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 API Support » JAVA Application to Put and Get Messages from MQ

Post new topic  Reply to topic
 JAVA Application to Put and Get Messages from MQ « View previous topic :: View next topic » 
Author Message
Aldrine
PostPosted: Thu Dec 01, 2011 10:16 pm    Post subject: JAVA Application to Put and Get Messages from MQ Reply with quote

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
View user's profile Send private message
fjb_saper
PostPosted: Thu Dec 01, 2011 11:47 pm    Post subject: Reply with quote

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
View user's profile Send private message Send e-mail
Aldrine
PostPosted: Wed Dec 14, 2011 12:36 am    Post subject: Better Solution Reply with quote

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
View user's profile Send private message
mqjeff
PostPosted: Wed Dec 14, 2011 2:45 am    Post subject: Reply with quote

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
View user's profile Send private message
Aldrine
PostPosted: Wed Dec 14, 2011 2:53 am    Post subject: Reply with quote

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
View user's profile Send private message
mqjeff
PostPosted: Wed Dec 14, 2011 3:21 am    Post subject: Reply with quote

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
View user's profile Send private message
Aldrine
PostPosted: Wed Dec 14, 2011 4:03 am    Post subject: Reply with quote

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
View user's profile Send private message
mqjeff
PostPosted: Wed Dec 14, 2011 4:29 am    Post subject: Reply with quote

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
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 API Support » JAVA Application to Put and Get Messages from MQ
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.