ASG
IBM
Zystems
Cressida
Icon
Netflexity
 
  MQSeries.net
Search  Search       Tech Exchange      Education      Certifications      Library      Info Center      SupportPacs      LinkedIn  Search  Search                                                                   FAQ  FAQ   Usergroups  Usergroups
 
Register  ::  Log in Log in to check your private messages
 
RSS Feed - WebSphere MQ Support RSS Feed - Message Broker Support

MQSeries.net Forum Index » IBM MQ Java / JMS » Spring JMS WMQ Integration

Post new topic  Reply to topic
 Spring JMS WMQ Integration « View previous topic :: View next topic » 
Author Message
apatnaik14
PostPosted: Tue Aug 11, 2015 1:16 pm    Post subject: Spring JMS WMQ Integration Reply with quote

Newbie

Joined: 11 Aug 2015
Posts: 8

Hi All,

I am currently building a spring web application listener which is to interface with a main frame system running WMQ.

I have the queue and channel configurations and I am able to connect to the destination queue using the MQ APIs without any issues.

Its when I migrated the code to a Spring JMS based version, I am constantly facing the below exception:

Code:
WARNING: Setup of JMS message listener invoker failed for destination 'queue://XXXXXX/XXXXXXX.REPLY?targetClient=1' - trying to recover. Cause: MQJMS2008: failed to open MQ queue ''.; nested exception is com.ibm.mq.MQException: MQJE001: Completion Code '2', Reason '2046'.


I have googled the given error code and I do understand its an error based on the MQoptions MQRC_OPTIONS_ERROR, I just want to know which spring field it corresponds to and how can I correct it under my configuration!

Here is my spring configuration:
Code:

<bean id="mqConnectionFactory"
      class="com.ibm.mq.jms.MQQueueConnectionFactory" >
            <property name="channel" value="XXXXX" />
            <property name="hostName" value="XXXXXXXX" />
   <property name="port" value="3000" />
   <property name="queueManager" value="XXXXXX" />
   <property name="transportType" value="1" />
<property name="clientReconnectTimeout" value="2" />
<property name="clientReconnectOptions" value="0" />

<bean id="jmsQueueConnectionFactory"
      class="org.springframework.jms.connection.SingleConnectionFactory">
      <property name="targetConnectionFactory">
         <ref bean="mqConnectionFactory" />
      </property>
   </bean>

<bean id="queue" class="com.ibm.mq.jms.MQQueue" depends-on="mqConnectionFactory">
                <property name="baseQueueManagerName" value="XXX" />
                <property name="baseQueueName" value="XXXXX" />
                <property name="targetClient" value="1" />
        </bean>

<bean id="messageListener" class="com.test.testspringjmsmq.ExampleListener" />

<bean id="listenerContainer" class="org.springframework.jms.listener.DefaultMessageListenerContainer">     
 <property name="concurrentConsumers" value="5" />     
 <property name="connectionFactory" ref="jmsQueueConnectionFactory" />   
   <property name="destination" ref="queue" />   
     <property name="messageListener" ref="messageListener" />   
     </bean>


Here is my calling class:

Code:

@ContextConfiguration(locations="/spring.xml")
public class CallerClass {
   public static void main(String[] args) {
      // TODO Auto-generated method stub
      try   
      {   
         
         @SuppressWarnings("resource")
         ApplicationContext context=new ClassPathXmlApplicationContext(new String[]{"spring.xml"});
         //BeanFactory beanFactory = new XmlBeanFactory(new ClassPathResource("spring.xml"));
         BeanFactory factory=context;
         DefaultMessageListenerContainer listenerContainer = (DefaultMessageListenerContainer) factory.getBean("listenerContainer");
         listenerContainer.start();
         System.out.println("Listening for the next 10 seconds than exiting:");     
         Thread.sleep(10000);  //sleep for 10 seconds
         listenerContainer.stop();
      } 
      catch(Exception e)   
      {   
            e.printStackTrace(); 
      }   
      
   }
}


I would really appreciate some urgent assistance in this.

Thanks,
Arpan
Back to top
View user's profile Send private message
Vitor
PostPosted: Wed Aug 12, 2015 4:40 am    Post subject: Reply with quote

Grand High Poobah

Joined: 11 Nov 2005
Posts: 26093
Location: Texas, USA

