Author |
Message
|
ajdavis |
Posted: Wed Mar 27, 2002 2:01 pm Post subject: |
|
|
Newbie
Joined: 19 Mar 2002 Posts: 3
|
I have a JMS Listener deployed on WebSphere, receiving messages from an MQ client. The message I receive has the JMSReplyTo() set for my response to be sent back to. Since this queue is not handled within the JMSAdmin, I am unable to set the TARGCLIENT to MQ. When I receive the response back in my C client, all that header information causes trouble. Is there a way to turn off the RFH2 header information in the reply message programatically? Or is there a way to get around that information in the C client side?
Any help would be appreciated. |
|
Back to top |
|
 |
kolban |
Posted: Wed Mar 27, 2002 2:32 pm Post subject: |
|
|
 Grand Master
Joined: 22 May 2001 Posts: 1072 Location: Fort Worth, TX, USA
|
Oooh!!! Interesting problem ... I am thinking that you should be able to cast the JMSReplyToQ as an com.ibm.mq.jms.MQQueue object and then use the methods there to specify that the destination is not JMS but truly an MQ consumer. |
|
Back to top |
|
 |
ajdavis |
Posted: Wed Mar 27, 2002 2:37 pm Post subject: |
|
|
Newbie
Joined: 19 Mar 2002 Posts: 3
|
Thanks for the quick reply.
Is there a more generic solution? I was hoping to keep my Listener provider independent if possible. If not, I'll just have to live with it. |
|
Back to top |
|
 |
xprezons |
Posted: Wed Jun 15, 2005 2:29 pm Post subject: |
|
|
 Novice
Joined: 02 Sep 2004 Posts: 16 Location: UK
|
Sample Code for anyone who is trying to do this >
Code: |
/**
* Prepares and puts a message onto the queue.
* <p>
*
*/
private boolean putMessage() {
boolean boStatus = false;
try {
// Create JMS Queue Connection Factory
qcfFactory = new MQQueueConnectionFactory();
qcfFactory.setTransportType(JMSC.MQJMS_TP_CLIENT_MQ_TCPIP);
qcfFactory.setChannel(mqcd.getChannel());
qcfFactory.setHostName(mqcd.getHostname());
qcfFactory.setQueueManager(mqcd.getQManager());
if (mqcd.getPortNumber() != 0) {
qcfFactory.setPort(mqcd.getPortNumber());
}
// Create Connection
qConnection = qcfFactory.createQueueConnection();
qConnection.start();
session = qConnection.createQueueSession(transacted, Session.AUTO_ACKNOWLEDGE);
queue = session.createQueue(mqcd.getPutQName());
[b] // Set to not generate RFH2 header
MQDestination mqd = (MQDestination)queue;
mqd.setTargetClient(JMSC.MQJMS_CLIENT_NONJMS_MQ);[/b]
QueueSender qsender = session.createSender(queue);
//Creating a Text Message
TextMessage outMessage = session.createTextMessage(buildMessage());
//Put message onto the queue
qsender.send(outMessage);
qConnection.stop();
qConnection.close();
boStatus = true;
}
catch(Exception e)
{
System.out.println("Error while loading message onto the queue " + e.getMessage());
}
finally {
try {
if (qConnection != null) {
qConnection.close();
}
}
catch(Exception e) {
System.out.println("Error while forcefully closing Queue Connection " + e.getMessage());
}
}
return boStatus;
} |
|
|
Back to top |
|
 |
fjb_saper |
Posted: Wed Jun 15, 2005 6:28 pm Post subject: |
|
|
 Grand High Poobah
Joined: 18 Nov 2003 Posts: 20756 Location: LI,NY
|
Easier and staying within the JMS general spec:
String name = queue.getName();
name = name+"&targetClient=1" ; //you might have to check for other props already present ("?" present)
queue = session.createQueue(name);
Sorry all from memory
Enjoy  |
|
Back to top |
|
 |
bower5932 |
Posted: Thu Jun 16, 2005 1:55 am Post subject: |
|
|
 Jedi Knight
Joined: 27 Aug 2001 Posts: 3023 Location: Dallas, TX, USA
|
However, both methods tie your code to using WMQ as your JMS provider. |
|
Back to top |
|
 |
jefflowrey |
Posted: Thu Jun 16, 2005 3:52 am Post subject: |
|
|
Grand Poobah
Joined: 16 Oct 2002 Posts: 19981
|
bower5932 wrote: |
However, both methods tie your code to using WMQ as your JMS provider. |
Because the requirement was to specify that the target client was MQ, to prevent the creation of the MQRFH2 header.
If you can think of how to do this *without* tying the code to WMQ as a provider, or why you would NEED to do this if you weren't using WMQ as your provider...  _________________ I am *not* the model of the modern major general. |
|
Back to top |
|
 |
jefflowrey |
Posted: Thu Jun 16, 2005 4:39 am Post subject: |
|
|
Grand Poobah
Joined: 16 Oct 2002 Posts: 19981
|
Plus, there is also
http://www.developer.ibm.com/isv/tech/sampmq.html
Sample Java program that acts as a JMS requester to a server program (mqjmsreq.java)
Sample Java program that acts as a JMS server sending replies back to a requester program (mqjmssrv.java) _________________ I am *not* the model of the modern major general. |
|
Back to top |
|
 |
colincrist |
Posted: Sat Jun 18, 2005 2:16 pm Post subject: |
|
|
Novice
Joined: 24 Feb 2004 Posts: 22
|
To avoid your code being bound to WMQ...
You could program dynamically, test to see if the queue is WMQ, either via instanceof (which means you always need the WMQ client libs available) or (bit hacky this) via queue.getClass().getName().equals("com.ibm.mq.jms.MQQueue") and then use the ever useful http://jakarta.apache.org/commons/beanutils to invoke the methods dynamically with no casting - this means you don't need the MQ libs available at compile time. Of course if IBM changes the package name then you've an issue, but this is unlikely.
Not elegant, bit hacky, but pragmatic.
Colin. |
|
Back to top |
|
 |
|