Author |
Message
|
bshankar |
Posted: Mon Jul 28, 2008 1:13 am Post subject: How to read a file from esql |
|
|
Novice
Joined: 14 Jul 2008 Posts: 16
|
Hi friends,
I am using WMB6.1 and I am using message set to take care of validations what ever i have specified in the xsd. but i need to take care of some more validations like reading a file and comparing the field value with the values contain the file.
So i'm writing esql code for that . can anyone tell me how to read the file( it is a .ini file) and hold the values in a variable.
thanks
bhargav |
|
Back to top |
|
 |
Gaya3 |
Posted: Mon Jul 28, 2008 1:23 am Post subject: |
|
|
 Jedi
Joined: 12 Sep 2006 Posts: 2493 Location: Boston, US
|
use java compute node, for the same, it can be done pretty simpler and faster in this case _________________ Regards
Gayathri
-----------------------------------------------
Do Something Before you Die |
|
Back to top |
|
 |
bshankar |
Posted: Mon Jul 28, 2008 1:35 am Post subject: |
|
|
Novice
Joined: 14 Jul 2008 Posts: 16
|
I have tried using javacompute node . wmb is creating some tamplate code called evaluate method. i have written some code as part of that method. but it is not executing the java code and just skipping it.
please tell me do i need to make any settings to enable my code? if so . what are they?
thanks
Bhargav |
|
Back to top |
|
 |
AkankshA |
Posted: Mon Jul 28, 2008 1:40 am Post subject: |
|
|
 Grand Master
Joined: 12 Jan 2006 Posts: 1494 Location: Singapore
|
Bhargav,
Can u pls paste the code you have written in JCN to red the file... _________________ Cheers |
|
Back to top |
|
 |
bshankar |
Posted: Mon Jul 28, 2008 1:50 am Post subject: |
|
|
Novice
Joined: 14 Jul 2008 Posts: 16
|
String str = assembly.toString();
System.out.println(str); |
|
Back to top |
|
 |
bshankar |
Posted: Mon Jul 28, 2008 1:51 am Post subject: |
|
|
Novice
Joined: 14 Jul 2008 Posts: 16
|
it is not even printing system.out.println stmt.
i have tried like this also
System.out.println("bhargav"); |
|
Back to top |
|
 |
zpat |
Posted: Mon Jul 28, 2008 2:10 am Post subject: |
|
|
 Jedi Council
Joined: 19 May 2001 Posts: 5866 Location: UK
|
Don't use Java nodes unless there is really no alternative - otherwise you are turning the broker into just another WAS.
I would have thought these values from the file should be stored in the broker database for use within message flows.
You could use the new WMB 6.1 fileinput node to process the files and store the values into the database. |
|
Back to top |
|
 |
AkankshA |
Posted: Mon Jul 28, 2008 2:13 am Post subject: |
|
|
 Grand Master
Joined: 12 Jan 2006 Posts: 1494 Location: Singapore
|
|
Back to top |
|
 |
Gaya3 |
Posted: Mon Jul 28, 2008 2:24 am Post subject: |
|
|
 Jedi
Joined: 12 Sep 2006 Posts: 2493 Location: Boston, US
|
i agree with ZPAT use a fileinput node, get the file and process the same. _________________ Regards
Gayathri
-----------------------------------------------
Do Something Before you Die |
|
Back to top |
|
 |
bshankar |
Posted: Mon Jul 28, 2008 3:07 am Post subject: |
|
|
Novice
Joined: 14 Jul 2008 Posts: 16
|
I tried using Inputfile node just now. i'm not knowing how to get the message sending by fileinput node in compute node.
i connected my flow like this
fileinput-----compute-----mqoutput
mqinput-----/ |
|
Back to top |
|
 |
zpat |
Posted: Mon Jul 28, 2008 6:57 am Post subject: |
|
|
 Jedi Council
Joined: 19 May 2001 Posts: 5866 Location: UK
|
File input node is not meant for reading files repeatedly during message flows. It is meant for starting a flow when a file arrives.
Like I said, set one of these up to load the file contents into a database. It only needs to run once and when the file changes. Or you can load it using any other file -> database method that you know how to use.
Then use the database as you would expect during a message flow for accesing reference data in a table in a compute node.
If you are trying to read a file each time a message arrives in order to get reference data from the file, then you are not designing your message flow properly - use a database table for reference data.
You need to understand how to use the message broker properly. Do not resort to Java due to a lack of training in WMB as this would create an unmaintainable legacy of unnecessary code. |
|
Back to top |
|
 |
bshankar |
Posted: Tue Jul 29, 2008 1:09 am Post subject: |
|
|
Novice
Joined: 14 Jul 2008 Posts: 16
|
I'll tell you my actual problem..
I am validating xml using message set it is validation properly and i need to take care of the validations which are not defined in the xsd.
one of the validation is reading the coutry list from the file( which contains 500 contry codes) and checking the whether <country> tag of incoming xml holding that value ( one of the value from the list of countires available in the file). this is my actual problem
can anybody tell me the correct solution
thanks in advance
bhargav |
|
Back to top |
|
 |
zpat |
Posted: Tue Jul 29, 2008 1:12 am Post subject: |
|
|
 Jedi Council
Joined: 19 May 2001 Posts: 5866 Location: UK
|
Once again; load a database table with the reference data.
Look up the value in the table in a compute node to validate the message field. |
|
Back to top |
|
 |
bshankar |
Posted: Tue Jul 29, 2008 1:32 am Post subject: |
|
|
Novice
Joined: 14 Jul 2008 Posts: 16
|
zpat,
I am not getting ur suggestion may be this is because of i'm new to WMB. are you asking me to read the file content from fileinput node and store it in database?
If so i have following problems.
1. I am not knowing how to get the message which is read by the fileinput node
2. is there any constant which represents the file in esql?
3. and in fileinput node properties it has been set blob domain by default. I guess i will get the blob object as instance of the file is it right? 4. how to read that blob object?
5. is there any predifined variable which holds this blob object?
|
|
Back to top |
|
 |
AkankshA |
Posted: Tue Jul 29, 2008 2:30 am Post subject: |
|
|
 Grand Master
Joined: 12 Jan 2006 Posts: 1494 Location: Singapore
|
Quote: |
I am not getting ur suggestion may be this is because of i'm new to WMB. are you asking me to read the file content from fileinput node and store it in database? |
Yes... You need to make sure that the flow which inserts the data in database is run(with updated file) everytime the file is updated..
1. I am not knowing how to get the message which is read by the fileinput node
Have a look at the help of v6.1 to get more info about file input...
2. is there any constant which represents the file in esql?
Not to my knowledge..
3. and in fileinput node properties it has been set blob domain by default. I guess i will get the blob object as instance of the file is it right?
you ll get your file content as blob and later you can format it the way u want..
4. how to read that blob object?
Hint : ASBITSTREAM
5. is there any predifined variable which holds this blob object?
i dint get this one.. _________________ Cheers |
|
Back to top |
|
 |
|