當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。