Author |
Message
|
fjb_saper |
Posted: Fri Oct 01, 2010 7:55 am Post subject: |
|
|
 Grand High Poobah
Joined: 18 Nov 2003 Posts: 20756 Location: LI,NY
|
zpat wrote: |
You might have to add a cast to ensure the string is the correct codepage
Quote: |
SET OutputRoot.BLOB.BLOB = CAST(InputRoot.BLOB.BLOB AS CHAR CCSID InputRoot.MQMD.CodedCharSetId); |
|
Are you making implicit cast here assigning a CHAR to the BLOB?
If you don't change the CCSID and ENCODING between input and output, it is ok to just assign the input BLOB to the output BLOB...  _________________ MQ & Broker admin |
|
Back to top |
|
 |
kimbert |
Posted: Fri Oct 01, 2010 12:31 pm Post subject: |
|
|
 Jedi Council
Joined: 29 Jul 2003 Posts: 5542 Location: Southampton
|
Quote: |
My problem here is, I don't know the structure of the MbElement tree, so I'm groping in the dark a bit. Does anyone know the correct route to navigate to my BLOB data? |
I do, but I'd rather teach you how to fish instead of throwing the fish at you. There are at least two well-known ways to find out the structure of the message tree.
a) attach the debugger and set a breakpoint after the MQInput node.
b) add a Trace node to the message flow and set the 'Pattern' property to '{Root}'. Then either take a user trace or else change the 'Destination' property to 'File' and provide a file path. |
|
Back to top |
|
 |
afielden |
Posted: Mon Oct 04, 2010 6:17 am Post subject: |
|
|
Novice
Joined: 30 Sep 2010 Posts: 10
|
Well thanks for the fishing lesson, but the interesting thing here is that if on the FileInput node, I set the 'Record detection' to 'Whole file', I was expecting to receive a single message containing the contents of the whole file. What I actually get is nothing!
However, if I set the record detection to 'delimited' by DOS/Unix line end, I receive separate messages (one for each line), and this time the message does contain the line contents as I expect.
Not sure what's going wrong with the whole file situation, but I'm happy now that I have a way of accessing the contents of my file.
I could also try using a custom delimiter at the end of the file which might combine the whole file into one message? |
|
Back to top |
|
 |
kimbert |
Posted: Mon Oct 04, 2010 6:26 am Post subject: |
|
|
 Jedi Council
Joined: 29 Jul 2003 Posts: 5542 Location: Southampton
|
Quote: |
What I actually get is nothing! |
Please define 'nothing'. Where are you looking, and what are you seeing there? |
|
Back to top |
|
 |
WMBDEV1 |
Posted: Mon Oct 04, 2010 6:28 am Post subject: |
|
|
Sentinel
Joined: 05 Mar 2009 Posts: 888 Location: UK
|
afielden wrote: |
What I actually get is nothing! |
Nothing after the Fileinput node or nothing in the final output?
How did you confirm this?
If theres data present after the fileinput node but not in the output then it'd be time to look at what your JCN is doing. |
|
Back to top |
|
 |
lancelotlinc |
Posted: Mon Oct 04, 2010 6:31 am Post subject: |
|
|
 Jedi Knight
Joined: 22 Mar 2010 Posts: 4941 Location: Bloomington, IL USA
|
You may get a different result if you turn off Transactionality on all nodes in the flow. (ie. Transaction mode = no). _________________ http://leanpub.com/IIB_Tips_and_Tricks
Save $20: Coupon Code: MQSERIES_READER |
|
Back to top |
|
 |
