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 » Migration from MQ libraries to JMS

Post new topic  Reply to topic
 Migration from MQ libraries to JMS « View previous topic :: View next topic » 
Author Message
fsapienza
PostPosted: Fri Nov 11, 2005 8:03 am    Post subject: Migration from MQ libraries to JMS Reply with quote

Novice

Joined: 11 Nov 2005
Posts: 10

Hi all!

I have to migrate a Java class that use MQ libraries to JMS, _without_ using any non-Sun libraries. I'm a JMS newbie.

Old _working_ code is:

Code:

      MQQueueManager oQm=null;

      MQQueue oQIn=null;
      MQPutMessageOptions oPmo=null;
      MQMessage oMsgIn=null;
      int iOpenOptionsIn;

      MQQueue oQOut=null;
      MQGetMessageOptions oGmo=null;
      MQMessage oMsgOut=null;
      int iOpenOptionsOut;

      String sHostOutputString = "";

        oQm = new MQQueueManager(getSendQueueManagerName());
        iOpenOptionsIn = MQC.MQOO_OUTPUT | MQC.MQOO_INQUIRE | MQC.MQOO_SET_IDENTITY_CONTEXT;
        oQIn = oQm.accessQueue(getInQueueName(),iOpenOptionsIn);
        oPmo = new MQPutMessageOptions();
        oPmo.options = MQC.MQPMO_SET_IDENTITY_CONTEXT | MQC.MQPMO_FAIL_IF_QUIESCING;
        oMsgIn = new MQMessage();
        oMsgIn.messageType = MQC.MQMT_DATAGRAM;
        oMsgIn.format = MQC.MQFMT_STRING; // "MQSTR"
        oMsgIn.replyToQueueManagerName = getReceiveQueueMgrName();
   oMsgIn.characterSet = 923;
   oMsgIn.replyToQueueName = "returnQueue";
        oQIn.put(oMsgIn,oPmo);
        oQm.disconnect();

        oMsgOut = new MQMessage();
        oMsgOut.messageId = oMsgIn.messageId; /
        oMsgOut.format =  MQC.MQFMT_STRING; // "MQSTR"      
   oMsgOut.characterSet = 923;
        oGmo = new MQGetMessageOptions();
        oGmo.options = MQC.MQGMO_WAIT | MQC.MQGMO_FAIL_IF_QUIESCING;
        iOpenOptionsOut = MQC.MQOO_INQUIRE | MQC.MQOO_INPUT_AS_Q_DEF;
        oQOut = oQm.accessQueue(getOutQueueName(),
                                  iOpenOptionsOut); //getOutQueueName returns the name of the queue
        oQOut.get(oMsgOut,oGmo);
       sHostOutputString = oMsgOut.readString(oMsgOut.getTotalMessageLength());
        oQOut.close();
        oQm.disconnect();


I tried to migrate to a class with this code:
Code:

   Context context = new InitialContext ();
   queueConnectionFactory = (QueueConnectionFactory) context.lookup("QCF");
        queue = (Queue) context.lookup("Q");
        queueConnection = queueConnectionFactory.createQueueConnection();
        queueSession = queueConnection.createQueueSession(false, javax.jms.Session.AUTO_ACKNOWLEDGE);
   queueConnection.start();
   TextMessage message = queueSession.createTextMessage();
   message.setText(sHostInputString);
   QueueSender requestSender = queueSession.createSender(queue);
   Queue replyQueue = queueSession.createQueue("QueueName");
        QueueReceiver replyReceiver = queueSession.createReceiver(replyQueue);
message.setJMSReplyTo(replyQueue);
              message.setJMSDeliveryMode(DeliveryMode.PERSISTENT);
requestSender.send(message);
Message responseMessageAsMessage = replyReceiver.receive(20000);
TextMessage responseMessage = (TextMessage) responseMessageAsMessage;
sHostOutputString = responseMessage.getText();


All seems to work until send operation. But I receive no response. I think that header message is not set correctly.

How can I "translate" operation like
Code:

