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 » WMB : How to Parse a String in Java Compute Node ?

Post new topic  Reply to topic
 WMB : How to Parse a String in Java Compute Node ? « View previous topic :: View next topic » 
Author Message
rohitkul
PostPosted: Mon Aug 24, 2009 10:16 pm    Post subject: WMB : How to Parse a String in Java Compute Node ? Reply with quote

Newbie

Joined: 24 Aug 2009
Posts: 6

I hav a RCD which gives me the parsed Message like
Message
MRM
Message1
Message2
...............
Messagen

I want to now parse this Message1, Message2 etc by a specific Message Definition, Set and Format using a Java Compute Node. Could you please guide me in this.

I understand that the Message needs to be first converted into BLOB format and then we can use toBitStream function to parse against a Message Set, Defn and Format. But could you please provide me the pseudo code for doing this.
Back to top
View user's profile Send private message
rohitkul
PostPosted: Mon Aug 24, 2009 11:38 pm    Post subject: WMB : Parse String Java Compute Node Reply with quote

Newbie

Joined: 24 Aug 2009
Posts: 6

I hav tried with the following code as below. But its not working. Can anybody help me out as to where am I going wrong here ASAP.

MbElement lastchild = root.getLastChild();

// starts the messages now
MbElement lastchildfirst = lastchild.getFirstChild();
MbElement nextElement = lastchildfirst;
while (nextElement != null)
{
MbElement element = nextElement.getNextSibling();
String str = element.getValue().toString();

// Converting string str to BLOB Format

MbElement outRoot = outMessage.getRootElement();
MbElement outParser = outRoot.createElementAsLastChild(MbBLOB.PARSER_NAME);
MbElement outBody = outParser.createElementAsLastChild(MbElement.TYPE_NAME_VALUE, "BLOB", str);

// Parse this element against the Message Type and Set
byte[] tmp = outRoot.getLastChild().toBitstream("MessageDef", "MessageSet", "TDS_FORMAT", 0, 0, 0);

nextElement = element;
}
Back to top
View user's profile Send private message
WMBDEV1
PostPosted: Tue Aug 25, 2009 12:41 am    Post subject: Re: WMB : How to Parse a String in Java Compute Node ? Reply with quote

Sentinel

Joined: 05 Mar 2009
Posts: 888
Location: UK

Why is this your requirement:
rohitkul wrote:
I want to now parse this Message1, Message2 etc by a specific Message Definition, Set and Format using a Java Compute Node.


ESQL will be easier to use and i'd have thought it will perform better.

Elaborate:
Quote:

But its not working


Do you get an error or is the output not as expected? If not why not?
Back to top
View user's profile Send private message
rohitkul
PostPosted: Tue Aug 25, 2009 12:49 am    Post subject: How to Parse a String in Java Compute Node ? Reply with quote

Newbie

Joined: 24 Aug 2009
Posts: 6

We need to just ignore the Messages which are not getting Parsed as per the message defn, format and set provided.

Initially there were a no. of messages, but if we had a RCD for parsing these, the flow was not going out of RCD since the RCD block would throw exception if one of our Messages fail. We don't want this to happen, rather just want to discard the Messages not parsed and go further.

If ESQL is better, then could you please suggest how to parse the Message using the Message Defn, Set and Format.
Back to top
View user's profile Send private message
WMBDEV1
PostPosted: Tue Aug 25, 2009 12:51 am    Post subject: Re: How to Parse a String in Java Compute Node ? Reply with quote

Sentinel

Joined: 05 Mar 2009
Posts: 888
Location: UK

rohitkul wrote:

If ESQL is better, then could you please suggest how to parse the Message using the Message Defn, Set and Format.


You can use PARSE ASBITSTREAM and then declare error handlers to handle parsing errors as needed.
Back to top
View user's profile Send private message
rohitkul
PostPosted: Tue Aug 25, 2009 12:55 am    Post subject: WMB : How to Parse a String in Java Compute Node ? Reply with quote

Newbie

Joined: 24 Aug 2009
Posts: 6

Can you provide me the example for doing this. A pseudo code in this case would be appreciable.
Back to top
View user's profile Send private message
rohitkul
PostPosted: Tue Aug 25, 2009 1:14 am    Post subject: WMB : How to Parse a String in Java Compute Node ? Reply with quote

Newbie

Joined: 24 Aug 2009
Posts: 6

I am not able to get an example for PARSE ASBITSTREAM. Can anybody help me out in this case. The documentation is available. But a pseudo code is highly appreciable since its difficult to understand from the documentation.
Back to top
View user's profile Send private message
kimbert
PostPosted: Tue Aug 25, 2009 1:20 am    Post subject: Reply with quote

Jedi Council

Joined: 29 Jul 2003
Posts: 5542
Location: Southampton

It's not 'PARSE ASBITSTREAM'.
You use the CREATE statement with the PARSE clause to create a message tree from a BLOB
You use ASBITSTREAM to create a BLOB from a message tree

There are dozens of examples of both statements on this forum.
Back to top
View user's profile Send private message
WMBDEV1
PostPosted: Tue Aug 25, 2009 1:33 am    Post subject: Reply with quote

Sentinel

Joined: 05 Mar 2009
Posts: 888
Location: UK

kimbert wrote:
It's not 'PARSE ASBITSTREAM'.
You use the CREATE statement with the PARSE clause to create a message tree from a BLOB
You use ASBITSTREAM to create a BLOB from a message tree


which leads to ....
PARSE ASBITSTREAM

I understand the point you're making, but I reckon the poster would still end up with "PARSE ASBITSTREAM" in his ESQL. I had hoped to provide enough information for the OP to then be able to go and research this for himself. Maybe if I had written it as PARSE [and] ASBITSTREAM it would have been more correct.
Back to top
View user's profile Send private message
yortch
PostPosted: Tue Aug 25, 2009 9:29 am    Post subject: Re: WMB : How to Parse a String in Java Compute Node ? Reply with quote

Apprentice

Joined: 30 Aug 2004
Posts: 34

rohitkul wrote:
I want to now parse this Message1, Message2 etc by a specific Message Definition, Set and Format using a Java Compute Node. Could you please guide me in this.


By parsing do you mean turning a message tree into a string representation? I was able to parse a XMLNSC tree (e.g. OutputRoot.XMLNSC) into a string using the following code:

Code:
byte[] data = xmlMbElement.toBitstream("", "", "", 0, 0, 0);
xmlStr = new String(data);


Hope this helps!
Back to top
View user's profile Send private message
mqjeff
PostPosted: Tue Aug 25, 2009 10:11 am    Post subject: Re: WMB : How to Parse a String in Java Compute Node ? Reply with quote

Grand Master

Joined: 25 Jun 2008
Posts: 17447

yortch wrote:
I was able to parse a XMLNSC tree (e.g. OutputRoot.XMLNSC) into a string


No, you weren't.

You were, perhaps, able to SERIALIZE an MBMessage Tree built using hte XMLNSC Parser into a string.

You did not PARSE it into a string. Parsing is, in fact, exactly opposite of what you did.
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 » WMB : How to Parse a String in Java Compute Node ?
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.