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


Java ActiveMQConnection.close方法代码示例

本文整理汇总了Java中org.apache.activemq.ActiveMQConnection.close方法的典型用法代码示例。如果您正苦于以下问题:Java ActiveMQConnection.close方法的具体用法?Java ActiveMQConnection.close怎么用?Java ActiveMQConnection.close使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.apache.activemq.ActiveMQConnection的用法示例。


在下文中一共展示了ActiveMQConnection.close方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: sendTestStreamMessage

import org.apache.activemq.ActiveMQConnection; //导入方法依赖的package包/类
private void sendTestStreamMessage(ActiveMQConnectionFactory factory, String message) throws JMSException {
   ActiveMQConnection connection = (ActiveMQConnection) factory.createConnection();
   Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
   MessageProducer producer = session.createProducer(queue);
   StreamMessage streamMessage = session.createStreamMessage();

   streamMessage.writeBoolean(true);
   streamMessage.writeByte((byte) 10);
   streamMessage.writeBytes(TEXT.getBytes());
   streamMessage.writeChar('A');
   streamMessage.writeDouble(55.3D);
   streamMessage.writeFloat(79.1F);
   streamMessage.writeInt(37);
   streamMessage.writeLong(56652L);
   streamMessage.writeObject(new String("VVVV"));
   streamMessage.writeShort((short) 333);
   streamMessage.writeString(TEXT);

   producer.send(streamMessage);
   connection.close();
}
 
开发者ID:apache,项目名称:activemq-artemis,代码行数:22,代码来源:MessageCompressionTest.java

示例2: sendTestMapMessage

import org.apache.activemq.ActiveMQConnection; //导入方法依赖的package包/类
private void sendTestMapMessage(ActiveMQConnectionFactory factory, String message) throws JMSException {
   ActiveMQConnection connection = (ActiveMQConnection) factory.createConnection();
   Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
   MessageProducer producer = session.createProducer(queue);
   MapMessage mapMessage = session.createMapMessage();

   mapMessage.setBoolean("boolean-type", true);
   mapMessage.setByte("byte-type", (byte) 10);
   mapMessage.setBytes("bytes-type", TEXT.getBytes());
   mapMessage.setChar("char-type", 'A');
   mapMessage.setDouble("double-type", 55.3D);
   mapMessage.setFloat("float-type", 79.1F);
   mapMessage.setInt("int-type", 37);
   mapMessage.setLong("long-type", 56652L);
   mapMessage.setObject("object-type", new String("VVVV"));
   mapMessage.setShort("short-type", (short) 333);
   mapMessage.setString("string-type", TEXT);

   producer.send(mapMessage);
   connection.close();
}
 
开发者ID:apache,项目名称:activemq-artemis,代码行数:22,代码来源:MessageCompressionTest.java

示例3: closeConnection

import org.apache.activemq.ActiveMQConnection; //导入方法依赖的package包/类
static void closeConnection(Session session, ActiveMQConnection connection) {
    try {
        session.close();
        connection.close();
    } catch (JMSException ex) {
        throw new MessageQueueException("Could not close session connection", ex);
    }
}
 
开发者ID:code-obos,项目名称:servicebuilder,代码行数:9,代码来源:ActiveMqUtils.java

示例4: 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

示例5: testTempQueueDelete

import org.apache.activemq.ActiveMQConnection; //导入方法依赖的package包/类
@Test
public void testTempQueueDelete() throws Exception {
   connection.start();
   QueueSession queueSession = connection.createQueueSession(false, Session.AUTO_ACKNOWLEDGE);

   TemporaryQueue tempQueue = queueSession.createTemporaryQueue();

   ActiveMQConnection newConn = (ActiveMQConnection) factory.createConnection();
   try {
      QueueSession newQueueSession = newConn.createQueueSession(false, Session.AUTO_ACKNOWLEDGE);
      QueueSender queueSender = newQueueSession.createSender(tempQueue);

      Message msg = queueSession.createMessage();
      queueSender.send(msg);

      try {
         QueueReceiver consumer = newQueueSession.createReceiver(tempQueue);
         fail("should have gotten exception but got consumer: " + consumer);
      } catch (JMSException ex) {
         //correct
      }

      connection.close();

      try {
         Message newMsg = newQueueSession.createMessage();
         queueSender.send(newMsg);
      } catch (JMSException e) {
         //ok
      }

   } finally {
      newConn.close();
   }
}
 
