Search in sources :

Example 1 with SessionAwareMessageListener

use of org.springframework.jms.listener.SessionAwareMessageListener in project spring-framework by spring-projects.

the class JmsListenerContainerFactoryIntegrationTests method invokeListener.

@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);
    }
}
Also used : DefaultMessageListenerContainer(org.springframework.jms.listener.DefaultMessageListenerContainer) SessionAwareMessageListener(org.springframework.jms.listener.SessionAwareMessageListener) SessionAwareMessageListener(org.springframework.jms.listener.SessionAwareMessageListener) MessageListener(javax.jms.MessageListener) Session(javax.jms.Session)

Aggregations

MessageListener (javax.jms.MessageListener)1 Session (javax.jms.Session)1 DefaultMessageListenerContainer (org.springframework.jms.listener.DefaultMessageListenerContainer)1 SessionAwareMessageListener (org.springframework.jms.listener.SessionAwareMessageListener)1