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


Java Queue类代码示例

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


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

示例1: setUp

import javax.jms.Queue; //导入依赖的package包/类
@BeforeEach
public void setUp() throws JMSException {
    initMocks(this);
    when(mockEvent.getTarget()).thenReturn(of(rdf.createIRI("trellis:repository/resource")));
    when(mockEvent.getAgents()).thenReturn(singleton(Trellis.AdministratorAgent));
    when(mockEvent.getCreated()).thenReturn(time);
    when(mockEvent.getIdentifier()).thenReturn(rdf.createIRI("urn:test"));
    when(mockEvent.getTypes()).thenReturn(singleton(AS.Update));
    when(mockEvent.getTargetTypes()).thenReturn(singleton(LDP.RDFSource));
    when(mockEvent.getInbox()).thenReturn(empty());

    when(mockConnection.createSession(anyBoolean(), eq(AUTO_ACKNOWLEDGE))).thenReturn(mockSession);
    when(mockSession.createQueue(eq(queueName))).thenReturn(mockQueue);
    when(mockSession.createTextMessage(anyString())).thenReturn(mockMessage);
    when(mockSession.createProducer(any(Queue.class))).thenReturn(mockProducer);

    doNothing().when(mockProducer).send(any(TextMessage.class));
}
 
开发者ID:trellis-ldp,项目名称:trellis-jms,代码行数:19,代码来源:JmsPublisherTest.java

示例2: createQueue

import javax.jms.Queue; //导入依赖的package包/类
/**
 * Deals with reconnecting or if broker gone down, fails
 *
 * @param queueName
 * @return
 * @throws JMSException
 */
protected Queue createQueue(String queueName) throws JMSException {

	// Deals with reconnecting or if broker gone down, fails
	try {
		if (connection==null) createConnection();
		if (qSession == null) createQSession();

		return qSession.createQueue(queueName);

	} catch (Exception ne) {
		createConnection();
		createQSession();

		return qSession.createQueue(queueName);
	}
}
 
开发者ID:eclipse,项目名称:scanning,代码行数:24,代码来源:AbstractConnection.java

示例3: sendRequest

import javax.jms.Queue; //导入依赖的package包/类
public String sendRequest(Optional<String> routeId) {
    CompactRequest req = new CompactRequest(routeId.orElse("asdf"));
    try {
        TextMessage msg = context.createTextMessage(JsonMapper.serializeOrThrow(req));
        msg.setJMSDeliveryMode(DeliveryMode.NON_PERSISTENT);

        Queue answerQ = context.createTemporaryQueue();
        msg.setJMSReplyTo(answerQ);

        context.createProducer().send(minQ, msg);

        Message response = context.createConsumer(answerQ).receive();
        if (response instanceof TextMessage) {
            return ((TextMessage) response).getText();
        }

        return "";
    } catch (JMSException e) {
        return e.getMessage();
    }
}
 
开发者ID:RWTH-i5-IDSG,项目名称:xsharing-services-router,代码行数:22,代码来源:CompactCaller.java

示例4: testReceiveNoWait

import javax.jms.Queue; //导入依赖的package包/类
@Test
public void testReceiveNoWait() throws JMSException {
    JmsPoolConnection connection = (JmsPoolConnection) cf.createQueueConnection();
    Session session = connection.createSession();
    Queue queue = session.createTemporaryQueue();
    MessageConsumer consumer = session.createConsumer(queue, "Color = Red");

    assertNull(consumer.receiveNoWait());

    consumer.close();

    try {
        consumer.receiveNoWait();
        fail("Should not be able to interact with closed consumer");
    } catch (IllegalStateException ise) {}
}
 
开发者ID:messaginghub,项目名称:pooled-jms,代码行数:17,代码来源:JmsPoolMessageConusmerTest.java

示例5: doTestCreateQueueSender

