Need help with asynchronous JMS reception
I'm new to Spring and I have a problem with Message-Driven Pojos.
I send a single message through the message sender; however I receive the message twice at the MDP end.
When I try the same configuration, while using a Message-Driven Bean, it works fine and I receive a single message.
My configuration is as follows:
Spring v. 2.5
Websphere Application Sever v. 6.1
Messaging provider: Websphere Application Sever internal Service Integration Bus
JMS Domain: Publish/Subscribe
My configuration XML is below:
Any help is really appreciated
Code:
<bean id="jndiTemplate" class="org.springframework.jndi.JndiTemplate">
<property name="environment">
<props>
<prop key="java.naming.factory.initial">com.ibm.websphere.naming.WsnInitialContextFactory</prop>
<prop key="java.naming.provider.url">iiop://localhost:10004/</prop>
</props>
</property>
</bean>
<!-- JMS Topic Connection Factory -->
<bean id="internalJmsTopicConnectionFactory"
class="org.springframework.jndi.JndiObjectFactoryBean">
<property name="jndiTemplate">
<ref bean="jndiTemplate"/>
</property>
<property name="jndiName">
<value>jms/deftconfac</value>
</property>
</bean>
<!-- Spring JMS Topic Connection Factory -->
<bean id="jmsTopicConnectionFactory"
class="org.springframework.jms.connection.SingleConnectionFactory">
<property name="targetConnectionFactory">
<ref bean="internalJmsTopicConnectionFactory"/>
</property>
</bean>
<!-- JMS Destination Resolver -->
<bean id="jmsDestinationResolver"
class="org.springframework.jms.support.destination.JndiDestinationResolver">
<property name="jndiTemplate">
<ref bean="jndiTemplate"/>
</property>
<property name="cache">
<value>true</value>
</property>
</bean>
<!-- JMS Topic Template -->
<bean id="jmsTopicTemplate" class="org.springframework.jms.core.JmsTemplate">
<property name="connectionFactory">
<ref bean="jmsTopicConnectionFactory"/>
</property>
<property name="destinationResolver">
<ref bean="jmsDestinationResolver"/>
</property>
</bean>
<bean id="jmsSender" class="com.ejada.ecorp.jms.JmsSender">
<property name="jmsTemplate">
<ref bean="jmsTopicTemplate"/>
</property>
<property name ="destination">
<ref bean = "theTopic"/>
</property>
</bean>
<!-- this is the Message Driven POJO (MDP) -->
<bean id="messageListener" class="com.ejada.ecorp.jms.JmsMDP" />
<!-- JCA Support, enabling the usage of SIB -->
<bean class="org.springframework.jms.listener.endpoint.JmsMessageEndpointManager">
<property name="resourceAdapter" ref="wasSIBJMSResourceAdapter"/>
<property name="activationSpec">
<bean class="com.ibm.ws.sib.api.jmsra.impl.JmsJcaActivationSpecImpl">
<property name="destination" ref="theTopic"/>
<property name="destinationType" value="javax.jms.Topic"/>
<property name="busName" value="TheSIB"/>
</bean>
</property>
<property name="messageListener" ref="messageListener"/>
</bean>
<jee:jndi-lookup id="theTopic" jndi-name="jms/deft"/>
<bean id="wasDefaultWorkManager" class="org.springframework.scheduling.commonj.WorkManagerTaskExecutor">
<property name="workManagerName" value="wm/default" />
</bean>
<bean id="wasSIBJMSResourceAdapter" class="org.springframework.jca.support.ResourceAdapterFactoryBean">
<property name="resourceAdapter">
<bean class="com.ibm.ws.sib.api.jmsra.impl.JmsJcaResourceAdapterImpl"/>
</property>
<property name="workManager">
<bean class="org.springframework.jca.work.SimpleTaskWorkManager">
<property name="asyncTaskExecutor" ref="wasDefaultWorkManager" />
</bean>
</property>
</bean>