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 » How to convert Base64 payload in Monitoring event into XML

Post new topic  Reply to topic
 How to convert Base64 payload in Monitoring event into XML « View previous topic :: View next topic » 
Author Message
hellozen123
PostPosted: Wed Feb 08, 2017 6:11 am    Post subject: How to convert Base64 payload in Monitoring event into XML Reply with quote

Novice

Joined: 09 May 2016
Posts: 11

Hi,

I am new to Java and JCN. I am using monitoring events to create a custom audit message in xml format and having following issues?

1) How do I convert Base64encoded payload I receive by subscribing to a Monitoring Event into XML using JavaComputeNode? Earlier in my project payload (again a xml message) was encoded as CDATA, which I was able to embed into custom Audit message.

Quote:
wmb:bitstream wmb:encoding="hexBinary">4d442020............


2) If I received Base64 encoded payload which is the combination of MQMD + Body then how can I split it. Since I am struggling with the first issue, I am not even sure how the complete payload would look like after decoding. Somewhere in my project I found custom class that splits MQMD and Body into two separate BLOBs.

This causes another problem,

3) That is converting BLOB into XML using JAVA. I have searched this FORUM and found many discussions but they all share solution via ESQL or RCD. Even in the Infocentre only reverse is mentioned, which is converting XML into BLOB. I do not want to pass the encoded part to RCD and receive it again in another JCN to build the custom xml.

4) How can I subscribe to a event generated by a particular node only in a flow. As per my understanding Monitoring events topics are defined up to Flow level or above. So if my flow A is generating 3 events (considering 3 nodes are configured to emit monitoring events) then I have consume all the 3 events and discard the one I don't need in the JCN. I think this is the product limitation and Topics for node level events are only available for statistic events not monitoring.

I have spent considerable amount of time doing trial and error in IIB, searching this forum, info centre and stack trace forum, only after that I am posting these questions. I would really appreciate if you can share some advice.

Thanks
[/quote]
Back to top
View user's profile Send private message
fjb_saper
PostPosted: Wed Feb 08, 2017 9:02 am    Post subject: Re: How to convert Base64 payload in Monitoring event into X Reply with quote

Grand High Poobah

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

hellozen123 wrote:
Hi,

I am new to Java and JCN. I am using monitoring events to create a custom audit message in xml format and having following issues?

1) How do I convert Base64encoded payload I receive by subscribing to a Monitoring Event into XML using JavaComputeNode? Earlier in my project payload (again a xml message) was encoded as CDATA, which I was able to embed into custom Audit message.

Quote:
wmb:bitstream wmb:encoding="hexBinary">4d442020............


This says hexbinary and not 64bit encoded and the content confirms it

hellozen123 wrote:
2) If I received Base64 encoded payload which is the combination of MQMD + Body then how can I split it. Since I am struggling with the first issue, I am not even sure how the complete payload would look like after decoding. Somewhere in my project I found custom class that splits MQMD and Body into two separate BLOBs.

This causes another problem,

3) That is converting BLOB into XML using JAVA. I have searched this FORUM and found many discussions but they all share solution via ESQL or RCD. Even in the Infocentre only reverse is mentioned, which is converting XML into BLOB. I do not want to pass the encoded part to RCD and receive it again in another JCN to build the custom xml.
[/code]

There are quite a few standard Java 64bit Encoders and Decoders out there... Google it. You might even find a reference back into the infocenter...
hellozen123 wrote:

4) How can I subscribe to a event generated by a particular node only in a flow. As per my understanding Monitoring events topics are defined up to Flow level or above. So if my flow A is generating 3 events (considering 3 nodes are configured to emit monitoring events) then I have consume all the 3 events and discard the one I don't need in the JCN. I think this is the product limitation and Topics for node level events are only available for statistic events not monitoring.

Have you thought about creating a collection that would capture all the events from a single flow invocation?

hellozen123 wrote:

