当前位置: 首页>>代码示例>>Java>>正文


Java ActiveMQConnection.start方法代码示例

本文整理汇总了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();
}
 
开发者ID:apache,项目名称:activemq-artemis,代码行数:26,代码来源:ProducerFlowControlTest.java

示例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));
}
 
开发者ID:apache,项目名称:activemq-artemis,代码行数:17,代码来源:ProducerFlowControlTest.java

示例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();
      }
   }
}
 
开发者ID:apache,项目名称:activemq-artemis,代码行数:18,代码来源:FailoverTimeoutTest.java

示例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) {
   }
}
 
开发者ID:apache,项目名称:activemq-artemis,代码行数:26,代码来源:AbortSlowAckConsumer0Test.java

示例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);
    }
}
 
开发者ID:code-obos,项目名称:servicebuilder,代码行数:11,代码来源:ActiveMqUtils.java

示例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();
}
 
开发者ID:cschneider,项目名称:jms-copy,代码行数:8,代码来源:Copy.java

示例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;
}
 
开发者ID:metasfresh,项目名称:metasfresh,代码行数:34,代码来源:ActiveMQJMSEndpoint.java

示例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());
    }
 
开发者ID:ctytgat,项目名称:amq-jdbc-security,代码行数:28,代码来源:JdbcAuthenticationPluginTest.java

示例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);
   }
}
 
开发者ID:apache,项目名称:activemq-artemis,代码行数:13,代码来源:FailoverClusterTestSupport.java

示例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();
}
 
开发者ID:apache,项目名称:activemq-artemis,代码行数:30,代码来源:ProducerFlowControlTest.java

示例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;
}
 
开发者ID:apache,项目名称:activemq-artemis,代码行数:10,代码来源:MessageCompressionTest.java

示例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;
}
 
开发者ID:apache,项目名称:activemq-artemis,代码行数:10,代码来源:MessageCompressionTest.java

示例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;
}
 
开发者ID:apache,项目名称:activemq-artemis,代码行数:10,代码来源:MessageCompressionTest.java

示例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());
}
 
开发者ID:apache,项目名称:activemq-artemis,代码行数:45,代码来源:ProducerFlowControlTest.java

示例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());
}
 
开发者ID:apache,项目名称:activemq-artemis,代码行数:47,代码来源:ProducerFlowControlTest.java


注:本文中的org.apache.activemq.ActiveMQConnection.start方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。