It's not your JMS configuration per se - you're trying to set an option that's not allowed for the queue type you're using. The most common example is trying to open a WMQ Remote Queue definition for read (get in WMQ terms). I am not now nor have I ever been a JMS expert, but JMS often implicitly opens a queue for browse even when the code is only putting messages; on a remote queue this causes the kind of error you're seeing.
_________________
Honesty is the best policy.
Insanity is the best defence.
Back to top
View user's profile Send private message
apatnaik14
PostPosted: Wed Aug 12, 2015 12:53 pm    Post subject: Reply with quote

Newbie

Joined: 11 Aug 2015
Posts: 8

Thanks for the reply Vitor!

I would really appreciate it if you could point out the options and how to set them under the Spring JMS configuration I have above with which I can avoid this error!

I have been stuck with it for a while and cant seem to find a way out of it by manipulating any other options like transportType or clientReconnectOptions under the com.ibm.mq.jms.MQQueueConnectionFactory.

Is there any other option I can work upon? If so, where are they to be placed...in the spring config or under the caller class? Any code snippets would really help me on this!

Thanks again!
Back to top
View user's profile Send private message
fjb_saper
PostPosted: Wed Aug 12, 2015 2:14 pm    Post subject: Reply with quote

Grand High Poobah

Joined: 18 Nov 2003
Posts: 20696
Location: LI,NY

apatnaik14 wrote:
Thanks for the reply Vitor!

I would really appreciate it if you could point out the options and how to set them under the Spring JMS configuration I have above with which I can avoid this error!

I have been stuck with it for a while and cant seem to find a way out of it by manipulating any other options like transportType or clientReconnectOptions under the com.ibm.mq.jms.MQQueueConnectionFactory.

Is there any other option I can work upon? If so, where are they to be placed...in the spring config or under the caller class? Any code snippets would really help me on this!

Thanks again!


Make sure there is no message consumer of any kind attached to the destination.
_________________
MQ & Broker admin
Back to top
View user's profile Send private message Send e-mail
apatnaik14
PostPosted: Wed Aug 12, 2015 2:35 pm    Post subject: Reply with quote

Newbie

Joined: 11 Aug 2015
Posts: 8

fjb_saper wrote:
apatnaik14 wrote:
Thanks for the reply Vitor!

I would really appreciate it if you could point out the options and how to set them under the Spring JMS configuration I have above with which I can avoid this error!

I have been stuck with it for a while and cant seem to find a way out of it by manipulating any other options like transportType or clientReconnectOptions under the com.ibm.mq.jms.MQQueueConnectionFactory.

Is there any other option I can work upon? If so, where are they to be placed...in the spring config or under the caller class? Any code snippets would really help me on this!

Thanks again!


Make sure there is no message consumer of any kind attached to the destination.


So basically what I am developing is a JMS listener which will eventually listen to a given Mainframe reply queue on a remote mainframe system.

There will be a process associated with picking up the messages and putting a response in the REPLY queue at the mainframe side, but thats not dependent on my JMS listener. Also, my listener process is supposed to be the only designated process to be consuming the replies in the REPLY queue. There are no other processes running which pick up the messages as of now. So I am a little confused on the message consumer part you have mentioned above.

Also I have been trying the below modifications under the calling class

Code:

MQQueueConnectionFactory mqConnectionFactory = (MQQueueConnectionFactory) factory.getBean("mqConnectionFactory");
mqConnectionFactory.setMQConnectionOptions(0);


Doesn't seem to change the exception though.

Regards,
A
Back to top
View user's profile Send private message
fjb_saper
PostPosted: Wed Aug 12, 2015 7:47 pm    Post subject: Reply with quote

Grand High Poobah

Joined: 18 Nov 2003
Posts: 20696
Location: LI,NY

So you're attaching to a remote mainframe. What is the version of MQ on the mainframe?

Depending on the version does it have the Client Attachment Facility (CAF)?
If not that might be one of your problems.

Usually it is better if you have a distributed qmgr in your estate to have your server attach to that one and have it handle the communications to the mainframe's qmgr. (less CPU, MIPS, CHIN, ...)

Have fun
_________________
MQ & Broker admin
Back to top
View user's profile Send private message Send e-mail
apatnaik14
PostPosted: Thu Aug 13, 2015 8:58 am    Post subject: Reply with quote

Newbie

Joined: 11 Aug 2015
Posts: 8

fjb_saper wrote:
So you're attaching to a remote mainframe. What is the version of MQ on the mainframe?

