Announcement Announcement Module
Collapse
No announcement yet.
IBM MQ/ActiveMQ XML Config Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • IBM MQ/ActiveMQ XML Config

    Hi all,

    I'm desperately trying to reconfigure the samples to make use of IBM MQ q's instead of the ActiveMQ ones. Has anyone got a sample xml config for doing this please?

    many thanx

  • #2
    Is your app running inside an app server? Mine is running in WebSphere 6.1 and all the WebSphere MQ config is configured there. I then use JNDI to look the queues up

    Code:
    <jee:jndi-lookup id="Q_ADDRESS_REQUEST" jndi-name="jms/AddressRequestQueue" />
    	<jee:jndi-lookup id="Q_ADDRESS_RESPONSE" jndi-name="jms/AddressResponseQueue" />
    	 
    	 
    	<beans:bean id="connectionFactory"
    		class="org.springframework.jndi.JndiObjectFactoryBean">
    		<beans:property name="jndiName">
    			<beans:value>jms/QueueConnectionFactory</beans:value>
    		</beans:property>
    	</beans:bean>
    
    
    <jms:inbound-channel-adapter id="jmsAddressRequest"
    		destination="Q_ADDRESS_REQUEST" channel="addressRequestChannel" />
    		
    	<channel id="addressRequestChannel" />
    	
    	<outbound-channel-adapter 
            channel="addressRequestChannel" 
            ref="addressRequestMessageAdapter" 
            method="save"/>
            
    	<inbound-channel-adapter 
    		  ref="addressRequestMessageAdapter"
    		  method="removeNext" 
    		  channel="getAddressChannel">
    		  
    		<poller>
    		    <!-- The poller is configured to check for new messages every 10 seconds. -->
    		    <interval-trigger interval="10000"/>
    		    
    		    <!-- It starts a transaction before a message is read. This means that if an error occurs
    		         during processing of the message the transaction can be rolled back and the message
    		         will not be removed from the table.  
    		    -->
    		    <transactional transaction-manager="transactionManager"
    		              propagation="REQUIRED" />
    		</poller>
    	</inbound-channel-adapter>
    		
    	 
    	<chain input-channel="getAddressChannel" output-channel="addressResponseChannel">
    		<service-activator ref="addressRequestHandler" />
    	</chain>
    	
    	
    	<channel id="addressResponseChannel">
    	</channel>
    	
    	<jms:outbound-channel-adapter id="jmsAddressResponse"
    		destination="Q_ADDRESS_RESPONSE" channel="addressResponseChannel" />

    Comment


    • #3
      thanks rhart, this really helps. We will ultimately run this inside WS6.1 aswell, but for now I'm just trying to do some basic testing/prototyping without having to deploy to the appserver each time. This is our main reason, after all, for using Spring. Is there any other way?

      I managed to find this, but its not working yet, throwing CLASS NOT FOUND exceptions. So once I've sorted the classes thing out, i'm hoping it will work.

      <bean id="connectionFactory" class="org.springframework.jms.connection.CachingC onnectionFactory">
      <property name="targetConnectionFactory">
      <bean name="MQConnectionFactory" class="com.ibm.mq.jms.MQQueueConnectionFactory">
      <property name="hostName" value="10.185.21.160"/>
      <property name="port" value="1414"/>
      <property name="channel" value="S_EE"/>
      <property name="queueManager" value="QM_EE"/>
      <property name="transportType" value="0"/>
      </bean>
      </property>
      <property name="sessionCacheSize" value="10"/>
      <property name="cacheProducers" value="false"/>
      </bean>

      <bean id="jmsQueueConnectionFactory" class="org.springframework.jms.connection.UserCred entialsConnectionFactoryAdapter">
      <property name="targetConnectionFactory" ref="connectionFactory"/>
      <property name="username" value=" "/>
      <property name="password" value=" "/>
      </bean>

      Comment


      • #4
        if you're not inside a container then use MQ to publish the queues as JMS objects to a file based JNDI and then use the following

        Code:
        <beans:bean id="jndiTemplate"
        		class="org.springframework.jndi.JndiTemplate">
        		<beans:property name="environment">
        			<beans:props>
        				<beans:prop key="java.naming.factory.initial">
        					com.sun.jndi.fscontext.RefFSContextFactory
        				</beans:prop>
        				<beans:prop key="java.naming.provider.url">
        					file:/C:/Program Files/IBM/WebSphere MQ/JNDI Context
        				</beans:prop>
        			</beans:props>
        		</beans:property>
        	</beans:bean>
        
        
        <beans:bean id="connectionFactory"
        		class="org.springframework.jndi.JndiObjectFactoryBean">
        		<beans:property name="jndiName">
        			<beans:value>WMQConnectionFactory</beans:value>
        		</beans:property>
        		
        		<beans:property name="jndiTemplate">
        			<beans:ref bean="jndiTemplate" />
        		</beans:property>
        		
        	</beans:bean>
        This worked for me. Oh and use destination-name instead of destination on the jms adapters

        Comment


        • #5
          thanx rhart

          I am using Linux and the MQ Q manager is on a seperate windows server.
          I am trying to make my SI app, make use of those q's on the seperate server.

          So if I generate the file, then do you leave it on the MQ machine or bring it across to my pc?

          Comment


          • #6
            Hmmm i'm not sure. Looks like your config is headed on the right tracks though. Are you not using Rational Application Developer then? You dont need to keep re-deploying with this tool. I would argue that even a POC should be done in an environment that closely mathces what you'll be using. I quickly found out that getting the webservice endpoint working using Tomcat was easy but then getting it working in WAS wasnt! You need to set classloaders to parent_last etc

            Comment


            • #7
              True, I've had those issues to. Its not always as simple as they say, write it and if it works in Tomcat, it will work in WAS or any other appserver. NOT!

              I guess I'm really just trying to find a good way I can develop independantly of the appserver so I dont have to have this monolothic WAS chowing up my workstation as I try work. I like the fast turnaround of just clicking RUN in the IDE and my app can do its thing right away. I'm sure there must be a way to access a remote MQ, I cant accept that I need to have a whole appserver running so that I can access a MQ Q! Blah
              It seems ActiveMQ just exposes its queues via the broker URL and thats all u need. Why is it such a mission to work with MQ!!!

              Comment


              • #8
                so, basically, I can get this to work in a snap using JNDI, but then I'm tied to the appserver. So I got to run a whole freeking appserver just for JNDI reference to my Q's?
                THERE MUST BE ANOTHER WAY, PLS SOMEONE HEEEEELLLPP

                Comment


                • #9
                  hi guys, really struggling with this, would appreciate some pointers please
                  heres what I got so far.

                  <bean id="MQConnectionFactory" class="com.ibm.mq.jms.MQQueueConnectionFactory">
                  <property name="hostName" value="10.185.21.160"/>
                  <property name="port" value="1414"/>
                  <property name="channel" value="S_EE"/>
                  <property name="queueManager" value="QM_EE"/>
                  <property name="transportType" value="1"/>
                  </bean>

                  <bean id="connectionFactoryMQ" class="org.springframework.jms.connection.CachingC onnectionFactory">
                  <property name="targetConnectionFactory" ref="jmsQueueConnectionFactory" />
                  </bean>

                  <bean id="jmsQueueConnectionFactory" class="org.springframework.jms.connection.UserCred entialsConnectionFactoryAdapter">
                  <property name="targetConnectionFactory" ref="MQConnectionFactory"/>
                  <property name="username" value=" "/>
                  <property name="password" value=" "/>
                  </bean>

                  <bean id="requestQueue" class="com.ibm.mq.jms.MQQueue">
                  <constructor-arg value="dud_sync_out"/>
                  </bean>

                  <bean id="replyQueue" class="com.ibm.mq.jms.MQQueue">
                  <constructor-arg value="dud_sync_in"/>
                  </bean>



                  I keep getting the error:

                  SEVERE: org.springframework.jms.InvalidDestinationExceptio n: MQJMS2008: failed to open MQ queue ; nested exception is javax.jms.InvalidDestinationException: MQJMS2008: failed to open MQ queue ; nested exception is com.ibm.mq.MQException: MQJE001: Completion Code 2, Reason 2085

                  Would REAAAALLLYYY appreciate any pointers, I'm sooooo close to getting this right

                  Comment


                  • #10
                    ok so i've narrowed it down a little.
                    i intentionally put in fake values into the connection factory settings and SI reports the errors correctly, so I now know I am at least making a connection to the Q manager successfully. The issue seems to be with the q's themselves

                    <bean id="requestQueue" class="com.ibm.mq.jms.MQQueue">
                    <constructor-arg value="dud_sync_out" />
                    </bean>

                    <bean id="replyQueue" class="com.ibm.mq.jms.MQQueue">
                    <constructor-arg value="dud_sync_in" />
                    </bean>

                    No matter what I do with these entries, I get the same error. Perhaps a bug? Not sure yet, but it could be. I am going to look into the other parameters for the queue beans, perhaps I need to supply something more?

                    Comment


                    • #11
                      its eventually stopped throwing the exception, but I changed destination-name to destination

                      but now the jms in adapter isnt consuming messages from the MQ queue....<sigh>

                      heres my whole config so far
                      common.xml
                      ==========
                      <bean id="MQConnectionFactory" class="com.ibm.mq.jms.MQQueueConnectionFactory">
                      <property name="hostName" value="10.185.21.160"/>
                      <property name="port" value="1414"/>
                      <property name="channel" value="S_EE"/>
                      <property name="queueManager" value="QM_EE"/>
                      <property name="transportType" value="1"/>
                      </bean>

                      <!-- bean id="connectionFactoryMQ" class="org.springframework.jms.connection.CachingC onnectionFactory">
                      <property name="targetConnectionFactory" ref="jmsQueueConnectionFactory" />
                      </bean-->

                      <bean id="connectionFactoryMQ" class="org.springframework.jms.connection.UserCred entialsConnectionFactoryAdapter">
                      <property name="targetConnectionFactory" ref="MQConnectionFactory"/>
                      <property name="username" value=" "/>
                      <property name="password" value=" "/>
                      </bean>


                      <bean id="requestQueue" class="com.ibm.mq.jms.MQQueue">
                      <constructor-arg value="dud_sync_out" />
                      </bean>

                      <bean id="responseQueue" class="com.ibm.mq.jms.MQQueue">
                      <constructor-arg value="dud_sync_in" />
                      </bean>

                      --------------------------------
                      inboundChannelAdapter.xml
                      ===================


                      <jms:inbound-channel-adapter id="jmsin" destination="requestQueue" channel="jmsinToOutQChannel" connection-factory="connectionFactoryMQ"/>

                      <channel id="jmsinToOutQChannel"/>

                      <beans:bean id="outQRouter" class="org.springframework.integration.samples.jms .OutQRouter"/>
                      <router input-channel="jmsinToOutQChannel" ref="outQRouter" method="resolveOutputChannel"/>
                      <channel id="out1"/>
                      <channel id="out2"/>

                      <jms:outbound-channel-adapter id="jmsout1" connection-factory="connectionFactoryAMQ" channel="out1" destination="q.out1"/>
                      <jms:outbound-channel-adapter id="jmsout2" connection-factory="connectionFactoryAMQ" channel="out2" destination="q.out2"/>


                      why wouldnt the jsmin adapter be consuming messages from the MQ q?

                      Comment


                      • #12
                        When you tried using destination-name did you set the value to be the actual queue name in MQ? Using this method means you dont need to entries for requestQueue and responseQueue in your config.

                        Comment


                        • #13
                          Hi Rhart,

                          Both destination and detsination-name now seems to work, well, not actually consuming any messages as yet, but the connection stopped throwing exceptions. My biggest issue is now to find out why its not consuming my messages off the requestQueue

                          Anyone had similair issues?

                          Comment


                          • #14
                            still not consuming the MQ q messages from requestQueue
                            I even tried putting in its own poller

                            <jms:inbound-channel-adapter id="jmsin" destination="requestQueue" channel="jmsinToOutQChannel" connection-factory="connectionFactoryMQ">
                            <integrationoller>
                            <integration:interval-trigger interval="10" time-unit="SECONDS"/>
                            </integrationoller>
                            </jms:inbound-channel-adapter>

                            or should I be using a message driven channel adapter

                            the way i understand it, the destination is the q name from which the message is read from and then passes it along to the rest of the points?

                            Still not consuming any messages........aaarrrggghhh!


                            =========================UPDATE

                            So I switched all the connectionfactories to AMQ and it works 100%, this is def a MQ sort of related issue. I'm making a connection to the q and q manager, its just not taking the messages off.....rrrrrrrrrr, any ideas would be most welcome please. And I reckon once I got this right it will be a good example for others, who are building outside a container, with no JNDI.
                            Last edited by dudleygb; Mar 9th, 2009, 05:30 AM.

                            Comment


                            • #15
                              silly me, ok, its all working great now, I was listening to the wring queue...duh.

                              So now my next few tasks are going to try achieve transactionality with JMS. If something goes wrong, i want to rollback.

                              Any fast tips and prompts will be appreciated before I hit the docs again, maybe someone can save me some time?

                              Much appreciated!!!
                              I'm loving SI again

                              Comment

                              Working...
                              X