开发者ID:apache,项目名称:activemq-artemis,代码行数:36,代码来源:SimpleOpenWireTest.java

示例6: sendTestMessage

import org.apache.activemq.ActiveMQConnection; //导入方法依赖的package包/类
private void sendTestMessage(ActiveMQConnectionFactory factory, String message) throws JMSException {
   ActiveMQConnection connection = (ActiveMQConnection) factory.createConnection();
   Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
   MessageProducer producer = session.createProducer(queue);
   producer.send(session.createTextMessage(message));
   connection.close();
}
 
开发者ID:apache,项目名称:activemq-artemis,代码行数:8,代码来源:MessageCompressionTest.java

示例7: receiveTestStreamMessage

import org.apache.activemq.ActiveMQConnection; //导入方法依赖的package包/类
private ActiveMQStreamMessage receiveTestStreamMessage(ActiveMQConnectionFactory factory) throws JMSException {
   ActiveMQConnection connection = (ActiveMQConnection) factory.createConnection();
   connection.start();
   Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
   MessageConsumer consumer = session.createConsumer(queue);
   ActiveMQStreamMessage rc = (ActiveMQStreamMessage) consumer.receive();
   connection.close();
   return rc;
}
 
开发者ID:apache,项目名称:activemq-artemis,代码行数:10,代码来源:MessageCompressionTest.java

示例8: testDurableSubRedeliveryFlagAfterRestartNotSupported

import org.apache.activemq.ActiveMQConnection; //导入方法依赖的package包/类
@org.junit.Test
public void testDurableSubRedeliveryFlagAfterRestartNotSupported() throws Exception {

   ConnectionFactory connectionFactory = new ActiveMQConnectionFactory("failover:(" + broker.getTransportConnectors().get(0).getPublishableConnectString() + ")?jms.prefetchPolicy.all=0");
   connection = (ActiveMQConnection) connectionFactory.createConnection();
   connection.setClientID("id");
   connection.start();

   Session session = connection.createSession(false, Session.CLIENT_ACKNOWLEDGE);
   ActiveMQTopic destination = new ActiveMQTopic(queueName);

   TopicSubscriber durableSub = session.createDurableSubscriber(destination, "id");

   populateDestination(10, destination, connection);

   TextMessage msg = null;
   for (int i = 0; i < 5; i++) {
      msg = (TextMessage) durableSub.receive(20000);
      LOG.info("not redelivered? got: " + msg);
      assertNotNull("got the message", msg);
      assertEquals("first delivery", 1, msg.getLongProperty("JMSXDeliveryCount"));
      assertEquals("not a redelivery", false, msg.getJMSRedelivered());
   }
   durableSub.close();

   restartBroker();

   // make failover aware of the restarted auto assigned port
   connection.getTransport().narrow(FailoverTransport.class).add(true, broker.getTransportConnectors().get(0).getPublishableConnectString());

   durableSub = session.createDurableSubscriber(destination, "id");
   for (int i = 0; i < 10; i++) {
      msg = (TextMessage) durableSub.receive(4000);
      LOG.info("redelivered? got: " + msg);
      assertNotNull("got the message again", msg);
      assertEquals("no reDelivery flag", false, msg.getJMSRedelivered());
      msg.acknowledge();
   }
   connection.close();
}
 
开发者ID:apache,项目名称:activemq-artemis,代码行数:41,代码来源:RedeliveryRestartTest.java

示例9: 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

示例10: receiveTestMessage

import org.apache.activemq.ActiveMQConnection; //导入方法依赖的package包/类
private ActiveMQTextMessage receiveTestMessage(ActiveMQConnectionFactory factory) throws JMSException {
   ActiveMQConnection connection = (ActiveMQConnection) factory.createConnection();
   connection.start();
   Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
   MessageConsumer consumer = session.createConsumer(queue);
   ActiveMQTextMessage rc = (ActiveMQTextMessage) consumer.receive();
   connection.close();
   return rc;
}
 
