Results 1 to 4 of 4

Thread: Need help with asynchronous JMS reception

  1. #1
    Join Date
    Jan 2010
    Posts
    3

    Default 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>

  2. #2
    Join Date
    Jan 2008
    Location
    San Diego
    Posts
    780

    Default

    You're using a TOPIC...you are going to receive the message more than once if you have multiple topic subscribers. They'll each receive it once.

  3. #3
    Join Date
    Jan 2010
    Posts
    3

    Default

    Dear Chudak,

    Thanks for your reply. Actually I have only one topic subscriber which is the MDP. This single subscriber recieves each message being sent twice. However, if I replace the MDP with an MDB everything works fine and I recieve a single message once only not twice as the MDP does.

    Quote Originally Posted by chudak View Post
    You're using a TOPIC...you are going to receive the message more than once if you have multiple topic subscribers. They'll each receive it once.

  4. #4
    Join Date
    Jan 2008
    Location
    San Diego
    Posts
    780

    Default

    Make sure that you aren't configuring concurrent consumers in your single MDP. This will also cause the message to be received more than once.

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •