當前位置: 首頁>>代碼示例>>Java>>正文


Java MessageListener.onMessage方法代碼示例

本文整理匯總了Java中javax.jms.MessageListener.onMessage方法的典型用法代碼示例。如果您正苦於以下問題:Java MessageListener.onMessage方法的具體用法?Java MessageListener.onMessage怎麽用?Java MessageListener.onMessage使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在javax.jms.MessageListener的用法示例。


在下文中一共展示了MessageListener.onMessage方法的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: sendMessage

import javax.jms.MessageListener; //導入方法依賴的package包/類
@Override
public void sendMessage(final String destination, final Message message) {
    final Class<? extends MessageListener> mdbClass = messageDrivenBeanRegistry.get(destination);
    final Releaser releaser = new Releaser();
    final MessageListener mdb = dependencyInjection.getInstanceOf(mdbClass, releaser);
    try {
        mdb.onMessage(message);
    } finally {
        releaser.release();
    }
}
 
開發者ID:dajudge,項目名稱:testee.fi,代碼行數:12,代碼來源:TestQueueImpl.java

示例2: testListeners

import javax.jms.MessageListener; //導入方法依賴的package包/類
@Test
public void testListeners() throws Exception {
	TestBean testBean1 = context.getBean("testBean1", TestBean.class);
	TestBean testBean2 = context.getBean("testBean2", TestBean.class);
	TestMessageListener testBean3 = context.getBean("testBean3", TestMessageListener.class);

	assertNull(testBean1.getName());
	assertNull(testBean2.getName());
	assertNull(testBean3.message);

	TextMessage message1 = mock(TextMessage.class);
	given(message1.getText()).willReturn("Test1");

	MessageListener listener1 = getListener("listener1");
	listener1.onMessage(message1);
	assertEquals("Test1", testBean1.getName());

	TextMessage message2 = mock(TextMessage.class);
	given(message2.getText()).willReturn("Test2");

	MessageListener listener2 = getListener("listener2");
	listener2.onMessage(message2);
	assertEquals("Test2", testBean2.getName());

	TextMessage message3 = mock(TextMessage.class);

	MessageListener listener3 = getListener(DefaultMessageListenerContainer.class.getName() + "#0");
	listener3.onMessage(message3);
	assertSame(message3, testBean3.message);
}
 
開發者ID:langtianya,項目名稱:spring4-understanding,代碼行數:31,代碼來源:JmsNamespaceHandlerTests.java

示例3: toProcessor

import javax.jms.MessageListener; //導入方法依賴的package包/類
/**
 * Allows a JMS {@link MessageListener} to be converted to a Camel {@link Processor}
 * so that we can provide better
 * <a href="">Bean Integration</a> so that we can use any JMS MessageListener in
 * in Camel as a bean
 * @param listener the JMS message listener
 * @return a newly created Camel Processor which when invoked will invoke
 * {@link MessageListener#onMessage(Message)}
 */
@Converter
public Processor toProcessor(final MessageListener listener) {
    return new Processor() {
        public void process(Exchange exchange) throws Exception {
            Message message = toMessage(exchange);
            listener.onMessage(message);
        }

        @Override
        public String toString() {
            return "Processor of MessageListener: " + listener;
        }
    };
}
 
開發者ID:DiamondLightSource,項目名稱:daq-eclipse,代碼行數:24,代碼來源:ActiveMQMessageConverter.java

示例4: execute

import javax.jms.MessageListener; //導入方法依賴的package包/類
@Override
public void execute(ActiveMQDestination destination, MessageListener listener) throws Exception {
   LOG.info("Initial query is creating: " + MESSAGE_COUNT + " messages");
   for (int i = 0; i < MESSAGE_COUNT; i++) {
      ActiveMQTextMessage message = new ActiveMQTextMessage();
      message.setText("Initial message: " + i + " loaded from query");
      listener.onMessage(message);
   }
}
 
開發者ID:apache,項目名稱:activemq-artemis,代碼行數:10,代碼來源:DummyMessageQuery.java

示例5: doInvokeListener

import javax.jms.MessageListener; //導入方法依賴的package包/類
/**
 * Invoke the specified listener as standard JMS MessageListener.
 * <p>Default implementation performs a plain invocation of the
 * {@code onMessage} method.
 * @param listener the JMS MessageListener to invoke
 * @param message the received JMS Message
 * @throws JMSException if thrown by JMS API methods
 * @see javax.jms.MessageListener#onMessage
 */
protected void doInvokeListener(MessageListener listener, Message message) throws JMSException {
	listener.onMessage(message);
}
 
開發者ID:langtianya,項目名稱:spring4-understanding,代碼行數:13,代碼來源:AbstractMessageListenerContainer.java


注:本文中的javax.jms.MessageListener.onMessage方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。