iOpenOptionsIn = MQC.MQOO_OUTPUT | MQC.MQOO_INQUIRE | MQC.MQOO_SET_IDENTITY_CONTEXT;
...
oPmo.options = MQC.MQPMO_SET_IDENTITY_CONTEXT | MQC.MQPMO_FAIL_IF_QUIESCING;


in a "JMS-mode" without using com.ibm.mq package???

Thanks a lot, it is very important and also urgent for me

Ciao[/code]
Back to top
View user's profile Send private message
bower5932
PostPosted: Fri Nov 11, 2005 9:13 am    Post subject: Reply with quote

Jedi Knight

Joined: 27 Aug 2001
Posts: 3023
Location: Dallas, TX, USA

I haven't looked at your code, but there are versions of programs at:

http://www.developer.ibm.com/isv/tech/sampmq.html

that are written in java and jms. You might want to look at one of them.
Back to top
View user's profile Send private message Send e-mail Visit poster's website AIM Address Yahoo Messenger
fjb_saper
PostPosted: Fri Nov 11, 2005 10:08 pm    Post subject: Reply with quote

Grand High Poobah

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

As to your question : You don't.
There is no setting of options as the JMS classes will do that for you.

Enjoy
Back to top
View user's profile Send private message Send e-mail
makattack47
PostPosted: Fri May 31, 2013 6:28 am    Post subject: link dead Reply with quote

Newbie

Joined: 31 May 2013
Posts: 4

Hi. I have the same query..
Thanks for the link... but it seems to be dead.
Please advise further.
Back to top
View user's profile Send private message
zpat
PostPosted: Fri May 31, 2013 6:41 am    Post subject: Reply with quote

Jedi Council

Joined: 19 May 2001
Posts: 5866
Location: UK

Some samples here

http://www.capitalware.biz/pc_win_code_java.html#jmscode
Back to top
View user's profile Send private message
Vitor
PostPosted: Fri May 31, 2013 6:43 am    Post subject: Re: link dead Reply with quote

Grand High Poobah

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

makattack47 wrote:
Thanks for the link... but it seems to be dead.


After 8 years? I'm not surprised. Mr Google can find you fresher versions.
_________________
Honesty is the best policy.
Insanity is the best defence.
Back to top
View user's profile Send private message
makattack47
PostPosted: Fri May 31, 2013 6:46 am    Post subject: Reply with quote

Newbie

Joined: 31 May 2013
Posts: 4

zpat wrote:
Some samples here

http://www.capitalware.biz/pc_win_code_java.html#jmscode

Thanks zpat - I'll check it out
Back to top
View user's profile Send private message
makattack47
PostPosted: Fri May 31, 2013 6:59 am    Post subject: Re: link dead Reply with quote

Newbie

Joined: 31 May 2013
Posts: 4

Vitor wrote:
makattack47 wrote:
Thanks for the link... but it seems to be dead.


After 8 years? I'm not surprised. Mr Google can find you fresher versions.

Mr. Google found me this thread
Back to top
View user's profile Send private message
Vitor
PostPosted: Fri May 31, 2013 7:22 am    Post subject: Re: link dead Reply with quote

Grand High Poobah

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

makattack47 wrote:
Vitor wrote:
makattack47 wrote:
Thanks for the link... but it seems to be dead.


After 8 years? I'm not surprised. Mr Google can find you fresher versions.

Mr. Google found me this thread


He should have found others. You don't get search engines the way you used to when I was a lad.....
_________________
Honesty is the best policy.
Insanity is the best defence.
Back to top
View user's profile Send private message
makattack47
PostPosted: Fri May 31, 2013 7:27 am    Post subject: Re: link dead Reply with quote

Newbie

Joined: 31 May 2013
Posts: 4

Vitor wrote:

He should have found others. You don't get search engines the way you used to when I was a lad.....

He did.. not very helpful ones tho. ..this one was the closest match so I hit Reply
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic  Reply to topic Page 1 of 1

MQSeries.net Forum Index » IBM MQ Java / JMS » Migration from MQ libraries to JMS
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.