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 » IIB 9/10 Events - process the base64Binary message in Java?

Post new topic  Reply to topic
 IIB 9/10 Events - process the base64Binary message in Java? « View previous topic :: View next topic » 
Author Message
john.ormerod
PostPosted: Tue Mar 07, 2017 4:40 am    Post subject: IIB 9/10 Events - process the base64Binary message in Java? Reply with quote

Apprentice

Joined: 14 Feb 2017
Posts: 49

Hello
I have searched the forum, and not found an answer. Apologies if one does exist.

I want to be able to process the contents of the wmb:bitstream/wmb:encoding="base64Binary" in an Event message, received from a subscription to the appropriate Event topic.

In a simple Java test with the debugger, using org.apache.commons.codec.binary.Base64 to decode, I can see the bitstream as a String converted from a byte array. The text that I sent using the Pager sample, is visible at the end of the String, though there is a 'space' before each character e.g "< ? x m l v e r s i o n =", which must be an unprinatable character (and prevents copy/paste of selected text from the Console!?).

What I want is a definition of how to parse the decoded bitstream, probably as a byte array, in order to extract the headers or properties (not sure of the precise term, as I'm not an IIB developer) as well as the message content.

Grateful if anyone can help with this.

Regards, John
Back to top
View user's profile Send private message Send e-mail
smdavies99
PostPosted: Tue Mar 07, 2017 4:51 am    Post subject: Re: IIB 9/10 Events - process the base64Binary message in Ja Reply with quote

Jedi Council

Joined: 10 Feb 2003
Posts: 6076
Location: Somewhere over the Rainbow this side of Never-never land.

john.ormerod wrote:

In a simple Java test with the debugger, using org.apache.commons.codec.binary.Base64 to decode, I can see the bitstream as a String converted from a byte array. The text that I sent using the Pager sample, is visible at the end of the String, though there is a 'space' before each character e.g "< ? x m l v e r s i o n =", which must be an unprinatable character (and prevents copy/paste of selected text from the Console!?).

What I want is a definition of how to parse the decoded bitstream, probably as a byte array, in order to extract the headers or properties (not sure of the precise term, as I'm not an IIB developer) as well as the message content.

Grateful if anyone can help with this.

Regards, John


The text you are seeing after decoding the bitstream is in UNICODE. If you look at the hex representation you will see that the unprintable bits are all "0000".
To parse this you can do it in ESQL using the following steps.

1) Convert the Base64 to BLOB using the builtin function to decode the Base64Binary
2) Create a message tree from the BLOB using the Create + PARSE function

Bear in mind that you might assume that the content of the Base64Binary is an XML structure but what happens if something accidentally puts a non XML message onto the Queue (or other medium). You may want to verify that the BLOB has the

"< ? x m l v e r s i o n =",

or at least the

"< "

before trying to parse it as XML.
_________________
WMQ User since 1999
MQSI/WBI/WMB/'Thingy' User since 2002
Linux user since 1995

Every time you reinvent the wheel the more square it gets (anon). If in doubt think and investigate before you ask silly questions.
Back to top
View user's profile Send private message
john.ormerod
PostPosted: Tue Mar 07, 2017 1:41 pm    Post subject: Reply with quote

Apprentice

Joined: 14 Feb 2017
Posts: 49

Thanks for clarifying - I suspected I was dealing with 16 bit 'characters'.
I can't use ESQL. My java code will run outside of IIB, in the sense that it won't use msg flows - it's part of a planned monitoring tool, where I am using the CMP Java api. The event data arrives in a JMS onMessage() method in response to a subscription.

I've just searched to see if I can find anything to convert in Java. Only success is with the xml (in this case) content - the rest looks like simplified Chinese, I guess because the data isn't characters.

Is there a way to decocde this and process the message tree (I guess that's the term I was loooking for) in Java?

I've just had a search for 'parse message tree java' and found this
https://www.ibm.com/support/knowledgecenter/en/SSMKHH_9.0.0/com.ibm.etools.mft.doc/ac30330_.htm
I fear this only applies to a Java node where the MbMessageAssembly class is available.

Can I make any progress?

Regards, John
Back to top
View user's profile Send private message Send e-mail
fjb_saper
PostPosted: Tue Mar 07, 2017 1:58 pm    Post subject: Reply with quote

Grand High Poobah

Joined: 18 Nov 2003
Posts: 20696
Location: LI,NY

john.ormerod wrote:
Thanks for clarifying - I suspected I was dealing with 16 bit 'characters'.
I can't use ESQL. My java code will run outside of IIB, in the sense that it won't use msg flows - it's part of a planned monitoring tool, where I am using the CMP Java api. The event data arrives in a JMS onMessage() method in response to a subscription.

I've just searched to see if I can find anything to convert in Java. Only success is with the xml (in this case) content - the rest looks like simplified Chinese, I guess because the data isn't characters.

Is there a way to decocde this and process the message tree (I guess that's the term I was loooking for) in Java?

I've just had a search for 'parse message tree java' and found this
https://www.ibm.com/support/knowledgecenter/en/SSMKHH_9.0.0/com.ibm.etools.mft.doc/ac30330_.htm
I fear this only applies to a Java node where the MbMessageAssembly class is available.

Can I make any progress?

Regards, John

Well,,, you should be able to look at the content and determine whether it is indeed xml or something else depending on the content. Then you should be able to parse it, either in XML using the Xerxes parser or in DFDL using the DFDL parser...(and jars ... see documentation...)
What you are going to do with the parsed data outside of IIB I have no idea...
_________________
MQ & Broker admin
Back to top
View user's profile Send private message Send e-mail
timber
PostPosted: Tue Mar 07, 2017 2:15 pm    Post subject: Reply with quote

Grand Master

Joined: 25 Aug 2015
Posts: 1280

Quote:
Thanks for clarifying - I suspected I was dealing with 16 bit 'characters'.
They're just ordinary characters, sir. Nothing unusual or special about them. In fact, 8-bit characters are the exception, not the rule, these days.

That reply leads me to think that you should read this:The Absolute Minimum Every Software Developer Absolutely, Positively Must Know About Unicode and Character Sets (No Excuses!)
It's well written and explains the issues very well. Written in 2003, btw.
Back to top
View user's profile Send private message
john.ormerod
PostPosted: Thu Mar 09, 2017 1:45 am    Post subject: Reply with quote

Apprentice

Joined: 14 Feb 2017
Posts: 49

Hi timber
Thanks for the link to Unicode. It was well worth taking 10-15 minutes to read it. Unicode was something I "kind of, sort of" assumed I knew enough about and was on my long list of things to look at one day. I will post it internally as something to read.
I started with EBCDIC (which no doubt places me in time and organisation) so had to grapple with this rather limited 7-bit ASCII when it rose to prominance etc. I'd basically assumed Unicode was a new name for DBCS. I'm now much better informed. A good read.
Regards, John
Back to top
View user's profile Send private message Send e-mail
Display posts from previous:   
Post new topic  Reply to topic Page 1 of 1

MQSeries.net Forum Index » WebSphere Message Broker (ACE) Support » IIB 9/10 Events - process the base64Binary message in Java?
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.