• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Java QueueRequestor类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Java中javax.jms.QueueRequestor的典型用法代码示例。如果您正苦于以下问题:Java QueueRequestor类的具体用法?Java QueueRequestor怎么用?Java QueueRequestor使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



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

示例1: setUp

import javax.jms.QueueRequestor; //导入依赖的package包/类
@Override
protected void setUp() throws Exception {
   super.setUp();
   context = createApplicationContext();

   createConnections();

   requestServerSession = localConnection.createQueueSession(false, Session.AUTO_ACKNOWLEDGE);
   Queue theQueue = requestServerSession.createQueue(getClass().getName());
   requestServerConsumer = requestServerSession.createConsumer(theQueue);
   requestServerConsumer.setMessageListener(this);
   requestServerProducer = requestServerSession.createProducer(null);

   QueueSession session = remoteConnection.createQueueSession(false, Session.AUTO_ACKNOWLEDGE);
   requestor = new QueueRequestor(session, theQueue);
}
 
开发者ID:apache,项目名称:activemq-artemis,代码行数:17,代码来源:QueueBridgeTest.java


示例2: setUp

import javax.jms.QueueRequestor; //导入依赖的package包/类
@Override
protected void setUp() throws Exception {
   super.setUp();

   context = createApplicationContext();

   createConnections();

   requestServerSession = localConnection.createQueueSession(false, Session.AUTO_ACKNOWLEDGE);
   theQueue = requestServerSession.createQueue(QUEUE_NAME);
   requestServerConsumer = requestServerSession.createConsumer(theQueue);
   requestServerProducer = requestServerSession.createProducer(null);

   QueueSession session = localConnection.createQueueSession(false, Session.AUTO_ACKNOWLEDGE);
   requestor = new QueueRequestor(session, theQueue);
}
 
开发者ID:apache,项目名称:activemq-artemis,代码行数:17,代码来源:PurgeCommandTest.java


示例3: getDeployment

import javax.jms.QueueRequestor; //导入依赖的package包/类
@Deployment
public static JavaArchive getDeployment() {
	return ShrinkWrap.create(JavaArchive.class, "test.jar")
			.addPackages(true, "victor.training.jee6")
			.addPackages(true, "org.mockito")
			.addPackages(true, "org.apache.tools")
			.addPackages(true, "org.objenesis")
			.addClass(QueueRequestor.class)
			.addAsManifestResource(new File("src/main/webapp/WEB-INF/beans.xml"))
			;
}
 
开发者ID:victorrentea,项目名称:training,代码行数:12,代码来源:AbstractArquillianTest.java


示例4: getDeployment

import javax.jms.QueueRequestor; //导入依赖的package包/类
@Deployment
public static JavaArchive getDeployment() {
	return ShrinkWrap.create(JavaArchive.class, "test.jar").addPackages(true, "victor.training.ejb")
			.addPackages(true, "org.mockito")
			.addPackages(true, "org.objenesis").addClass(QueueRequestor.class);
}
 
开发者ID:victorrentea,项目名称:training,代码行数:7,代码来源:EJBTest.java


示例5: main

import javax.jms.QueueRequestor; //导入依赖的package包/类
public static void main(final String[] args) throws Exception {
   QueueConnection connection = null;
   InitialContext initialContext = null;
   try {
      // Step 1. Create an initial context to perform the JNDI lookup.
      initialContext = new InitialContext();

      // Step 2. Perfom a lookup on the queue
      Queue queue = (Queue) initialContext.lookup("queue/exampleQueue");

      // Step 3. Look-up the JMS queue connection factory
      QueueConnectionFactory cf = (QueueConnectionFactory) initialContext.lookup("ConnectionFactory");

      // Step 4. Create a TextReverserService which consumes messages from the queue and sends message with reversed
      // text
      TextReverserService reverserService = new TextReverserService(cf, queue);

      // Step 5. Create a JMS QueueConnection
      connection = cf.createQueueConnection();

      // Step 6. Start the connection
      connection.start();

      // Step 7. Create a JMS queue session with AUTO_ACKNOWLEDGE mode
      QueueSession session = connection.createQueueSession(false, Session.AUTO_ACKNOWLEDGE);

      // Step 8. Create a JMS queue requestor to send requests to the queue
      QueueRequestor queueRequestor = new QueueRequestor(session, queue);

      // Step 9. Create a JMS message to send as a request
      TextMessage request = session.createTextMessage("Hello, World!");

      // Step 10. Use the requestor to send the request and wait to receive a reply
      TextMessage reply = (TextMessage) queueRequestor.request(request);

      // Step 11. The reply's text contains the reversed request's text
      System.out.println("Send request: " + request.getText());
      System.out.println("Received reply:" + reply.getText());

      // Step.12 close the queue requestor
      queueRequestor.close();

      // Step 13. close the text reverser service
      reverserService.close();
   } finally {
      if (connection != null) {
         try {
            // Step 14. Be sure to close the JMS resources!
            connection.close();
         } catch (JMSException e) {
            e.printStackTrace();
         }
      }

      if (initialContext != null) {
         // Also the InitialContext
         initialContext.close();
      }
   }
}
 
