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 » Get and Put again with same MessageID

Post new topic  Reply to topic
 Get and Put again with same MessageID « View previous topic :: View next topic » 
Author Message
sfari
PostPosted: Mon Apr 25, 2005 8:54 am    Post subject: Get and Put again with same MessageID Reply with quote

Centurion

Joined: 15 Apr 2003
Posts: 144

Hi,

Is it somehow possible to get a Message from a Queue manipulate the data and put it again on the same Queue
without having a changed MessageID afterwards? I need to use JMS because there are JMS Properties and Data which have to updated.

Clients are looking for Messages with specific Message IDs. So it is important that after my update the message is still available under the same ID.

Are there may some static MQ settings which influence the generation of Message IDs?

I am happy about any hint! Thanks!
Back to top
View user's profile Send private message
jefflowrey
PostPosted: Mon Apr 25, 2005 9:06 am    Post subject: Reply with quote

Grand Poobah

Joined: 16 Oct 2002
Posts: 19981

You can't preserve the message ID if you use JMS to send the message.

The JMS send always changes the message ID.

You should be able to write code that will copy the message, JMS header and all, to an MQ message that can be put using the Java API for WebSphere MQ.
_________________
I am *not* the model of the modern major general.
Back to top
View user's profile Send private message
fjb_saper
PostPosted: Mon Apr 25, 2005 4:15 pm    Post subject: Reply with quote

Grand High Poobah

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

jefflowry wrote:
You can't preserve the message ID if you use JMS to send the message

I know this to be true when you create the message via JMS. I am not so sure about it if you just move the message from one queue to the other.
You may have no choice as you may have to modify the payload.

Try something simple. Create a message and put on queue A. Get the JMSMessageID and store it in memory and print it out. Consume the message. Create a new message and set the JMSMessageID to the one in memory. Post the message to a queue.

Check the message id. If nothing else it is worth a try
Back to top
View user's profile Send private message Send e-mail
EddieA
PostPosted: Mon Apr 25, 2005 4:57 pm    Post subject: Reply with quote

Jedi

Joined: 28 Jun 2001
Posts: 2453
Location: Los Angeles

Quote:
I am not so sure about it if you just move the message from one queue to the other

Quote:
The JMS send always changes the message ID

From the Java Manual:
Quote:
setJMSMessageID
.
.
.
Any value set using this method is ignored when the message is sent, but this method can be used to change the value in a received message.

Cheers,
_________________
Eddie Atherton
IBM Certified Solution Developer - WebSphere Message Broker V6.1
IBM Certified Solution Developer - WebSphere Message Broker V7.0
Back to top
View user's profile Send private message
clindsey
PostPosted: Tue Apr 26, 2005 4:50 am    Post subject: Reply with quote

Knight

Joined: 12 Jul 2002
Posts: 586
Location: Dallas, Tx

Were you planning to return the message to the same queue. If so, how can you be sure your code to modify the content would get the message before your client's app. Seems you would have to insert a staging queue in the mix to receive the messages first, where you could modify and redirect them.

To intercept the message on the destination queue and modify it before the receiving app, you would have to use an API Exit.

Charlie
Back to top
View user's profile Send private message
jefflowrey
PostPosted: Tue Apr 26, 2005 5:03 am    Post subject: Reply with quote

Grand Poobah

Joined: 16 Oct 2002
Posts: 19981

clindsey wrote:
To intercept the message on the destination queue and modify it before the receiving app, you would have to use an API Exit.


Which you can't write in Java. Not even in v6.
_________________
I am *not* the model of the modern major general.
Back to top
View user's profile Send private message
sfari
PostPosted: Tue Apr 26, 2005 5:19 am    Post subject: Reply with quote

Centurion

Joined: 15 Apr 2003
Posts: 144

I am able to do the message manipulation during a maintainance window so I am sure the application does not consume the messages at the same time.

I think I found a way to do what I want but I am not very happy with it! It's not very elegant and I am not really sure if it really works.

1. get the message using JMS
2. save the message id
3. manipulate the message
4. put the manipulated message backto the queue (new msgid will be issued)
5. get this message again with MQ base API
6. change the message id to the saved one in step 2
7. put the message back to the queue

With MQ base Java classes it is possible to manipulate a message id manually. A problem is that between step 4 and 5 I need to convert the message ID from a string to a byte array, since JMS does return the ID as string. I don't know what kind of conversion IBM is using for that.

Silvano
Back to top
View user's profile Send private message
jefflowrey
PostPosted: Tue Apr 26, 2005 5:33 am    Post subject: Reply with quote

Grand Poobah

Joined: 16 Oct 2002
Posts: 19981

You should be able to skip writing it to a queue and then getting it again.

Set your properties, extract the bytes of the JMS message and then create a new MQ Message and set the MQMD fields.
_________________
I am *not* the model of the modern major general.
Back to top
View user's profile Send private message
sfari
PostPosted: Tue Apr 26, 2005 5:51 am    Post subject: Reply with quote

Centurion

Joined: 15 Apr 2003
Posts: 144

If I do it that way I need to rebild the whole MQRFH2 2 Header with its XML property structure. Is it not much more complicated to do this correctly than to just put it with JMS and get it again with MQ base?

The only problem I see with this solution is as I said the convertion of the string msgId (JMS) to a byte msgId (MQ base).

Thanks
Silvano
Back to top
View user's profile Send private message
fjb_saper
PostPosted: Tue Apr 26, 2005 5:30 pm    Post subject: Reply with quote

Grand High Poobah

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

This conversion should pose no problem. Look at the different methods.
One of them should be byte[] getJMSMessageIDasBytes()

Enjoy
Back to top
View user's profile Send private message Send e-mail
sfari
PostPosted: Wed Apr 27, 2005 1:28 am    Post subject: Reply with quote

Centurion

Joined: 15 Apr 2003
Posts: 144

I haven't found such a method . As far as I have seen the Message ID in JMS is always represented as String. Thus in a mix of the JMS and MQ base I would need to know how to convert this String to a byte[].
Back to top
View user's profile Send private message
clindsey
PostPosted: Wed Apr 27, 2005 6:11 am    Post subject: Reply with quote

Knight

Joined: 12 Jul 2002
Posts: 586
Location: Dallas, Tx

There is method getJMSCorrellationIDAsBytes but no getJMSMessageIDAsBytes.

I believe getJMSMessageID.getBytes() will use the String getBytes method to return a byte array.

Charlie
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 » Get and Put again with same 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.