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 » Problem In MQ MessageID

Post new topic  Reply to topic Goto page Previous  1, 2, 3, 4  Next
 Problem In MQ MessageID « View previous topic :: View next topic » 
Author Message
atheek
PostPosted: Tue Nov 18, 2008 3:28 am    Post subject: Reply with quote

Partisan

Joined: 01 Jun 2006
Posts: 327
Location: Sydney

So you have taken the java api in mdb path? Hope you have specified MQC.MQPMO_SYNCPOINT in the Put Message Options.

The message will be available to any receiver appln only after the syncpoint is committed.Syncpoints are committed when the appln call MQQueueManager.commit() or disconect from the queue manager. In your case you need to call MQQueueManager.commit() within the onMessage() method.

A point to note - here your mqput could be a totally different transaction. As a result it might not be in scope of the global transaction which involves the read from the input queue. Hence if the transaction involving the mqput commits, but the global transaction fails, message will be rolled back to the input queue and redelivered to the mdb. This could result in duplicate messages.
Back to top
View user's profile Send private message
meetgaurav
PostPosted: Tue Nov 18, 2008 4:04 am    Post subject: Reply with quote

Voyager

Joined: 08 Sep 2008
Posts: 94

HI Atheek / FJB,

Thanks for the reply.. I selected JAVA API for another remote system. I have to test the XA functionality now.

I have 2 more queries
1.
--------------------------------------------------------
MQMessage msg = new MQMessage();
msg.writeString(msgContent);
--------------------------------------------------------
The above lines is not giving the message in instance of textmessage. Its giving as bytes message.

2.
--------------------------------------------------------
msg.messageId = msgId.getBytes();
msg.correlationId = correlId.getBytes();
--------------------------------------------------------

Am just assigning the msgid and correld as byte array.. But this getBytes() method is doing some encoding. Again the msg id will not remain the same what I sent.

Please advice Atheek and FJB
Back to top
View user's profile Send private message
fjb_saper
PostPosted: Tue Nov 18, 2008 4:05 am    Post subject: Reply with quote

Grand High Poobah

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

fjb_saper wrote:
And finally if you really need to jump through hoops here is an elegant way:
Have JMS set the messageid to correlation Id and write the message to a local queue. You can have this queue triggered to pick up the message in java base or C etc... and have this little utility move the correlationId to the messageId and clear the correlation id and forward the message on to it's final destination... so full JMS in the J2EE environment and no JMS at all in the utility.... Have fun

_________________
MQ & Broker admin
Back to top
View user's profile Send private message Send e-mail
meetgaurav
PostPosted: Tue Nov 18, 2008 4:11 am    Post subject: Reply with quote

Voyager

Joined: 08 Sep 2008
Posts: 94

Great Atheek

This works fine..

I created MQGR in create() and commit in Onmessage() and disocnnect in remove().

The MDB behaviour is same even after I commented the below line.. What is the use of this.

pmo.options = MQC.MQPMO_SYNCPOINT
Back to top
View user's profile Send private message
fjb_saper
PostPosted: Tue Nov 18, 2008 4:19 am    Post subject: Reply with quote

Grand High Poobah

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

In MQ Base you need to set the msg format to MQC.MQFMT_STRING for a text message. Just use as advertized JMS in J2EE and a little triggered app for MQBase. You can then just get the message, chg msgid/correlid and put the message, using set all context.

And by the way there is no encoding in msgid or correl id.
Which ever platform you look at, a byte is a byte is a byte.
Value in hex representation from 00 to FF.

Have fun.
_________________
MQ & Broker admin


Last edited by fjb_saper on Tue Nov 18, 2008 4:22 am; edited 1 time in total
Back to top
View user's profile Send private message Send e-mail
atheek
PostPosted: Tue Nov 18, 2008 4:22 am    Post subject: Reply with quote

Partisan

Joined: 01 Jun 2006
Posts: 327
Location: Sydney

meetgaurav wrote:
HI Atheek / FJB,

Thanks for the reply.. I selected JAVA API for another remote system. I have to test the XA functionality now.

I have 2 more queries
1.
--------------------------------------------------------
MQMessage msg = new MQMessage();
msg.writeString(msgContent);
--------------------------------------------------------
The above lines is not giving the message in instance of textmessage. Its giving as bytes message.

2.
--------------------------------------------------------
msg.messageId = msgId.getBytes();
msg.correlationId = correlId.getBytes();
--------------------------------------------------------

Am just assigning the msgid and correld as byte array.. But this getBytes() method is doing some encoding. Again the msg id will not remain the same what I sent.

Please advice Atheek and FJB


For (1) set msg.format = MQC.MQFMT_STRING;

For (2) what objects are msgId and correlId?
Back to top
View user's profile Send private message
fjb_saper
PostPosted: Tue Nov 18, 2008 4:27 am    Post subject: Reply with quote

Grand High Poobah

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

Now we are getting to the hart of the problem and it is a design problem

MsgId and correlid are of type byte[24]

Trying to infuse them with any particular meaning is an anti pattern.
Trying to treat them as String is an anti pattern.

They follow naturally an ANONYMOUS IDENTIFIER pattern.

Have fun redesigning.

Only in JMS can the correlationId be longer than byte[24]. The true value is then kept in the RFH header and the first 24 bytes are copied to the correlationId field in the MQMD.
_________________
MQ & Broker admin


Last edited by fjb_saper on Tue Nov 18, 2008 4:29 am; edited 1 time in total
Back to top
View user's profile Send private message Send e-mail
atheek
PostPosted: Tue Nov 18, 2008 4:27 am    Post subject: Reply with quote

Partisan

Joined: 01 Jun 2006
Posts: 327
Location: Sydney

fjb_saper wrote:
Just use as advertized JMS in J2EE and a little triggered app for MQBase. You can then just get the message, chg msgid/correlid and put the message, using set all context. Have fun.


Hi FJ, what you propose could be a much more elegant way. But there are situations where you may not want to build anything outside the app server. A classic case could be if you have configured the app server for high availability under an external HA software. Having part of the app outside the app server could mess this up.
Back to top
View user's profile Send private message
fjb_saper
PostPosted: Tue Nov 18, 2008 4:31 am    Post subject: Reply with quote

Grand High Poobah

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

atheek wrote:
fjb_saper wrote:
Just use as advertized JMS in J2EE and a little triggered app for MQBase. You can then just get the message, chg msgid/correlid and put the message, using set all context. Have fun.


Hi FJ, what you propose could be a much more elegant way. But there are situations where you may not want to build anything outside the app server. A classic case could be if you have configured the app server for high availability under an external HA software. Having part of the app outside the app server could mess this up.


So I don't see any way around redesigning the receiving app.
You are putting so much effort into designing around an anti-pattern. Imagine how much faster it would go if you redesigned the receiving app to follow the pattern...
_________________
MQ & Broker admin
Back to top
View user's profile Send private message Send e-mail
atheek
PostPosted: Tue Nov 18, 2008 4:37 am    Post subject: Reply with quote

Partisan

Joined: 01 Jun 2006
Posts: 327
Location: Sydney

Agree.. Changing the receiver app is the best and easiest solution.

But meetgaurav is saying its not a choice for him. Either he has to convince the management or has to find a work around. Both optons have been advised to him here.
Back to top
View user's profile Send private message
atheek
PostPosted: Tue Nov 18, 2008 4:39 am    Post subject: Reply with quote

Partisan

Joined: 01 Jun 2006
Posts: 327
Location: Sydney

meetgaurav wrote:
What is the use of this.

pmo.options = MQC.MQPMO_SYNCPOINT


Hope you are familar with JMS.

A mqput without MQC.MQPMO_SYNCPOINT is like using a non transacted session in auto acknowledge mode for sending a message.Messages will be immediately available for reception when the send completes.

A mqput with MQC.MQPMO_SYNCPOINT is like using a transacted session. Messages will be available for reception only after the commit is called.
Back to top
View user's profile Send private message
fjb_saper
PostPosted: Tue Nov 18, 2008 4:41 am    Post subject: Reply with quote

Grand High Poobah

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

atheek wrote:
fjb_saper wrote:
Just use as advertized JMS in J2EE and a little triggered app for MQBase. You can then just get the message, chg msgid/correlid and put the message, using set all context. Have fun.


Hi FJ, what you propose could be a much more elegant way. But there are situations where you may not want to build anything outside the app server. A classic case could be if you have configured the app server for high availability under an external HA software. Having part of the app outside the app server could mess this up.


So you mean to say that your qmgr is not under HA while the app using it is?
Your triggered app living under the qmgr could be under HA as well...
_________________
MQ & Broker admin
Back to top
View user's profile Send private message Send e-mail
meetgaurav
PostPosted: Tue Nov 18, 2008 4:46 am    Post subject: Reply with quote

Voyager

Joined: 08 Sep 2008
Posts: 94

Again My thanks to Atheek / FJB

Quote:

For (2) what objects are msgId and correlId?


msgId and correlId are actual msgid and correlid which I received from MQ message. Then I stored it as a String Format like

String Message ID =msg.getJMSMessageID();
String Correlation ID = msg.getJMSCorrelationID();

after that while replying am setting as
msg.messageId = msgid.getBytes();
msg.correlationId = p_message.getBytes();

Again if I try to receive the message the msgid will be different.. This getbytes() is doing some encoding. Any other way to set this..

Please advice
Back to top
View user's profile Send private message
fjb_saper
PostPosted: Tue Nov 18, 2008 5:00 am    Post subject: Reply with quote

Grand High Poobah

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

You have to check the APIs and use like with like.

The MQ BAse API is described in the Using Java manual.
The JMS API can be looked up here http://java.sun.com
The String being returned is a hex representation of a byte array.

For a byte value of FF, you need to use Integer/Byte.decode("0xFF") to convert it back to a byte.

Have fun
_________________
MQ & Broker admin
Back to top
View user's profile Send private message Send e-mail
atheek
PostPosted: Tue Nov 18, 2008 5:14 am    Post subject: Reply with quote

Partisan

Joined: 01 Jun 2006
Posts: 327
Location: Sydney

http://www.mqseries.net/phpBB2/viewtopic.php?t=45722
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic  Reply to topic Goto page Previous  1, 2, 3, 4  Next Page 3 of 4

MQSeries.net Forum Index » IBM MQ Java / JMS » Problem In MQ MessageID
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.