Tags

,

links:
http://static.springsource.org/spring/docs/3.0.x/reference/jms.html (“Receiving a message” section)

summary:
– 3 methods: 1) std jms intf, 2) spring msg intf, 3) no intf but need spring cfg

—- method 1: javax.jms.MessageListener
– also need to specify container and container class=”org.springframework.jms.listener.DefaultMessageListenerContainer”

<!-- this is the Message Driven POJO (MDP) -->
<bean id="messageListener" class="jmsexample.ExampleListener" />

<!-- and this is the message listener container -->
<bean id="jmsContainer" class="org.springframework.jms.listener.DefaultMessageListenerContainer">
    <property name="connectionFactory" ref="connectionFactory"/>
    <property name="destination" ref="destination"/>
    <property name="messageListener" ref="messageListener" />
</bean>

——– method 2: SessionAwareMessageListener
– a Spring-specific interface similar to JMS MessageListener
– but also provides the message handling method with access to the JMS Session from which the Message was received

—— method 3: MessageListenerAdapter
– a real MDP truly support POJO according to Spring

<!-- this is the Message Driven POJO (MDP) -->
<bean id="messageListener" class="org.springframework.jms.listener.adapter.MessageListenerAdapter">
    <constructor-arg>
        <bean class="jmsexample.DefaultMessageDelegate"/>
    </constructor-arg>
</bean>

<!-- and this is the message listener container... -->
<bean id="jmsContainer" class="org.springframework.jms.listener.DefaultMessageListenerContainer">
    <property name="connectionFactory" ref="connectionFactory"/>
    <property name="destination" ref="destination"/>
    <property name="messageListener" ref="messageListener" />
</bean>
Advertisements