Depending on the version does it have the Client Attachment Facility (CAF)?
If not that might be one of your problems.

Usually it is better if you have a distributed qmgr in your estate to have your server attach to that one and have it handle the communications to the mainframe's qmgr. (less CPU, MIPS, CHIN, ...)

Have fun


Thanks for your response fjb_saper!

We have the MQ V6 running at the Mainframe side. My question remains that the error message suggests an issue with the options parameters in opening the connection, similar to what we can see in using the normal WMQ APIs. Would the destination systems configuration put an impact on that?

I have a running application right now, which is able to connect and put messages into the request queue and fetch replies from the reply queue. Its a standalone Java coded program with WMQ JARs directly referenced. So would the use of JMS change so many things??

I am trying to understand should moving to JMS be similar considering JMS is inherently using my WMQ JARs for the bridge.

Regards,
Back to top
View user's profile Send private message
Vitor
PostPosted: Thu Aug 13, 2015 9:27 am    Post subject: Reply with quote

Grand High Poobah

Joined: 11 Nov 2005
Posts: 26093
Location: Texas, USA

apatnaik14 wrote:
So would the use of JMS change so many things??




apatnaik14 wrote:
I am trying to understand should moving to JMS be similar considering JMS is inherently using my WMQ JARs for the bridge.


JMS is a separate and distinct framework - literally the Java Message Standard - that has little in common with MQ aside from the basic function. It has different methods and classes that behave differently. While you're quite correct that, under the covers, it's using the same MQ software by your own admission you're using different jar files containing different code. The native jars expose the IBM methods to a Java app, the JMS jars expose JMS methods to a Java app and the simple fact is that the 2 standards are not identical.

More simply, the IBM supplied JMS jars are exactly that - they allow MQ to act as a JMS provider. Not as an IBM queue manager.
_________________
Honesty is the best policy.
Insanity is the best defence.
Back to top
View user's profile Send private message
apatnaik14
PostPosted: Thu Aug 13, 2015 9:48 am    Post subject: Reply with quote

Newbie

Joined: 11 Aug 2015
Posts: 8

Vitor wrote:
apatnaik14 wrote:
So would the use of JMS change so many things??




apatnaik14 wrote:
I am trying to understand should moving to JMS be similar considering JMS is inherently using my WMQ JARs for the bridge.


JMS is a separate and distinct framework - literally the Java Message Standard - that has little in common with MQ aside from the basic function. It has different methods and classes that behave differently. While you're quite correct that, under the covers, it's using the same MQ software by your own admission you're using different jar files containing different code. The native jars expose the IBM methods to a Java app, the JMS jars expose JMS methods to a Java app and the simple fact is that the 2 standards are not identical.

More simply, the IBM supplied JMS jars are exactly that - they allow MQ to act as a JMS provider. Not as an IBM queue manager.


Thanks for the response Vitor!

I do understand JMS changes things, I didnt expect it would go down to the destination system as well

So how do I work around this now? I do not have the option of upgrading or changing my Mainframe system. And I am trying to find a solution which will not require the install of WMQ on my application servers, if possible. Also, I have an application server of JBOSS 6.2 installed, and HornetQ attached to the same. Would using a intermediary like HornetQ solve things?

Regards,
A
Back to top
View user's profile Send private message
Vitor
PostPosted: Thu Aug 13, 2015 10:14 am    Post subject: Reply with quote

Grand High Poobah

Joined: 11 Nov 2005
Posts: 26093
Location: Texas, USA

apatnaik14 wrote:
I have an application server of JBOSS 6.2 installed, and HornetQ attached to the same. Would using a intermediary like HornetQ solve things?


You need someone who knows a lot more about JMS than I do.
_________________
Honesty is the best policy.
Insanity is the best defence.
Back to top
View user's profile Send private message
mqjeff
PostPosted: Thu Aug 13, 2015 10:18 am    Post subject: Reply with quote

Grand Master

Joined: 25 Jun 2008
Posts: 17447

JMS does do things like inquire on queues and etc. where normal MQ Java classes don't, unless I'm remembering wrong.

This might play higgledy-piggledy with the mainframe objects and their permissions.

Using any other kind of JMS provider between your JMS app and MQ means that your other JMS provider (HornetQ, in your example) will need to be able to *bridge* to MQ. Most of them don't do that...

