本文整理汇总了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();
}
}
示例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);
}
示例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;
}
};
}
示例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);
}
}
示例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);
}