开发者ID:apache,项目名称:activemq-artemis,代码行数:10,代码来源:MessageCompressionTest.java

示例11: receiveMessage

import org.apache.activemq.ActiveMQConnection; //导入方法依赖的package包/类
private Message receiveMessage(ActiveMQConnectionFactory cf, Queue destination) throws Exception {
   final ActiveMQConnection connection = (ActiveMQConnection) cf.createConnection();
   connection.start();
   final Session consumerSession = connection.createSession(true, Session.SESSION_TRANSACTED);
   final MessageConsumer consumer = consumerSession.createConsumer(destination);
   Message msg = consumer.receive(5000);
   consumerSession.commit();
   connection.close();
   return msg;
}
 
开发者ID:apache,项目名称:activemq-artemis,代码行数:11,代码来源:FailoverConsumerOutstandingCommitTest.java

示例12: tearDown

import org.apache.activemq.ActiveMQConnection; //导入方法依赖的package包/类
@After
public void tearDown() throws Exception {
   for (ActiveMQConnection conn : connections) {
      conn.close();
   }
   server0.stop();
   server1.stop();
}
 
开发者ID:apache,项目名称:activemq-artemis,代码行数:9,代码来源:TwoBrokerFailoverClusterTest.java

示例13: sendTestObjectMessage

import org.apache.activemq.ActiveMQConnection; //导入方法依赖的package包/类
private void sendTestObjectMessage(ActiveMQConnectionFactory factory, String message) throws JMSException {
   ActiveMQConnection connection = (ActiveMQConnection) factory.createConnection();
   Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
   MessageProducer producer = session.createProducer(queue);
   ObjectMessage objectMessage = session.createObjectMessage();

   objectMessage.setObject(TEXT);

   producer.send(objectMessage);
   connection.close();
}
 
开发者ID:apache,项目名称:activemq-artemis,代码行数:12,代码来源:MessageCompressionTest.java

示例14: 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

示例15: testPrefetch1MessageNotDispatched

import org.apache.activemq.ActiveMQConnection; //导入方法依赖的package包/类
@Test
public void testPrefetch1MessageNotDispatched() throws Exception {
   // Set prefetch to 1
   connection.getPrefetchPolicy().setAll(1);
   connection.start();

   Session session = connection.createSession(true, 0);
   ActiveMQDestination destination = createDestination(session, ActiveMQDestination.QUEUE_TYPE);
   MessageConsumer consumer = session.createConsumer(destination);

   // Send 2 messages to the destination.
   sendMessages(session, destination, 2);
   session.commit();

   // The prefetch should fill up with 1 message.
   // Since prefetch is still full, the 2nd message should get dispatched
   // to another consumer.. lets create the 2nd consumer test that it does
   // make sure it does.
   ActiveMQConnection connection2 = (ActiveMQConnection) factory.createConnection();
   connection2.start();
   Session session2 = connection2.createSession(true, 0);
   MessageConsumer consumer2 = session2.createConsumer(destination);

   System.out.println("consumer receiving ...");
   // Pick up the first message.
   Message message1 = consumer.receive(1000);
   System.out.println("received1: " + message1);
   assertNotNull(message1);

   System.out.println("consumer 2 receiving...");
   // Pick up the 2nd messages.
   Message message2 = consumer2.receive(5000);
   System.out.println("received2: " + message2);
   assertNotNull(message2);

   System.out.println("committing sessions !! " + session.getClass().getName());
   session.commit();
   System.out.println("committed session, now 2");
   session2.commit();

   System.out.println("all committed");
   Message m = consumer.receiveNoWait();
   System.out.println("received 3: " + m);
   assertNull(m);

   try {
      connection2.close();
   } catch (Throwable e) {
      System.err.println("exception e: " + e);
      e.printStackTrace();
   }

   System.out.println("Test finished!!");
}
 
开发者ID:apache,项目名称:activemq-artemis,代码行数:55,代码来源:JMSConsumer11Test.java


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