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 » Reading JMSReply to Queue

Post new topic  Reply to topic
 Reading JMSReply to Queue « View previous topic :: View next topic » 
Author Message
robiijohn
PostPosted: Wed Aug 13, 2008 3:46 am    Post subject: Reading JMSReply to Queue Reply with quote

Newbie

Joined: 13 Aug 2008
Posts: 7

Hi All,

I am facing one problem in assigning ReplytoQueue value for the MQ Message.

I am using MDB Listener For receiving the message..
I just wanted to read the JMSReplyTo and put it into the replytoQueue field of the MQ message...
Currently i am doing
mqMsg.replyToQueueName = jmsMsg.getJMSReplyTo().toString();

But the problem is jmsMsg.getJMSReplyTo().toString() is giving me
something like this "queue:\\\QueueName"
i dont know why it is prefixing with "queue:\\\"
Back to top
View user's profile Send private message
fjb_saper
PostPosted: Wed Aug 13, 2008 3:56 am    Post subject: Re: Reading JMSReply to Queue Reply with quote

Grand High Poobah

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

robiijohn wrote:
Hi All,

I am facing one problem in assigning ReplytoQueue value for the MQ Message.

I am using MDB Listener For receiving the message..
I just wanted to read the JMSReplyTo and put it into the replytoQueue field of the MQ message...
Currently i am doing
mqMsg.replyToQueueName = jmsMsg.getJMSReplyTo().toString();

But the problem is jmsMsg.getJMSReplyTo().toString() is giving me
something like this "queue:\\\QueueName"
i dont know why it is prefixing with "queue:\\\"

Your code should be:
Destination replyto = jmsMsg.getJMSReplyTo();
and then you should use something like
sender.send(jmsMsg, replyto);

It looks like you are mixing JMS and regular MQ.
You should avoid doing that. If it cannot be avoided you should look at following piece of code:
Destination myreplyto = jmsMsg.getJMSReplyTo();
If (myreplyto instanceof Queue) {
MQQueue myqueue = (MQQueue)Destination;
String RTqmgr = myqueue.getBaseQmgr();
String RTq = myqueue.getBaseQueue();
}

Or something like it. Watch the String declarations, they should have been done way before...
The Destination gives you the URI form : "queue://qmgr/qname?att1=val1&attn=valn"

Enjoy
_________________
MQ & Broker admin
Back to top
View user's profile Send private message Send e-mail
robiijohn
PostPosted: Wed Aug 13, 2008 4:45 am    Post subject: Reply with quote

Newbie

Joined: 13 Aug 2008
Posts: 7

Thanks for your reply.....

But now i am getting the type conversion error
com.ibm.mq.jms.MQQueue incompatible with com.ibm.mq.MQQueue, Status : Red

Can you please suggest ....
i am putting the portion of my code below:

q_Mgr = new MQQueueManager(props.getProperty("QUEUE_MANAGER").trim());
queue = q_Mgr.accessQueue(queueName, MQC.MQOO_OUTPUT);
//byte[] bytMessageID = msg.getJMSMessageID().getBytes();
mqMsg.correlationId = msg.getJMSMessageID().getBytes("UTF8"); //bytMessageID 8859_1;
mqMsg.report = MQC.MQRO_PASS_CORREL_ID;
mqMsg.replyToQueueManagerName= props.getProperty("QUEUE_MANAGER").trim();
Destination replyTo=msg.getJMSReplyTo();
MQQueue myqueue = (MQQueue)replyTo;
String RTq = myqueue.name;
mqMsg.replyToQueueName=RTq;
//mqMsg.replyToQueueName = "UIST.ONL.RS.SVRG1.BW.EWSS.QM_IPBZ3";//msg.getJMSReplyTo().toString();
logWriter.log(Level.SEVERE,"Reply to queue : " + msg.getJMSReplyTo());

mqMsg.messageType = MQC.MQMT_REQUEST;
//mqMsg.writeUTF(MQC.MQFMT_STRING);
mqMsg.characterSet = 1208;

mqMsg.writeString(txtMsg.getText().toString());
queue.put(mqMsg);
q_Mgr.commit();
queue.close();
Back to top
View user's profile Send private message
manicminer
PostPosted: Wed Aug 13, 2008 5:20 am    Post subject: Reply with quote

Disciple

Joined: 11 Jul 2007
Posts: 177

robiijohn wrote:
Thanks for your reply.....

But now i am getting the type conversion error
com.ibm.mq.jms.MQQueue incompatible with com.ibm.mq.MQQueue, Status : Red


Don't mix and match objects, you com.ibm.mq.MQQueue and com.ibm.mq.jms.MQQueue are 2 different objects, don't try and use one with the other, you probably have an incorrect import in your code.
Back to top
View user's profile Send private message
fjb_saper
PostPosted: Wed Aug 13, 2008 2:40 pm    Post subject: Reply with quote

Grand High Poobah

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

robiijohn wrote:
Thanks for your reply.....

But now i am getting the type conversion error
com.ibm.mq.jms.MQQueue incompatible with com.ibm.mq.MQQueue, Status : Red

That's one error you were meant to get.
The snippet I wrote was geared towards JMS so you would have to use com.ibm.mq.jms.MQQueue to extract the information (replyto qmgr, replyto queue) and set it to a com.ibm.mq.MQQueue that you would want to open...

Like I said mix and match at your own risks. I would just stay with JMS, but then that's just me....

Also look at your code.... despite being told that the correlID is a byte[24] field you are treating it as a text field! (ccsid conversion??) This is so wrong on so many levels... Not all values of a byte map to a char...
Look up the anonymous indentifier pattern with Google.
A perfect implementation would be a best of breed request/reply with MQ.
See the examples in base and JMS (sample code at top of page link).


Also if you need the message body in a particular CCSID set this CCSID on the QCF and do a receive of a TextMessage....(JMS).

Enjoy
_________________
MQ & Broker admin
Back to top
View user's profile Send private message Send e-mail
robiijohn
PostPosted: Wed Aug 13, 2008 6:12 pm    Post subject: Reply with quote

Newbie

Joined: 13 Aug 2008
Posts: 7

Hi , Thanks for your reply....

i wantedto put the message id of the incoming message into the correlationId field of the mq message. as you know i am getting the incoming message as jms.... so how can i solve this problem any advice please...
Back to top
View user's profile Send private message
fjb_saper
PostPosted: Thu Aug 14, 2008 1:30 pm    Post subject: Reply with quote

Grand High Poobah

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

robiijohn wrote:
Hi , Thanks for your reply....

i wantedto put the message id of the incoming message into the correlationId field of the mq message. as you know i am getting the incoming message as jms.... so how can i solve this problem any advice please...


This is going to be sooo easy. Be creative.
retrieve the message id , set the correlation id, retrieve the correlID as bytes.
Set the bytes:

JMS part
msgID = inmsg.getJMSMessageID();
dummymsg.setJMSCorrelationID() = msgID;
byte[24] mqmsgid = dummymsg.getCorrelationIDAsBytes();

Now you can use the bytearray to set the correlID on the mq message...

However you should:
  • first check the JMSCorrelationID for "ID:" + String.replicate("0",48 );
    (initial value or something like JMSC.MQID_NONE or MQSC.MQID_NONE...
  • If this is the value go ahead and move the msgid to the correlId
  • if the correlID has already a non initial value, it should be "passthrough"


Enjoy
_________________
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 » Reading JMSReply to Queue
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.