开发者ID:apache,项目名称:activemq-artemis,代码行数:61,代码来源:QueueRequestorExample.java


示例6: getMessageCount

import javax.jms.QueueRequestor; //导入依赖的package包/类
private static int getMessageCount(final Connection connection) throws Exception {
   QueueSession session = ((QueueConnection) connection).createQueueSession(false, Session.AUTO_ACKNOWLEDGE);

   Queue managementQueue = ActiveMQJMSClient.createQueue("activemq.management");

   QueueRequestor requestor = new QueueRequestor(session, managementQueue);

   connection.start();

   Message m = session.createMessage();

   JMSManagementHelper.putAttribute(m, ResourceNames.QUEUE + "exampleQueue", "messageCount");

   Message response = requestor.request(m);

   int messageCount = (Integer) JMSManagementHelper.getResult(response, Integer.class);

   return messageCount;
}
 
开发者ID:apache,项目名称:activemq-artemis,代码行数:20,代码来源:PreacknowledgeExample.java


示例7: test

import javax.jms.QueueRequestor; //导入依赖的package包/类
@Test(timeout = 5 * 60 * 1000)
public void test() throws Throwable {
   executeCommand("bundle:list");

   withinReason(new Callable<Boolean>() {
      @Override
      public Boolean call() throws Exception {
         assertTrue("artemis bundle installed", verifyBundleInstalled("artemis-server-osgi"));
         return true;
      }
   });

   Object service = waitForService("(objectClass=org.apache.activemq.artemis.core.server.ActiveMQServer)", 30000);
   assertNotNull(service);
   LOG.info("have service " + service);

   executeCommand("service:list -n");

   Connection connection = null;
   try {
      JmsConnectionFactory factory = new JmsConnectionFactory("amqp://localhost:5672");
      connection = factory.createConnection(USER, PASSWORD);
      connection.start();

      QueueSession sess = (QueueSession) connection.createSession(false, javax.jms.Session.AUTO_ACKNOWLEDGE);
      Queue queue = sess.createQueue("exampleQueue");
      MessageProducer producer = sess.createProducer(queue);
      producer.send(sess.createTextMessage("TEST"));

      // Test browsing
      try (QueueBrowser browser = sess.createBrowser(queue)) {
         Enumeration messages = browser.getEnumeration();
         while (messages.hasMoreElements()) {
            messages.nextElement();
         }
      }

      // Test management
      Queue managementQueue = sess.createQueue("activemq.management");
      QueueRequestor requestor = new QueueRequestor(sess, managementQueue);
      connection.start();
      TextMessage m = sess.createTextMessage();
      m.setStringProperty("_AMQ_ResourceName", "broker");
      m.setStringProperty("_AMQ_OperationName", "getQueueNames");
      m.setText("[\"ANYCAST\"]");
      Message reply = requestor.request(m);
      String json = ((TextMessage) reply).getText();
      JsonArray array = Json.createReader(new StringReader(json)).readArray();
      List<JsonString> queues = (List<JsonString>) array.get(0);
      assertNotNull(queues);
      assertFalse(queues.isEmpty());

      MessageConsumer consumer = sess.createConsumer(queue);
      Message msg = consumer.receive(5000);
      assertNotNull(msg);
   } finally {
      if (connection != null) {
         connection.close();
      }
   }
}
 
开发者ID:apache,项目名称:activemq-artemis,代码行数:62,代码来源:ArtemisFeatureTest.java


示例8: TemporaryQueueExecutor

import javax.jms.QueueRequestor; //导入依赖的package包/类
/**
 * Constructor.
 *
 * @param session
 *            the session to use to send the message
 * @param destination
 *            the queue to send the message on
 * @throws JMSException
 *             when internally used {@link QueueRequestor} can not be
 *             constructed with <code>session</code> and
 *             <code>destination</code>
 */
public TemporaryQueueExecutor(QueueSession session, Queue destination) throws JMSException {
    requestor = new QueueRequestor(session, destination);
}
 
开发者ID:johrstrom,项目名称:cloud-meter,代码行数:16,代码来源:TemporaryQueueExecutor.java


示例9: TemporaryQueueExecutor

import javax.jms.QueueRequestor; //导入依赖的package包/类
/**
 * Constructor.
 *
 * @param session
 *            the session to use to send the message
 * @param destination
 *            the queue to send the message on
 * @throws JMSException
 */
public TemporaryQueueExecutor(QueueSession session, Queue destination) throws JMSException {
    requestor = new QueueRequestor(session, destination);
}
 
开发者ID:botelhojp,项目名称:apache-jmeter-2.10,代码行数:13,代码来源:TemporaryQueueExecutor.java



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java SVNLogClient类代码示例发布时间:2022-05-22
下一篇:
Java LogHandler类代码示例发布时间:2022-05-22
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap