Author |
Message
|
Aldrine |
Posted: Thu Dec 01, 2011 10:16 pm Post subject: JAVA Application to Put and Get Messages from MQ |
|
|
 Novice
Joined: 25 Jul 2011 Posts: 22 Location: India
|
Hi Friends,
I am currently trying to build a java program to pump messages with RFH Header (V2) and also to retrieve the messages from Queue.
Code for put:
Code: |
try {
BufferedReader br = new BufferedReader(
new InputStreamReader(new DataInputStream(
new FileInputStream(new File(args[2]))), "Cp437"));
MQInterface MQcon = new MQInterface(queuemgr);
System.out.println("Connected to Queue Manager : " + queuemgr);
MQMessage message = new MQMessage();
String strLine;
while ((strLine = br.readLine()) != null) {
message.write(strLine.getBytes("Cp437"));
message.characterSet = 1208;
message.encoding = 546;
MQcon.publishDestinationList(message, queue);
message.clearMessage();
} |
The problem i am facing is, if i use RFHUtil to load the message to the Queue, it works perfectly; all the respective Headers are parsed and displayed in the respective tabs in RFHUtil (like Data, MQMD, USr, PubSub, and RFH).
But if i use the Java application to load the message to the Queue. It isn't parsed to the respective Headers. it is all under the Data Tab.
I am not sure in which part i am doing it wrong. the Message (from file, which is loaded to the Queue) has the RFH header with it; as it is saved using RFHUtil, with Headers.
kindly help me Thanks in advance.
Regards,
Aldrine Einsteen _________________ --
Aldrine Einsteen |
|
Back to top |
|
 |
fjb_saper |
Posted: Thu Dec 01, 2011 11:47 pm Post subject: |
|
|
 Grand High Poobah
Joined: 18 Nov 2003 Posts: 20756 Location: LI,NY
|
Well Aldrine, I hope you do realize that the concept here is header chaining...
Now for the rest, I am sure you can find samples.
The MQMD gets set by the application. Anything else will be part of the payload, or in V7 of the properties and payload.
Have fun  _________________ MQ & Broker admin |
|
Back to top |
|
 |
Aldrine |
Posted: Wed Dec 14, 2011 12:36 am Post subject: Better Solution |
|
|
 Novice
Joined: 25 Jul 2011 Posts: 22 Location: India
|
Using the RFHUtil's C program (Scripts) is much better playing around with Java and the Header details.
The Scripts are tidy themselves...
Thanks fjb  _________________ --
Aldrine Einsteen |
|
Back to top |
|
 |
mqjeff |
Posted: Wed Dec 14, 2011 2:45 am Post subject: |
|
|
Grand Master
Joined: 25 Jun 2008 Posts: 17447
|
You shouldn't be using an MQRFH2 header if you're on MQ v7.
You should be using message properties. |
|
Back to top |
|
 |
Aldrine |
Posted: Wed Dec 14, 2011 2:53 am Post subject: |
|
|
 Novice
Joined: 25 Jul 2011 Posts: 22 Location: India
|
Hi mqjeff,
mqjeff wrote: |
You shouldn't be using an MQRFH2 header if you're on MQ v7.
You should be using message properties. |
I am indeed using the MQ 7; the my need is to pump messages read from file (the data from file itself has RFH2 header) to MQ.
If you pump the message using Java after reading the data into a MQMessage; it is not getting parsed in the Header properly.
Hence i used the RFHUtil's script: which automatically parses the RFH2 header which is present @ the begin of the message and then pump the same.  _________________ --
Aldrine Einsteen |
|
Back to top |
|
 |
mqjeff |
Posted: Wed Dec 14, 2011 3:21 am Post subject: |
|
|
Grand Master
Joined: 25 Jun 2008 Posts: 17447
|
Ah! I see.
the usual caveats about making sure you're reading the data in the right code page and not doing things to convert it under the covers (java is fun that way).
Then use amqsbcg to dump the output message. |
|
Back to top |
|
 |
Aldrine |
Posted: Wed Dec 14, 2011 4:03 am Post subject: |
|
|
 Novice
Joined: 25 Jul 2011 Posts: 22 Location: India
|
mqjeff wrote: |
Ah! I see.
the usual caveats about making sure you're reading the data in the right code page and not doing things to convert it under the covers (java is fun that way).
Then use amqsbcg to dump the output message. |
Hi mqjeff,
Yet we meet again
I am looking for pumping a message from file to MQ; amqsbcg is for browsing the messages right? _________________ --
Aldrine Einsteen |
|
Back to top |
|
 |
mqjeff |
Posted: Wed Dec 14, 2011 4:29 am Post subject: |
|
|
Grand Master
Joined: 25 Jun 2008 Posts: 17447
|
Aldrine wrote: |
mqjeff wrote: |
Ah! I see.
the usual caveats about making sure you're reading the data in the right code page and not doing things to convert it under the covers (java is fun that way).
Then use amqsbcg to dump the output message. |
Hi mqjeff,
Yet we meet again
I am looking for pumping a message from file to MQ; amqsbcg is for browsing the messages right? |
Yes.
The message you have produced from your code. So you can make sure it is being produced correctly. |
|
Back to top |
|
 |
|