You're better off sitting down with your mainframe MQ team and reviewing the objects you're trying to talk to from JMS and make sure that you're actually connecting to the right qmgr and etc. etc. etc.
Back to top
View user's profile Send private message
apatnaik14
PostPosted: Thu Aug 13, 2015 11:05 am    Post subject: Reply with quote

Newbie

Joined: 11 Aug 2015
Posts: 8

mqjeff wrote:
JMS does do things like inquire on queues and etc. where normal MQ Java classes don't, unless I'm remembering wrong.

This might play higgledy-piggledy with the mainframe objects and their permissions.

Using any other kind of JMS provider between your JMS app and MQ means that your other JMS provider (HornetQ, in your example) will need to be able to *bridge* to MQ. Most of them don't do that...

You're better off sitting down with your mainframe MQ team and reviewing the objects you're trying to talk to from JMS and make sure that you're actually connecting to the right qmgr and etc. etc. etc.


Well I have had a discussion with my Mainframe team on this, and since my other WMQ based app is able to connect to the same QM, me and my Mainframe team are stuck! Is there any way I can set openOptions in the JMS code like we can in WMQ based code like below:


Code:

int openOptions = MQC.MQOO_INQUIRE + MQC.MQOO_FAIL_IF_QUIESCING + MQC.MQOO_INPUT_SHARED;
mqOutputQueue = mqQueueManager.accessQueue(queueName, openOptions, null, null, null);


The above code works and I am able to connect to the same QM, its just that its not JMS based.

Regards,
A
Back to top
View user's profile Send private message
fjb_saper
PostPosted: Thu Aug 13, 2015 11:54 am    Post subject: Reply with quote

Grand High Poobah

Joined: 18 Nov 2003
Posts: 20696
Location: LI,NY

No you cannot.
As the MF is at MQ V6 (OBSOLETE AND OUT OF SUPPORT) please check that there is a CAF (client attachment Facility) ...

Beyond that you need +inq as additional permission on every object.
The rest is governed by the JMS setup and code.

If there is no consumer ever set up for a queue you don't need get or browse for the queue... You may want and try it out first on a distributed qmgr.
After that there is little to no difference going against the mainframe but for the setup of your connection factory...

Have fun
_________________
MQ & Broker admin
Back to top
View user's profile Send private message Send e-mail
apatnaik14
PostPosted: Thu Aug 13, 2015 2:41 pm    Post subject: Reply with quote

Newbie

Joined: 11 Aug 2015
Posts: 8

fjb_saper wrote:
No you cannot.
As the MF is at MQ V6 (OBSOLETE AND OUT OF SUPPORT) please check that there is a CAF (client attachment Facility) ...

Beyond that you need +inq as additional permission on every object.
The rest is governed by the JMS setup and code.

If there is no consumer ever set up for a queue you don't need get or browse for the queue... You may want and try it out first on a distributed qmgr.
After that there is little to no difference going against the mainframe but for the setup of your connection factory...

Have fun


Thanks fjb_saper! I guess there is no way to completely convert my WMQ code to JMS without any serious alterations.

Currently adding permissions to those objects under the Mainframe side is a difficulty for me. But is there any way I can take it up by using an additional queue manager on my distributed server, which in turn routes the messages to the QM on the Mainframe side?

Also, if thats an option, can you please point me to some resources on the below topics:

1. How to setup WMQ for a JBOSS 6.2 application server.
2. How to establish the connection between my distributed QM to the Mainframe QM?

I apologize I am still learning on MQs so the above maybe some fundamental questions, to which I am unable to locate definitive answers.


Regards,
A
Back to top
View user's profile Send private message
fjb_saper
PostPosted: Thu Aug 13, 2015 7:26 pm    Post subject: Reply with quote

Grand High Poobah

Joined: 18 Nov 2003
Posts: 20696
Location: LI,NY

Look up the multi-hop concept in the Knowledge Center
http://www-01.ibm.com/support/knowledgecenter/search/multi-hop?scope=SSFKSJ_8.0.0
_________________
MQ & Broker admin
Back to top
View user's profile Send private message Send e-mail
Display posts from previous:   
Post new topic  Reply to topic Page 1 of 1

MQSeries.net Forum Index » IBM MQ Java / JMS » Spring JMS WMQ Integration
Jump to:  



You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
Protected by Anti-Spam ACP
 
 


Theme by Dustin Baccetti
Powered by phpBB © 2001, 2002 phpBB Group

Copyright © MQSeries.net. All rights reserved.