| Author | 
		  Message
		 | 
		
		  | fsapienza | 
		  
		    
			  
				 Posted: Fri Nov 11, 2005 8:03 am    Post subject: Migration from MQ libraries to JMS | 
				     | 
			   
			 
		   | 
		
		
		   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 | 
		  
		  	
		   | 
		
		
		    | 
		
		
		  | bower5932 | 
		  
		    
			  
				 Posted: Fri Nov 11, 2005 9:13 am    Post subject:  | 
				     | 
			   
			 
		   | 
		
		
		    Jedi Knight
 
 Joined: 27 Aug 2001 Posts: 3023 Location: Dallas, TX, USA 
  | 
		  
		    
		   | 
		
		
		  | Back to top | 
		  
		  	
		   | 
		
		
		    | 
		
		
		  | fjb_saper | 
		  
		    
			  
				 Posted: Fri Nov 11, 2005 10:08 pm    Post subject:  | 
				     | 
			   
			 
		   | 
		
		
		    Grand High Poobah
 
 Joined: 18 Nov 2003 Posts: 20768 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 | 
		  
		  	
		   | 
		
		
		    | 
		
		
		  | makattack47 | 
		  
		    
			  
				 Posted: Fri May 31, 2013 6:28 am    Post subject: link dead | 
				     | 
			   
			 
		   | 
		
		
		   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 | 
		  
		  	
		   | 
		
		
		    | 
		
		
		  | zpat | 
		  
		    
			  
				 Posted: Fri May 31, 2013 6:41 am    Post subject:  | 
				     | 
			   
			 
		   | 
		
		
		    Jedi Council
 
 Joined: 19 May 2001 Posts: 5867 Location: UK 
  | 
		  
		    
		   | 
		
		
		  | Back to top | 
		  
		  	
		   | 
		
		
		    | 
		
		
		  | Vitor | 
		  
		    
			  
				 Posted: Fri May 31, 2013 6:43 am    Post subject: Re: link dead | 
				     | 
			   
			 
		   | 
		
		
		    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 | 
		  
		  	
		   | 
		
		
		    | 
		
		
		  | makattack47 | 
		  
		    
			  
				 Posted: Fri May 31, 2013 6:46 am    Post subject:  | 
				     | 
			   
			 
		   | 
		
		
		   Newbie
 
 Joined: 31 May 2013 Posts: 4
  
  | 
		  
		    
			  
				
 
Thanks zpat - I'll check it out | 
			   
			 
		   | 
		
		
		  | Back to top | 
		  
		  	
		   | 
		
		
		    | 
		
		
		  | makattack47 | 
		  
		    
			  
				 Posted: Fri May 31, 2013 6:59 am    Post subject: Re: link dead | 
				     | 
			   
			 
		   | 
		
		
		   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 | 
		  
		  	
		   | 
		
		
		    | 
		
		
		  | Vitor | 
		  
		    
			  
				 Posted: Fri May 31, 2013 7:22 am    Post subject: Re: link dead | 
				     | 
			   
			 
		   | 
		
		
		    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 | 
		  
		  	
		   | 
		
		
		    | 
		
		
		  | makattack47 | 
		  
		    
			  
				 Posted: Fri May 31, 2013 7:27 am    Post subject: Re: link dead | 
				     | 
			   
			 
		   | 
		
		
		   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 | 
		  
		  	
		   | 
		
		
		    | 
		
		
		  | 
		    
		   |