|
RSS Feed - WebSphere MQ Support
|
RSS Feed - Message Broker Support
|
 |
|
JMS and MQ Series |
« View previous topic :: View next topic » |
Author |
Message
|
courtneybandrews |
Posted: Thu Jul 02, 2009 5:13 pm Post subject: JMS and MQ Series |
|
|
Newbie
Joined: 02 Jul 2009 Posts: 2
|
I have an application that puts a JMS message to an MQ Series queue, via bindings for Weblogic. For some reason, when I set correlationID and messageID the system overrides these values and put their own. Not sure what is the problem? Can you help me out please.
Best regards,
Courtney |
|
Back to top |
|
 |
fjb_saper |
Posted: Thu Jul 02, 2009 5:52 pm Post subject: |
|
|
 Grand High Poobah
Joined: 18 Nov 2003 Posts: 20756 Location: LI,NY
|
Hi Courtney,
Sorry but how familiar are you with JMS? The message Id gets generated anew with each send and you have no control over it. The only thing you can control is the correlation Id. Now if you can be more specific with your problem we can maybe help you find a solution...  _________________ MQ & Broker admin |
|
Back to top |
|
 |
courtneybandrews |
Posted: Thu Jul 02, 2009 7:36 pm Post subject: |
|
|
Newbie
Joined: 02 Jul 2009 Posts: 2
|
This is the sample code:-
(a) Use JNDI and look up a binding queue JMS - MQ Series
(b) Generate a MessageID
(c) Send to legacy
(d) Expect legacy to switch MessageID to JMSCorrelationID
What happens:- MessageID is overwritten, and JMSCorrelationID does not match
Here is the sample code:-
/**
* Send message to Legacy pulled from JMS to send to MQ Series remote queue.
*/
public void sendMessage(String pack, String requestType)
throws SystemException {
try {
// generate id
UUID uuid = UUID.randomUUID();
msg_sel = uuid.toString();
String message = "packet: " + pack;
log.info(message);
System.out.println(message);
message = "request type: " + requestType;
log.info(message);
System.out.println(message);
message = "generated id: " + msg_sel;
log.info(message);
System.out.println(message);
message = "ctx: " + ctx;
log.info(message);
System.out.println(message);
sendQueue = (Queue) ctx.lookup(getSndQ(requestType));
replyQueue = (Queue) ctx.lookup(getReplyToQ(requestType));
message = "send queue: " + sendQueue;
log.info(message);
System.out.println(message);
message = "reply queue: " + replyQueue;
log.info(message);
System.out.println(message);
connection.start();
connection.setExceptionListener(this);
queueSender = session.createSender(sendQueue);
message = "queue sender: " + queueSender;
log.info(message);
System.out.println(message);
msg = session.createTextMessage();
msg.setText(pack);
msg.setJMSReplyTo(replyQueue);
msg.setJMSMessageID(msg_sel); // To set this real value - use random
msg.setJMSCorrelationID(msg_sel);
msg_sel = msg.getJMSCorrelationID();
System.out.println("correlation id:" + msg_sel);
message = "Sending the message to queue "
+ sendQueue.getQueueName();
log.info(message);
System.out.println(message);
queueSender.send(msg);
msg_sel = msg.getJMSCorrelationID();
System.out.println("correlation id2:" + msg_sel);
} catch (JMSException e) {
e.printStackTrace();
} catch (NamingException e) {
e.printStackTrace();
}
}
Thanks for your help
Courtney |
|
Back to top |
|
 |
fjb_saper |
Posted: Thu Jul 02, 2009 11:07 pm Post subject: |
|
|
 Grand High Poobah
Joined: 18 Nov 2003 Posts: 20756 Location: LI,NY
|
So which part of my earlier message did you not understand...
YOU have NO CONTROL over the JMSMessageID!
For best efficiency let MQ generate msgid and correlationId.
What you want is a 24 byte array. It will be represented as ID:xxxxxxx where xxxxxx is the hex string of the values of each of the 24 bytes (00-FF).
Any string longer than that will not survive a non JMS environment (no RFH header) and will slow down performance. This is why you should never think of the msgid or correlation ids as strings but as a byte[24]. Note this means also that there is never a ccsid translation happening on these fields.
This being duly noted:
What you can do is send the message, retrieve the messageid from the sent message and expect a return message with this in the correlid:
from memory as I don't have the doc at hand:
Code: |
queueSender.send(msg);
String msgid = msg.getJMSMessageID(); //alternatively use correlId if you populated it on the msg before sending it.
String selector = "JMSCorrelationID="+msgid;
Receiver rcvr = queuesession.createReceiver(msg.getJMSReplyTo(), selector);
connection.start();
Message replymsg = rcvr.receive(long); |
You might want to a little bit more the using java manual and the relevant examples delivered with the server product.
And can you please define correlation id does not match?
Do you mean you have correlationid != correlationid2 ? if yes can you print them? Or do you mean msg_sel != correlationid2 ?
If your destination queue is defined of MQ type (targetClient=1) then the correlationId will be truncated at 24 bytes... (as designed)...
Have fun  _________________ MQ & Broker admin |
|
Back to top |
|
 |
|
|
 |
|
Page 1 of 1 |
|
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
|
|
|
|