afielden |
Posted: Mon Oct 04, 2010 7:56 am Post subject: |
|
|
Novice
Joined: 30 Sep 2010 Posts: 10
|
Code: |
MbElement cursor = null;
cursor = message.getRootElement(); // Root element.
cursor = cursor.getFirstChild(); // Properties element.
cursor = cursor.getNextSibling(); // MQMD element.
cursor = cursor.getFirstChild(); // Parser element.
cursor = cursor.getNextSibling(); // Parser.Blob element.
byte[] msgBytes = ((byte[]) cursor.getValue());
|
By 'nothing', I mean that the element which I expect to contain the blob data returns a zero length byte array from getValue().
And Transactional mode is set to 'NO' on the FileInput node |
|
Back to top |
|
 |
lancelotlinc |
Posted: Mon Oct 04, 2010 7:59 am Post subject: |
|
|
 Jedi Knight
Joined: 22 Mar 2010 Posts: 4941 Location: Bloomington, IL USA
|
Create a sample message flow using MQInput node instead of FileInput and use my original source code example. The source code I provided will not work directly with a FileInput node. _________________ http://leanpub.com/IIB_Tips_and_Tricks
Save $20: Coupon Code: MQSERIES_READER |
|
Back to top |
|
 |
afielden |
Posted: Mon Oct 04, 2010 8:07 am Post subject: |
|
|
Novice
Joined: 30 Sep 2010 Posts: 10
|
lancelotlinc wrote: |
Create a sample message flow using MQInput node instead of FileInput and use my original source code example. The source code I provided will not work directly with a FileInput node. |
But the code does work if I change the FileInput record detection to 'delimited' |
|
Back to top |
|
 |
lancelotlinc |
Posted: Mon Oct 04, 2010 8:14 am Post subject: |
|
|
 Jedi Knight
Joined: 22 Mar 2010 Posts: 4941 Location: Bloomington, IL USA
|
1976 USA TV Commercial for Life Cereal.
11 yr old: "Hey mom bought this new cereal. Try it."
8 yr old: "I don't want to try it, you try it."
11 yr old: "Hey, I know, let's get Mikey. He'll eat anything!"
--
"He likes it, hey Mikey!@"
--
MQInput node. Try it, you'll like it. _________________ http://leanpub.com/IIB_Tips_and_Tricks
Save $20: Coupon Code: MQSERIES_READER |
|
Back to top |
|
 |
Vitor |
Posted: Mon Oct 04, 2010 8:22 am Post subject: |
|
|
 Grand High Poobah
Joined: 11 Nov 2005 Posts: 26093 Location: Texas, USA
|
afielden wrote: |
lancelotlinc wrote: |
Create a sample message flow using MQInput node instead of FileInput and use my original source code example. The source code I provided will not work directly with a FileInput node. |
But the code does work if I change the FileInput record detection to 'delimited' |
Then you need to attach a debugger (or better still take a user trace) to determine where the data has been placed by the File Input node.
To ensure full disclosure, I'm firmly on the "do it with 1 line of ESQL" side of the fence.  _________________ Honesty is the best policy.
Insanity is the best defence. |
|
Back to top |
|
 |
Vitor |
Posted: Mon Oct 04, 2010 8:25 am Post subject: |
|
|
 Grand High Poobah
Joined: 11 Nov 2005 Posts: 26093 Location: Texas, USA
|
lancelotlinc wrote: |
MQInput node. Try it, you'll like it. |
Possibly, but if the OP's requirement is to read a file explaining that he's completed the task but has a new requirement for the sender to re-engineer to use a WMQ message rather than a file might be tricky. Indeed, explaining why he's experimenting with WMQ could lead to awkward questions.
Of course, using a WMB flow to move a file from one place to another is a large sledgehammer on a very small nut. There's nothing in the thread to indicate why this is being done, or done in Java (transformations, log4j, etc, etc). _________________ Honesty is the best policy.
Insanity is the best defence. |
|
Back to top |
|
 |
zpat |
Posted: Mon Oct 04, 2010 11:49 pm Post subject: |
|
|
 Jedi Council
