本文整理汇总了Java中org.springframework.jms.listener.SessionAwareMessageListener类的典型用法代码示例。如果您正苦于以下问题:Java SessionAwareMessageListener类的具体用法?Java SessionAwareMessageListener怎么用?Java SessionAwareMessageListener使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
SessionAwareMessageListener类属于org.springframework.jms.listener包,在下文中一共展示了SessionAwareMessageListener类的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: JmsContainerManagerImpl
import org.springframework.jms.listener.SessionAwareMessageListener; //导入依赖的package包/类
/**
* Constructor.
*/
@Autowired
public JmsContainerManagerImpl(final ProcessCache processCache,
final @Qualifier("daqInConnectionFactory") ConnectionFactory updateConnectionFactory,
final @Qualifier("sourceUpdateManager") SessionAwareMessageListener<Message> listener,
final @Qualifier("clusterCache") ClusterCache clusterCache,
final ThreadPoolTaskExecutor daqThreadPoolTaskExecutor,
final DaqProperties properties) {
super();
this.processCache = processCache;
this.updateConnectionFactory = updateConnectionFactory;
this.listener = listener;
this.clusterCache = clusterCache;
this.daqThreadPoolTaskExecutor = daqThreadPoolTaskExecutor;
this.properties = properties;
}
示例2: setUp
import org.springframework.jms.listener.SessionAwareMessageListener; //导入依赖的package包/类
@Before
public void setUp() throws Exception {
mockProcessCache = EasyMock.createMock(ProcessCache.class);
mockListener = EasyMock.createMock(SessionAwareMessageListener.class);
mockClusterCache = EasyMock.createMock(ClusterCache.class);
jmsSender = new ActiveJmsSender();
JmsTemplate template = new JmsTemplate();
template.setConnectionFactory(daqInConnectionFactory);
template.setTimeToLive(60000);
jmsSender.setJmsTemplate(template);
// jmsContainerManager = new JmsContainerManagerImpl(mockProcessCache, daqInConnectionFactory, mockListener, mockClusterCache, new StandardEnvironment());
// jmsContainerManager.setConsumersInitial(1);
// jmsContainerManager.setConsumersMax(1);
// jmsContainerManager.setNbExecutorThreads(2);
// jmsContainerManager.setIdleTaskExecutionLimit(1);
// jmsContainerManager.setMaxMessages(1);
// jmsContainerManager.setReceiveTimeout(100);
// jmsContainerManager.setJmsUpdateQueueTrunk(testTrunkName);
// jmsContainerManager.setSessionTransacted(true);
// jmsContainerManager.setUpdateWarmUpSeconds(60);
}
示例3: invokeListener
import org.springframework.jms.listener.SessionAwareMessageListener; //导入依赖的package包/类
@SuppressWarnings("unchecked")
private void invokeListener(JmsListenerEndpoint endpoint, Message message) throws JMSException {
DefaultMessageListenerContainer messageListenerContainer = containerFactory.createListenerContainer(endpoint);
Object listener = messageListenerContainer.getMessageListener();
if (listener instanceof SessionAwareMessageListener) {
((SessionAwareMessageListener<Message>) listener).onMessage(message, mock(Session.class));
}
else {
((MessageListener) listener).onMessage(message);
}
}
开发者ID:langtianya,项目名称:spring4-understanding,代码行数:12,代码来源:JmsListenerContainerFactoryIntegrationTests.java
示例4: mockServerListener
import org.springframework.jms.listener.SessionAwareMessageListener; //导入依赖的package包/类
@Bean
public MessageListenerContainer mockServerListener(ActiveMQConnectionFactory connectionFactory) {
DefaultMessageListenerContainer container = new DefaultMessageListenerContainer();
container.setConnectionFactory(connectionFactory);
container.setDestination(new ActiveMQQueue("c2mon.client.request"));
container.setMessageListener((SessionAwareMessageListener) (message, session) -> {
session.createProducer(message.getJMSReplyTo()).send(session.createTextMessage("[]"));
});
return container;
}
示例5: onMessage
import org.springframework.jms.listener.SessionAwareMessageListener; //导入依赖的package包/类
/**
* Spring {@link SessionAwareMessageListener} entry point.
* <p>Delegates the message to the target listener method, with appropriate
* conversion of the message argument. If the target method returns a
* non-null object, wrap in a JMS message and send it back.
* @param message the incoming JMS message
* @param session the JMS session to operate on
* @throws JMSException if thrown by JMS API methods
*/
@Override
@SuppressWarnings("unchecked")
public void onMessage(Message message, Session session) throws JMSException {
// Check whether the delegate is a MessageListener impl itself.
// In that case, the adapter will simply act as a pass-through.
Object delegate = getDelegate();
if (delegate != this) {
if (delegate instanceof SessionAwareMessageListener) {
if (session != null) {
((SessionAwareMessageListener<Message>) delegate).onMessage(message, session);
return;
}
else if (!(delegate instanceof MessageListener)) {
throw new javax.jms.IllegalStateException("MessageListenerAdapter cannot handle a " +
"SessionAwareMessageListener delegate if it hasn't been invoked with a Session itself");
}
}
if (delegate instanceof MessageListener) {
((MessageListener) delegate).onMessage(message);
return;
}
}
// Regular case: find a handler method reflectively.
Object convertedMessage = extractMessage(message);
String methodName = getListenerMethodName(message, convertedMessage);
if (methodName == null) {
throw new javax.jms.IllegalStateException("No default listener method specified: " +
"Either specify a non-null value for the 'defaultListenerMethod' property or " +
"override the 'getListenerMethodName' method.");
}
// Invoke the handler method with appropriate arguments.
Object[] listenerArguments = buildListenerArguments(convertedMessage);
Object result = invokeListenerMethod(methodName, listenerArguments);
if (result != null) {
handleResult(result, message, session);
}
else {
logger.trace("No result object given - no result to handle");
}
}
示例6: setActionToProcessorMap
import org.springframework.jms.listener.SessionAwareMessageListener; //导入依赖的package包/类
@Required
public void setActionToProcessorMap(Map<String, SessionAwareMessageListener> actionToProcessorMap) {
this.actionToProcessorMap = actionToProcessorMap;
}
示例7: onMessage
import org.springframework.jms.listener.SessionAwareMessageListener; //导入依赖的package包/类
/**
* Spring {@link SessionAwareMessageListener} entry point.
* <p>Delegates the message to the target listener method, with appropriate
* conversion of the message argument. If the target method returns a
* non-null object, wrap in a JMS message and send it back.
* @param message the incoming JMS message
* @param session the JMS session to operate on
* @throws JMSException if thrown by JMS API methods
*/
@SuppressWarnings("unchecked")
public void onMessage(Message message, Session session) throws JMSException {
// Check whether the delegate is a MessageListener impl itself.
// In that case, the adapter will simply act as a pass-through.
Object delegate = getDelegate();
if (delegate != this) {
if (delegate instanceof SessionAwareMessageListener) {
if (session != null) {
((SessionAwareMessageListener) delegate).onMessage(message, session);
return;
}
else if (!(delegate instanceof MessageListener)) {
throw new javax.jms.IllegalStateException("MessageListenerAdapter cannot handle a " +
"SessionAwareMessageListener delegate if it hasn't been invoked with a Session itself");
}
}
if (delegate instanceof MessageListener) {
((MessageListener) delegate).onMessage(message);
return;
}
}
// Regular case: find a handler method reflectively.
Object convertedMessage = extractMessage(message);
String methodName = getListenerMethodName(message, convertedMessage);
if (methodName == null) {
throw new javax.jms.IllegalStateException("No default listener method specified: " +
"Either specify a non-null value for the 'defaultListenerMethod' property or " +
"override the 'getListenerMethodName' method.");
}
// Invoke the handler method with appropriate arguments.
Object[] listenerArguments = buildListenerArguments(convertedMessage);
Object result = invokeListenerMethod(methodName, listenerArguments);
if (result != null) {
handleResult(result, message, session);
}
else {
logger.trace("No result object given - no result to handle");
}
}