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 » WebSphere Message Broker (ACE) Support » JMS InputNode How to get javax.jms.Message

Post new topic  Reply to topic
 JMS InputNode How to get javax.jms.Message « View previous topic :: View next topic » 
Author Message
tonytang
PostPosted: Tue Nov 01, 2011 11:56 pm    Post subject: JMS InputNode How to get javax.jms.Message Reply with quote

Newbie

Joined: 01 Nov 2011
Posts: 7

Hello all:)

I have a message flow like

JMSInput ->JavaCompute ->JMSOutput.

How can I get javax.jms.message in the JavaCompute node?

First I have set the parser of JMSInput to BLOB.
and package my java project as a jar file then add to classpath.
Because I have these from document:
Additional processing is required to deal with the ObjectMessage payload because the JMS ObjectMessage payload is a serialized Java Object.

The JMSInput node obtains the payload by calling getObject( ) on the message. getObject( ) returns a de-serialized object of the original class. This class definition must be made available to the JMSInput node, and you should ensure that it is accessible through the broker's Java class path. (The class path is defined in the mqsiprofile batch file, which is in the broker's executable directory; for example, on Windows, this is mqsiprofile.cmd in the install_dir/bin directory.) The JMSInput node invokes the BLOB parser, which creates the message body by using a bit stream that is created from the object.

What should I do in the JavaCompute node to get the javax.jms.Message, because in JavaCompute node only have blow object:
public void evaluate(MbMessageAssembly contact admin){
MbOutputTerminal out = getOutputTerminal("out");
MbOutputTerminal alt = getOutputTerminal("alternate");

MbMessage inMessage = contact admin.getMessage();

// other code

}

I have stuck here for two days,
Please help me.
Thanks!!!!!!
Back to top
View user's profile Send private message
paintpot
PostPosted: Wed Nov 02, 2011 1:43 am    Post subject: Reply with quote

Centurion

Joined: 19 Sep 2005
Posts: 112
Location: UK

First, is is much better not to pass Java objects around, as you create dependencies.

Secondly, the MB project and java project should be deployed in the standard manner, in a BAR.

Finally, you need:

Code:

MbElement root = inMessage.getRootElement();
MbElement blob = root.getFirstElementByPath("/BLOB");


to get your hands on the Blob. It sounds like you know java, so the next bits should be ok for you.

Hopefully that is enough to get you restarted.
Back to top
View user's profile Send private message
tonytang
PostPosted: Wed Nov 02, 2011 5:41 am    Post subject: Reply with quote

Newbie

Joined: 01 Nov 2011
Posts: 7

Yes, I log The BLOB
But still can not de-serialized to a JAVA object.
How to pass the BLOB-element to javax.jms.Message?
Back to top
View user's profile Send private message
tonytang
PostPosted: Wed Nov 02, 2011 5:45 am    Post subject: Reply with quote

Newbie

Joined: 01 Nov 2011
Posts: 7

paintpot wrote:
First, is is much better not to pass Java objects around, as you create dependencies.

Secondly, the MB project and java project should be deployed in the standard manner, in a BAR.


B.T.W , First I include the java project in the same BAR file, but this does not work,
Then I add this jar file to the classpath, it is works,
I don't know why
Back to top
View user's profile Send private message
mqjeff
PostPosted: Wed Nov 02, 2011 5:59 am    Post subject: Reply with quote

Grand Master

Joined: 25 Jun 2008
Posts: 17447

Don't add it to classpath.

Put it in shared-classes.

And then go back to the Information Center and review the provided material on classloading.

And then STOP USING ObjectMessages. They are a bad idea.
Back to top
View user's profile Send private message
tonytang
PostPosted: Wed Nov 02, 2011 6:18 am    Post subject: Reply with quote

Newbie

Joined: 01 Nov 2011
Posts: 7

mqjeff wrote:

And then STOP USING ObjectMessages. They are a bad idea.


WHY?
In our system we want to use MQ to communicate with other system, but in our system, between project we want to use JMS, so in this time maybe is better to use ObjectMessage, am i right?



P.S finnally I got the message:
Code:

      MbElement root=inMessage.getRootElement();
      MbElement blob = root.getFirstElementByPath("BLOB");
      MbElement first=blob.getFirstChild();
         ObjectInputStream objectInput = new ObjectInputStream(new ByteArrayInputStream((byte[]) value));
         Object object = objectInput.readObject(); // this is the message, e.g: User, Accout
Back to top
View user's profile Send private message
mqjeff
PostPosted: Wed Nov 02, 2011 6:25 am    Post subject: Reply with quote

Grand Master

Joined: 25 Jun 2008
Posts: 17447

Because an object message requires a number of things that must be the same between both ends... including for example the version of the class that describes the object.

So every time you update one side, you have to update both sides.

If, instead, you use a StringMessage to hold string based data, perhaps a JSON string or an XML document, then you can have code that is less tightly coupled and you only have to change both sides if the data changes.
Back to top
View user's profile Send private message
tonytang
PostPosted: Wed Nov 02, 2011 6:32 am    Post subject: Reply with quote

Newbie

Joined: 01 Nov 2011
Posts: 7

exactly!
Thanks
Back to top
View user's profile Send private message
Vitor
PostPosted: Wed Nov 02, 2011 6:51 am    Post subject: Reply with quote

Grand High Poobah

Joined: 11 Nov 2005
Posts: 26093
Location: Texas, USA

tonytang wrote:
In our system we want to use MQ to communicate with other system, but in our system, between project we want to use JMS, so in this time maybe is better to use ObjectMessage, am i right?




mqjeff wrote:
If, instead, you use a StringMessage to hold string based data, perhaps a JSON string or an XML document, then you can have code that is less tightly coupled and you only have to change both sides if the data changes



_________________
Honesty is the best policy.
Insanity is the best defence.
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 » WebSphere Message Broker (ACE) Support » JMS InputNode How to get javax.jms.Message
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.