I have spent considerable amount of time doing trial and error in IIB, searching this forum, info centre and stack trace forum, only after that I am posting these questions. I would really appreciate if you can share some advice.

Thanks

_________________
MQ & Broker admin
Back to top
View user's profile Send private message Send e-mail
hellozen123
PostPosted: Wed Feb 08, 2017 9:26 am    Post subject: Reply with quote

Novice

Joined: 09 May 2016
Posts: 11

Quote:
hellozen123 wrote:
Hi,

I am new to Java and JCN. I am using monitoring events to create a custom audit message in xml format and having following issues?

1) How do I convert Base64encoded payload I receive by subscribing to a Monitoring Event into XML using JavaComputeNode? Earlier in my project payload (again a xml message) was encoded as CDATA, which I was able to embed into custom Audit message.

Quote:
wmb:bitstream wmb:encoding="hexBinary">4d442020............


This says hexbinary and not 64bit encoded and the content confirms it

hellozen123 wrote:
2) If I received Base64 encoded payload which is the combination of MQMD + Body then how can I split it. Since I am struggling with the first issue, I am not even sure how the complete payload would look like after decoding. Somewhere in my project I found custom class that splits MQMD and Body into two separate BLOBs.

This causes another problem,

3) That is converting BLOB into XML using JAVA. I have searched this FORUM and found many discussions but they all share solution via ESQL or RCD. Even in the Infocentre only reverse is mentioned, which is converting XML into BLOB. I do not want to pass the encoded part to RCD and receive it again in another JCN to build the custom xml.
[/code]

There are quite a few standard Java 64bit Encoders and Decoders out there... Google it. You might even find a reference back into the infocenter...
hellozen123 wrote:

4) How can I subscribe to a event generated by a particular node only in a flow. As per my understanding Monitoring events topics are defined up to Flow level or above. So if my flow A is generating 3 events (considering 3 nodes are configured to emit monitoring events) then I have consume all the 3 events and discard the one I don't need in the JCN. I think this is the product limitation and Topics for node level events are only available for statistic events not monitoring.

Have you thought about creating a collection that would capture all the events from a single flow invocation?


Thanks for the reply, yes it was my mistake encoding is Hexbinary.

I am now able to decode it into character array using HexBin java utility and then converting it into string using

Code:
String xmlString = new String(decodedBytes);


I can see the xml structure but it is not proper.

Code:
<NS2:DbtrAgt>\r\n\t\t\t\t\t<NS2:FinInstnId>\r\n\t\t\t\t\t\t<NS2:BICFI>FIAMQTSTXXX</NS2:BICFI>\r\n\t\t\t\t\t</NS2:FinInstnId>\r\n\t\t\t\t</NS2:DbtrAgt>


getting these extra \r\n\t . What am I doing wrong here.
Back to top
View user's profile Send private message
hellozen123
PostPosted: Wed Feb 08, 2017 9:33 am    Post subject: Reply with quote

Novice

Joined: 09 May 2016
Posts: 11

I also tried
Code:
 String xmlString = new String(decodedBytes,"UTF-8");
still same result.
Back to top
View user's profile Send private message
Vitor
PostPosted: Wed Feb 08, 2017 9:39 am    Post subject: Reply with quote

Grand High Poobah

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

hellozen123 wrote:

I can see the xml structure but it is not proper.

Code:
<NS2:DbtrAgt>\r\n\t\t\t\t\t<NS2:FinInstnId>\r\n\t\t\t\t\t\t<NS2:BICFI>FIAMQTSTXXX</NS2:BICFI>\r\n\t\t\t\t\t</NS2:FinInstnId>\r\n\t\t\t\t</NS2:DbtrAgt>


getting these extra \r\n\t . What am I doing wrong here.


Nothing - that's a proper (or to use the technical term well formed) piece of XML. The additional tabs and so forth may or may not have been visible through whatever you were using to view the original source, and may or may not have been there (my Java is not up to snuff) but they have nothing to do with the XML content & don't affect it. They're just whitespace.