Joined: 19 May 2001 Posts: 5866 Location: UK
|
fjb_saper wrote: |
zpat wrote: |
You might have to add a cast to ensure the string is the correct codepage
Quote: |
SET OutputRoot.BLOB.BLOB = CAST(InputRoot.BLOB.BLOB AS CHAR CCSID InputRoot.MQMD.CodedCharSetId); |
|
Are you making implicit cast here assigning a CHAR to the BLOB?
If you don't change the CCSID and ENCODING between input and output, it is ok to just assign the input BLOB to the output BLOB...  |
I forget the exact reason for needing this CAST but there was one! |
|
Back to top |
|
 |
afielden |
Posted: Tue Oct 05, 2010 12:33 am Post subject: |
|
|
Novice
Joined: 30 Sep 2010 Posts: 10
|
Vitor wrote: |
lancelotlinc wrote: |
MQInput node. Try it, you'll like it. |
Of course, using a WMB flow to move a file from one place to another is a large sledgehammer on a very small nut. There's nothing in the thread to indicate why this is being done, or done in Java (transformations, log4j, etc, etc). |
Exactly!!
I didn't expect I would be required to explain this, as I tried to reduce my problem to its simplest form for clarity, but if you *really* want to know the background, here goes:-
The data file is produced by a legacy application which is used within the company. The requirement is to read this data file, pick out relevant bits of information, and transform it into XML. This XML then sent to a message queue, and the message is picked up by a new system intended to replace the old one.
There are many other legacy apps which will have the same procedure applied, so the basic problem was how to use WMB to read a file, access the data, and transform it into XML. The part I needed help on was reading the file and accessing the contents.
This has to be completed by the end of the week, hence my fairly obtuse questions, and the need for quick answers. I don't really have time to experiment and play around, even though I would like to. I also have very little experience with WMB (as you may have guessed) so I'm picking it up as I go along.
I KNOW that Webshpere Message Broker is not the ideal tool for this job. It is very much a large sledgehammer/nut situation. However, this product was selected early on in the project for some unknown reason, as I wasn't even working here at that time that decision was made.
So, to sum up for anyone else daft enough to want to try doing this - you have to set the record detection to 'delimited'. As to why 'whole file' has problems, well I'll leave that as an excercise for anyone with time/inclination to work it out. For now, I have an answer and can progress.
Thanks for your input everyone. |
|
Back to top |
|
 |
kimbert |
Posted: Tue Oct 05, 2010 1:36 am Post subject: |
|
|
 Jedi Council
Joined: 29 Jul 2003 Posts: 5542 Location: Southampton
|
Quote: |
The data file is produced by a legacy application which is used within the company. The requirement is to read this data file, pick out relevant bits of information, and transform it into XML. This XML then sent to a message queue, and the message is picked up by a new system intended to replace the old one.
There are many other legacy apps which will have the same procedure applied... |
You probably won't believe me, but that sounds like the kind of problem that WMB solves very well.
On the other hand, Vitor said:
Quote: |
using a WMB flow to move a file from one place to another is a large sledgehammer on a very small nut. |
Quite true - that would not be the sort of problem that requires WMB. But your problem is more complex than that. It involves parsing and transformation of the input file, and a change from file system to MQ.
Quote: |
the basic problem was how to use WMB to read a file, access the data, and transform it into XML |
That should be easy - it's a standard problem for WMB. Your problem is that you are trying to use WMB as a Java container in the mistaken belief that you will get the job done faster that way.
I still believe the best approach is:
- create a TDS message set to describe your file format. I can help with that.
- set Domain to 'MRM' on the input node, and set the Message Set/Message Type/Message Format properties to reference your TDS message set and its physical format.
- Forget Java. Insert one ordinary Compute node which has one line of ESQL, as follows:
Code: |
SET OutputRoot.XMLNSC.rootTag = InputRoot.MRM; |
Or you can continue to fight with the Java / BLOB solution if you like - I gave some good advice 4 days ago on how to make progress there. But I don't believe it's the right way, or that it will produce a good result for your business/client. |
|
Back to top |
|
 |
|