import javax.jms.Queue; //导入依赖的package包/类
private void doTestCreateQueueSender(boolean useAnonymousProducers) throws JMSException {
    cf.setUseAnonymousProducers(useAnonymousProducers);

    JmsPoolConnection connection = (JmsPoolConnection) cf.createConnection();
    QueueSession session = connection.createQueueSession(false, Session.AUTO_ACKNOWLEDGE);

    Queue queue1 = session.createTemporaryQueue();
    Queue queue2 = session.createTemporaryQueue();

    JmsPoolQueueSender sender1 = (JmsPoolQueueSender) session.createSender(queue1);
    JmsPoolQueueSender sender2 = (JmsPoolQueueSender) session.createSender(queue2);

    if (useAnonymousProducers) {
        assertSame(sender1.getMessageProducer(), sender2.getMessageProducer());
    } else {
        assertNotSame(sender1.getMessageProducer(), sender2.getMessageProducer());
    }

    connection.close();
}
 
开发者ID:messaginghub,项目名称:pooled-jms,代码行数:21,代码来源:JmsPoolWrappedProducersTest.java

示例6: testGetTopicSubscriber

import javax.jms.Queue; //导入依赖的package包/类
@Test
public void testGetTopicSubscriber() throws JMSException {
    JmsPoolConnection connection = (JmsPoolConnection) cf.createQueueConnection();
    QueueSession session = connection.createQueueSession(false, Session.AUTO_ACKNOWLEDGE);
    Queue queue = session.createTemporaryQueue();
    JmsPoolQueueSender sender = (JmsPoolQueueSender) session.createSender(queue);

    assertNotNull(sender.getQueueSender());
    assertTrue(sender.getQueueSender() instanceof MockJMSQueueSender);

    sender.close();

    try {
        sender.getQueueSender();
        fail("Cannot read state on closed sender");
    } catch (IllegalStateException ise) {}
}
 
开发者ID:messaginghub,项目名称:pooled-jms,代码行数:18,代码来源:JmsPoolQueueSenderTest.java

示例7: testGetMessageSelector

import javax.jms.Queue; //导入依赖的package包/类
@Test
public void testGetMessageSelector() throws JMSException {
    JmsPoolConnection connection = (JmsPoolConnection) cf.createQueueConnection();
    QueueSession session = connection.createQueueSession(false, Session.AUTO_ACKNOWLEDGE);
    Queue queue = session.createTemporaryQueue();
    QueueBrowser browser = session.createBrowser(queue, "color = red");

    assertNotNull(browser.getMessageSelector());
    assertEquals("color = red", browser.getMessageSelector());

    browser.close();

    try {
        browser.getMessageSelector();
        fail("Should not be able to use a closed browser");
    } catch (IllegalStateException ise) {
    }
}
 
开发者ID:messaginghub,项目名称:pooled-jms,代码行数:19,代码来源:JmsQueueBrowserTest.java

示例8: testGetEnumeration

import javax.jms.Queue; //导入依赖的package包/类
@Test
public void testGetEnumeration() throws JMSException {
    JmsPoolConnection connection = (JmsPoolConnection) cf.createQueueConnection();
    QueueSession session = connection.createQueueSession(false, Session.AUTO_ACKNOWLEDGE);
    Queue queue = session.createTemporaryQueue();
    QueueBrowser browser = session.createBrowser(queue);

    assertNotNull(browser.getEnumeration());

    browser.close();

    try {
        browser.getEnumeration();
        fail("Should not be able to use a closed browser");
    } catch (IllegalStateException ise) {
    }
}
 
开发者ID:messaginghub,项目名称:pooled-jms,代码行数:18,代码来源:JmsQueueBrowserTest.java

示例9: sendRequest

import javax.jms.Queue; //导入依赖的package包/类
public String sendRequest(Optional<String> routeId) {
    DetailsRequest req = new DetailsRequest(routeId.orElse("asdf"));
    try {
        TextMessage msg = context.createTextMessage(JsonMapper.serializeOrThrow(req));
        msg.setJMSDeliveryMode(DeliveryMode.NON_PERSISTENT);

        Queue answerQ = context.createTemporaryQueue();
        msg.setJMSReplyTo(answerQ);

        context.createProducer().send(minQ, msg);

        Message response = context.createConsumer(answerQ).receive();
        if (response instanceof TextMessage) {
            return ((TextMessage) response).getText();
        }

        return "";
    } catch (JMSException e) {
        return e.getMessage();
    }
}
 
