本文整理汇总了Java中org.apache.activemq.ActiveMQConnection.start方法的典型用法代码示例。如果您正苦于以下问题:Java ActiveMQConnection.start方法的具体用法?Java ActiveMQConnection.start怎么用?Java ActiveMQConnection.start使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.activemq.ActiveMQConnection
的用法示例。
在下文中一共展示了ActiveMQConnection.start方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: testSimpleSendReceive
import org.apache.activemq.ActiveMQConnection; //导入方法依赖的package包/类
@Test
public void testSimpleSendReceive() throws Exception {
factory.setAlwaysSyncSend(true);
flowControlConnection = (ActiveMQConnection) factory.createConnection();
flowControlConnection.start();
Session session = flowControlConnection.createSession(false, Session.CLIENT_ACKNOWLEDGE);
MessageConsumer consumer = session.createConsumer(queueA);
// Test sending to Queue B it should not block.
CountDownLatch pubishDoneToQeueuA = asyncSendTo(queueA, "Message 1");
assertTrue(pubishDoneToQeueuA.await(2, TimeUnit.SECONDS));
TextMessage msg = (TextMessage) consumer.receive();
assertEquals("Message 1", msg.getText());
msg.acknowledge();
pubishDoneToQeueuA = asyncSendTo(queueA, "Message 2");
assertTrue(pubishDoneToQeueuA.await(2, TimeUnit.SECONDS));
msg = (TextMessage) consumer.receive();
assertEquals("Message 2", msg.getText());
msg.acknowledge();
consumer.close();
}
示例2: test2ndPublisherWithStandardConnectionThatIsBlocked
import org.apache.activemq.ActiveMQConnection; //导入方法依赖的package包/类
@Test
public void test2ndPublisherWithStandardConnectionThatIsBlocked() throws Exception {
flowControlConnection = (ActiveMQConnection) factory.createConnection();
flowControlConnection.start();
// Test sending to Queue A
// 1st send should not block.
fillQueue(queueA);
// Test sending to Queue B it should block.
// Since even though the it's queue limits have not been reached, the
// connection
// is blocked.
CountDownLatch pubishDoneToQeueuB = asyncSendTo(queueB, "Message 1");
assertFalse(pubishDoneToQeueuB.await(2, TimeUnit.SECONDS));
}
示例3: testUpdateUris
import org.apache.activemq.ActiveMQConnection; //导入方法依赖的package包/类
@Test
public void testUpdateUris() throws Exception {
ActiveMQConnectionFactory cf = new ActiveMQConnectionFactory("failover:(" + tcpUri + ")?useExponentialBackOff=false");
ActiveMQConnection connection = (ActiveMQConnection) cf.createConnection();
try {
connection.start();
FailoverTransport failoverTransport = connection.getTransport().narrow(FailoverTransport.class);
URI[] bunchOfUnknownAndOneKnown = new URI[]{new URI("tcp://unknownHost:" + tcpUri.getPort()), new URI("tcp://unknownHost2:" + tcpUri.getPort()), new URI("tcp://localhost:2222")};
failoverTransport.add(false, bunchOfUnknownAndOneKnown);
} finally {
if (connection != null) {
connection.close();
}
}
}
示例4: testZeroPrefetchConsumerIsAborted
import org.apache.activemq.ActiveMQConnection; //导入方法依赖的package包/类
@Test
public void testZeroPrefetchConsumerIsAborted() throws Exception {
strategy.setMaxTimeSinceLastAck(2000); // Make it shorter
ActiveMQConnection conn = (ActiveMQConnection) createConnectionFactory().createConnection();
conn.setExceptionListener(this);
connections.add(conn);
Session sess = conn.createSession(false, Session.CLIENT_ACKNOWLEDGE);
final MessageConsumer consumer = sess.createConsumer(destination);
assertNotNull(consumer);
conn.start();
startProducers(destination, 20);
Message message = consumer.receive(5000);
assertNotNull(message);
TimeUnit.SECONDS.sleep(15);
try {
consumer.receive(5000);
fail("Slow consumer not aborted.");
} catch (Exception ex) {
}
}
示例5: openConnection
import org.apache.activemq.ActiveMQConnection; //导入方法依赖的package包/类
static ActiveMQConnection openConnection(String user, String password, String url) {
String brokerUrl = brokerUrl(url);
try {
ActiveMQConnection connection = ActiveMQConnection.makeConnection(user, password, brokerUrl);
connection.start();
return connection;
} catch (JMSException | URISyntaxException ex) {
throw new MessageQueueException("Could not establish connection to ActiveMQ", ex);
}
}
示例6: Copy
import org.apache.activemq.ActiveMQConnection; //导入方法依赖的package包/类
public Copy(ActiveMQConnectionFactory sourceCF, ActiveMQConnectionFactory destCF) throws JMSException {
this.counter = new AtomicInteger();
sconn = (ActiveMQConnection)sourceCF.createConnection();
dconn = (ActiveMQConnection)destCF.createConnection();
sconn.start();
dconn.start();
}
示例7: createConnection
import org.apache.activemq.ActiveMQConnection; //导入方法依赖的package包/类
private final Connection createConnection() throws JMSException
{
final ActiveMQConnection conn = (ActiveMQConnection)getConnectionFactory().createConnection();
conn.setExceptionListener(exceptionListener);
conn.addTransportListener(transportListener);
//
// Set ClientID
final String clientID = getClientID();
if (conn.getClientID() == null)
{
conn.setClientID(clientID);
}
else
{
if (conn.getClientID().equals(clientID))
{
throw new AdempiereException("Connection with clientID '" + clientID + "' already exists");
}
else
{
conn.setClientID(clientID);
}
}
//
// Start the connection
conn.start();
logger.info("Connection created and started: {}", conn);
return conn;
}
示例8: testSecurityContextClearedOnPurge
import org.apache.activemq.ActiveMQConnection; //导入方法依赖的package包/类
public void testSecurityContextClearedOnPurge() throws Exception {
connection.close();
ActiveMQConnectionFactory tcpFactory = new ActiveMQConnectionFactory(broker.getTransportConnectors().get(0).getPublishableConnectString());
ActiveMQConnection conn = (ActiveMQConnection) tcpFactory.createConnection("user", "password");
Session sess = conn.createSession(false, Session.AUTO_ACKNOWLEDGE);
conn.start();
final int numDests = broker.getRegionBroker().getDestinations().length;
for (int i=0; i<10; i++) {
MessageProducer p = sess.createProducer(new ActiveMQQueue("USERS.PURGE." + i));
p.close();
}
assertTrue("dests are purged", Wait.waitFor(new Wait.Condition() {
@Override
public boolean isSatisified() throws Exception {
LOG.info("dests, orig: " + numDests + ", now: "+ broker.getRegionBroker().getDestinations().length);
return (numDests + 1) == broker.getRegionBroker().getDestinations().length;
}
}));
// verify removed from connection security context
TransportConnection brokerConnection = broker.getTransportConnectors().get(0).getConnections().get(0);
TransportConnectionState transportConnectionState = brokerConnection.lookupConnectionState(conn.getConnectionInfo().getConnectionId());
assertEquals("no destinations", 0, transportConnectionState.getContext().getSecurityContext().getAuthorizedWriteDests().size());
}
示例9: createClients
import org.apache.activemq.ActiveMQConnection; //导入方法依赖的package包/类
@SuppressWarnings("unused")
protected void createClients(int numOfClients) throws Exception {
ActiveMQConnectionFactory factory = new ActiveMQConnectionFactory(clientUrl);
for (int i = 0; i < numOfClients; i++) {
ActiveMQConnection c = (ActiveMQConnection) factory.createConnection();
c.start();
Session s = c.createSession(false, Session.AUTO_ACKNOWLEDGE);
Queue queue = s.createQueue(getClass().getName());
MessageConsumer consumer = s.createConsumer(queue);
connections.add(c);
}
}
示例10: test2ndPublisherWithSyncSendConnectionThatIsBlocked
import org.apache.activemq.ActiveMQConnection; //导入方法依赖的package包/类
@Test
public void test2ndPublisherWithSyncSendConnectionThatIsBlocked() throws Exception {
factory.setAlwaysSyncSend(true);
flowControlConnection = (ActiveMQConnection) factory.createConnection();
flowControlConnection.start();
Session session = flowControlConnection.createSession(false, Session.CLIENT_ACKNOWLEDGE);
MessageConsumer consumer = session.createConsumer(queueB);
// Test sending to Queue A
// 1st send should not block. But the rest will.
fillQueue(queueA);
// Test sending to Queue B it should not block.
CountDownLatch pubishDoneToQeueuB = asyncSendTo(queueB, "Message 1");
assertTrue(pubishDoneToQeueuB.await(2, TimeUnit.SECONDS));
TextMessage msg = (TextMessage) consumer.receive();
assertEquals("Message 1", msg.getText());
msg.acknowledge();
pubishDoneToQeueuB = asyncSendTo(queueB, "Message 2");
assertTrue(pubishDoneToQeueuB.await(2, TimeUnit.SECONDS));
msg = (TextMessage) consumer.receive();
assertEquals("Message 2", msg.getText());
msg.acknowledge();
consumer.close();
}
示例11: receiveTestObjectMessage
import org.apache.activemq.ActiveMQConnection; //导入方法依赖的package包/类
private ActiveMQObjectMessage receiveTestObjectMessage(ActiveMQConnectionFactory factory) throws JMSException {
ActiveMQConnection connection = (ActiveMQConnection) factory.createConnection();
connection.start();
Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
MessageConsumer consumer = session.createConsumer(queue);
ActiveMQObjectMessage rc = (ActiveMQObjectMessage) consumer.receive();
connection.close();
return rc;
}
示例12: receiveTestMapMessage
import org.apache.activemq.ActiveMQConnection; //导入方法依赖的package包/类
private ActiveMQMapMessage receiveTestMapMessage(ActiveMQConnectionFactory factory) throws JMSException {
ActiveMQConnection connection = (ActiveMQConnection) factory.createConnection();
connection.start();
Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
MessageConsumer consumer = session.createConsumer(queue);
ActiveMQMapMessage rc = (ActiveMQMapMessage) consumer.receive();
connection.close();
return rc;
}
示例13: receiveTestBytesMessage
import org.apache.activemq.ActiveMQConnection; //导入方法依赖的package包/类
private ActiveMQBytesMessage receiveTestBytesMessage(ActiveMQConnectionFactory factory) throws JMSException, UnsupportedEncodingException {
ActiveMQConnection connection = (ActiveMQConnection) factory.createConnection();
connection.start();
Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
MessageConsumer consumer = session.createConsumer(queue);
ActiveMQBytesMessage rc = (ActiveMQBytesMessage) consumer.receive();
connection.close();
return rc;
}
示例14: testPublisherRecoverAfterBlock
import org.apache.activemq.ActiveMQConnection; //导入方法依赖的package包/类
@Test
public void testPublisherRecoverAfterBlock() throws Exception {
flowControlConnection = (ActiveMQConnection) factory.createConnection();
flowControlConnection.start();
final Session session = flowControlConnection.createSession(false, Session.CLIENT_ACKNOWLEDGE);
final MessageProducer producer = session.createProducer(queueA);
final AtomicBoolean done = new AtomicBoolean(true);
final AtomicBoolean keepGoing = new AtomicBoolean(true);
Thread thread = new Thread("Filler") {
int i;
@Override
public void run() {
while (keepGoing.get()) {
done.set(false);
try {
producer.send(session.createTextMessage("Test message " + ++i));
} catch (JMSException e) {
break;
}
}
}
};
thread.start();
waitForBlockedOrResourceLimit(done);
// after receiveing messges, producer should continue sending messages
// (done == false)
MessageConsumer consumer = session.createConsumer(queueA);
TextMessage msg;
for (int idx = 0; idx < 5; ++idx) {
msg = (TextMessage) consumer.receive(1000);
System.out.println("received: " + idx + ", msg: " + msg.getJMSMessageID());
msg.acknowledge();
}
Thread.sleep(1000);
keepGoing.set(false);
consumer.close();
assertFalse("producer has resumed", done.get());
}
示例15: testAsyncPublisherRecoverAfterBlock
import org.apache.activemq.ActiveMQConnection; //导入方法依赖的package包/类
@Test
public void testAsyncPublisherRecoverAfterBlock() throws Exception {
factory.setProducerWindowSize(1024 * 5);
factory.setUseAsyncSend(true);
flowControlConnection = (ActiveMQConnection) factory.createConnection();
flowControlConnection.start();
final Session session = flowControlConnection.createSession(false, Session.CLIENT_ACKNOWLEDGE);
final MessageProducer producer = session.createProducer(queueA);
final AtomicBoolean done = new AtomicBoolean(true);
final AtomicBoolean keepGoing = new AtomicBoolean(true);
Thread thread = new Thread("Filler") {
int i;
@Override
public void run() {
while (keepGoing.get()) {
done.set(false);
try {
producer.send(session.createTextMessage("Test message " + ++i));
} catch (JMSException e) {
}
}
}
};
thread.start();
waitForBlockedOrResourceLimit(done);
// after receiveing messges, producer should continue sending messages
// (done == false)
MessageConsumer consumer = session.createConsumer(queueA);
TextMessage msg;
for (int idx = 0; idx < 5; ++idx) {
msg = (TextMessage) consumer.receive(1000);
assertNotNull("Got a message", msg);
System.out.println("received: " + idx + ", msg: " + msg.getJMSMessageID());
msg.acknowledge();
}
Thread.sleep(1000);
keepGoing.set(false);
consumer.close();
assertFalse("producer has resumed", done.get());
}