Unless you're using some non-compliant, home grown parser.
_________________
Honesty is the best policy.
Insanity is the best defence.
Back to top
View user's profile Send private message
hellozen123
PostPosted: Wed Feb 08, 2017 10:15 am    Post subject: Reply with quote

Novice

Joined: 09 May 2016
Posts: 11

Thanks for the reply. My original message didnt have \r\n\t\. They are getting introduced via my processing. I can explicitly remove that from string but this might cause some issues when i receive these escaped in xml.
Back to top
View user's profile Send private message
Vitor
PostPosted: Wed Feb 08, 2017 10:17 am    Post subject: Reply with quote

Grand High Poobah

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

hellozen123 wrote:
this might cause some issues when i receive these escaped in xml.


What issues? Exactly? Why would any XML parser care about whitespace? Unless told to do so, which would be a very specific use case.

What exactly is your concern here?
_________________
Honesty is the best policy.
Insanity is the best defence.
Back to top
View user's profile Send private message
Vitor
PostPosted: Wed Feb 08, 2017 10:20 am    Post subject: Reply with quote

Grand High Poobah

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

This

Code:
<NS2:DbtrAgt>\r\n\t\t\t\t\t<NS2:FinInstnId>\r\n\t\t\t\t\t\t<NS2:BICFI>FIAMQTSTXXX</NS2:BICFI>\r\n\t\t\t\t\t</NS2:FinInstnId>\r\n\t\t\t\t</NS2:DbtrAgt>


is the same XML as this:

Code:
<NS2:DbtrAgt><NS2:FinInstnId><NS2:BICFI>FIAMQTSTXXX</NS2:BICFI></NS2:FinInstnId></NS2:DbtrAgt>

_________________
Honesty is the best policy.
Insanity is the best defence.
Back to top
View user's profile Send private message
fjb_saper
PostPosted: Wed Feb 08, 2017 12:13 pm    Post subject: Reply with quote

Grand High Poobah

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

The difference is that instead of having the information in 1 line, you'll see it in "pretty print" format over 4 lines with indentations...
A compliant XML parser should not make any difference between the two...
_________________
MQ & Broker admin
Back to top
View user's profile Send private message Send e-mail
hellozen123
PostPosted: Wed Feb 08, 2017 3:26 pm    Post subject: Reply with quote

Novice

Joined: 09 May 2016
Posts: 11

I got what all of you are saying, my final message is going to stored in oracle db as CLOB. Since '\r', '\t' are visible even when I open the XML in browser or xmlspy, I am worried that might cause any issuse later.

When I apply same process for the MQMD, XML structure gets generated with white spaces but \t' and '\n' are not visible when I open the XML in browser. Which is fine with me.

So not sure why MQMD and Body are getting treated differently.
Back to top
View user's profile Send private message
mqjeff
PostPosted: Thu Feb 09, 2017 5:06 am    Post subject: Reply with quote

Grand Master

Joined: 25 Jun 2008
Posts: 17447

The MQMD is not an XML document. Hard to understand how you are seeing it that way...

You should use something like amqsbcg(c) to actually look at the data in the message, and see if the whitespace is included in the message body.

If it is, then you need to determine if that's correct.

If only because

Code:
<NS2:DbtrAgt>\r\n\t\t\t\t\t<NS2:FinInstnId>\r\n\t\t\t\t\t\t<NS2:BICFI>FIAMQTSTXXX</NS2:BICFI>\r\n\t\t\t\t\t</NS2:FinInstnId>\r\n\t\t\t\t</NS2:DbtrAgt>


is not the same as

Code:
<NS2:DbtrAgt><NS2:FinInstnId><NS2:BICFI>FIAMQTSTXXX</NS2:BICFI></NS2:FinInstnId></NS2:DbtrAgt>


Since the second has mixed content and first doesn't...
_________________
chmod -R ugo-wx /
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 » How to convert Base64 payload in Monitoring event into XML
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.