开发者ID:RWTH-i5-IDSG,项目名称:xsharing-services-router,代码行数:22,代码来源:DetailsCaller.java

示例10: run

import javax.jms.Queue; //导入依赖的package包/类
@Override
public void run(String... strings) throws Exception {
    final String messageText = "Hello World";
    LOG.info("============= Sending " + messageText);
    this.jmsTemplate.send("example", new MessageCreator() {

        @Override
        public Message createMessage(Session session) throws JMSException {
            Queue replyQueue = session.createQueue("reply-queue");

            TextMessage message = session.createTextMessage(messageText);

            message.setJMSCorrelationID(correlationID.toString());
            message.setJMSReplyTo(replyQueue);

            return message;
        }
    });
}
 
开发者ID:tabish121,项目名称:qpid-jms-spring-boot,代码行数:20,代码来源:Requestor.java

示例11: init

import javax.jms.Queue; //导入依赖的package包/类
/**
 * Inits the.
 *
 * @throws JMSException the jMS exception
 */
public void init() throws JMSException {

  connection = connFactory.createConnection();
  // lets make it transactional
  session = connection.createSession(true, Session.SESSION_TRANSACTED);
  Queue controllerQueue = session.createQueue(ctrlrQueueName);

  MessageConsumer consumer = session.createConsumer(controllerQueue);

  consumer.setMessageListener(this);
  connection.start();

  logger.info(">>>>>>>>>>>>>>>>Inductor Listener Waiting for messages...");
}
 
开发者ID:oneops,项目名称:oneops,代码行数:20,代码来源:InductorListener.java

示例12: getQueueSender

import javax.jms.Queue; //导入依赖的package包/类
private QueueSender getQueueSender(Queue destination) throws JMSException {
    QueueSender result = null;

    if (useAnonymousProducers) {
        result = safeGetSessionHolder().getOrCreateSender();
    } else {
        result = ((QueueSession) getInternalSession()).createSender(destination);
    }

    return result;
}
 
开发者ID:messaginghub,项目名称:pooled-jms,代码行数:12,代码来源:JmsPoolSession.java

示例13: createQueue

import javax.jms.Queue; //导入依赖的package包/类
@Override
public Queue createQueue(String queueName) {
    try {
        return getSession().createQueue(queueName);
    } catch (JMSException jmse) {
        throw JMSExceptionSupport.createRuntimeException(jmse);
    }
}
 
开发者ID:messaginghub,项目名称:pooled-jms,代码行数:9,代码来源:JmsPoolJMSContext.java

示例14: createBrowser

import javax.jms.Queue; //导入依赖的package包/类
@Override
public QueueBrowser createBrowser(Queue queue) {
    try {
        return startIfNeeded(getSession().createBrowser(queue));
    } catch (JMSException jmse) {
        throw JMSExceptionSupport.createRuntimeException(jmse);
    }
}
 
开发者ID:messaginghub,项目名称:pooled-jms,代码行数:9,代码来源:JmsPoolJMSContext.java

示例15: getJmsQueue

import javax.jms.Queue; //导入依赖的package包/类
/**
 * Get the OSCM task queue
 * 
 * @param context
 *            a JNDI context
 * @return the task queue
 */
private Queue getJmsQueue(InitialContext context) {
    try {
        Object lookup = context.lookup(JMS_QUEUE_JNDI_NAME);
        return Queue.class.cast(lookup);
    } catch (Exception e) {
        e.printStackTrace();
        return null;
    }
}
 
开发者ID:servicecatalog,项目名称:oscm,代码行数:17,代码来源:SubscriptionAgent.java


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