Author |
Message
|
akil |
Posted: Thu Jun 26, 2014 4:44 am Post subject: Serialise a CSV record into a database column |
|
|
 Partisan
Joined: 27 May 2014 Posts: 338 Location: Mumbai
|
Hi
We have a DFDL XSD created for an incoming file, we use the FileInput to read the file. The record is then converted to an XML and an API call call is made to a server.
There is also a requirement to log the entire record, in a column of an audit table - column is big enough to hold the record. Is there an easy way to do this via the Mapping Node , or is there any alternate way ?
Regards |
|
Back to top |
|
 |
mqjeff |
Posted: Thu Jun 26, 2014 5:47 am Post subject: |
|
|
Grand Master
Joined: 25 Jun 2008 Posts: 17447
|
|
Back to top |
|
 |
akil |
Posted: Thu Jun 26, 2014 8:42 pm Post subject: |
|
|
 Partisan
Joined: 27 May 2014 Posts: 338 Location: Mumbai
|
Hi,
Is there any other alternative to Record & Replay ? This is an already available custom built table that's used by many other systems and it needs to be used to store records from the IIB as well.
In the developer studio, we create a logical instance and then serialise the record, is something similar available during runtime? To serialise a record that's already parsed in the JavaComputeNode or equivalent?
Regards |
|
Back to top |
|
 |
smdavies99 |
Posted: Thu Jun 26, 2014 9:42 pm Post subject: |
|
|
 Jedi Council
Joined: 10 Feb 2003 Posts: 6076 Location: Somewhere over the Rainbow this side of Never-never land.
|
There is nothing to stop you from writing your own code that serializes the message and puts it into your own table.
A couple of years ago I had to create a solution where messages were grouped by an identified extracted from within the messages and then later on combine all them into a single message. Yes this was a collector node replacement solution because there could be 1 messages or 20 messages in a collection.
The whole job tool less than two days including deconstructing the collection and creating a composite output message.
the step where you serialize a message and put it into a table is a very useful bit of code to have in your tooklit. I know that mqjeff is a fan of Record/replay but there are many cases where it is not appropriate simply because you have to integrate your solution with existing tables etc.
If you are logging a message like this, the chances of needing to replay it are IMHO (for what it is worth) very small indeed.
The biggest headache I have found is that the DBA's have not planned for the logging DB to get really, really big when you start this up for real. One site decided to restrict our logs to 1 day rater than increase the DB size. The Auditors soon put a stop to that silliness. _________________ 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 |
|
 |
martinb |
Posted: Fri Jun 27, 2014 1:10 am Post subject: |
|
|
Master
Joined: 09 Nov 2006 Posts: 210 Location: UK
|
|
Back to top |
|
 |
akil |
Posted: Fri Jun 27, 2014 1:57 am Post subject: |
|
|
 Partisan
Joined: 27 May 2014 Posts: 338 Location: Mumbai
|
I have used the Mapping done for the DB operations, What I have been able to do is 'map' the input record fields to database table fields via a move or some other transform.
I am however unable to figure out how to use the Mapping Node to get the serialised record so that I can assign it to the appropriate column.
Even for ESQL or Java, I am not sure what function/method to use to serialise the parsed logical record.. Can you point me to the right doc/method? |
|
Back to top |
|
 |
martinb |
Posted: Fri Jun 27, 2014 2:23 am Post subject: |
|
|
Master
Joined: 09 Nov 2006 Posts: 210 Location: UK
|
Quote: |
I am however unable to figure out how to use the Mapping Node to get the serialised record so that I can assign it to the appropriate column.
Even for ESQL or Java, I am not sure what function/method to use to serialise the parsed logical record |
For Java look at
Code: |
MbElement.toBitstream() |
For ESQL look at
The Graphical Data Mapper does not provide a transform to serialise elements.
However you can use a Custom Java transform that enables you to call out to a method taking the MbElement as input and returning the serialised record(s) as abyte array, or string. |
|
Back to top |
|
 |
akil |
Posted: Sun Jun 29, 2014 11:27 am Post subject: |
|
|
 Partisan
Joined: 27 May 2014 Posts: 338 Location: Mumbai
|
Hi
I am not able to figure out how to pass the record tree structure to the ESQL function for use with the ASBITSTREAM function ..
In the XPath expression box, i select $record, but this does not work, since the ROW dataType isn't allowed for ESQL procedures that are used in the map.
The help says that only scalar parameters are supported : http://www-01.ibm.com/support/knowledgecenter/#!/SSMKHH_9.0.0/com.ibm.etools.mft.doc/br28672_.htm .
How do I proceed? _________________ Regards |
|
Back to top |
|
 |
martinb |
Posted: Sun Jun 29, 2014 2:45 pm Post subject: |
|
|
Master
Joined: 09 Nov 2006 Posts: 210 Location: UK
|
You could create a Java method taking the record as a MbElement input param, and return the byte[] from calling MbElement.toBitstream(). |
|
Back to top |
|
 |
akil |
Posted: Sun Jun 29, 2014 10:37 pm Post subject: |
|
|
 Partisan
Joined: 27 May 2014 Posts: 338 Location: Mumbai
|
Hi
I add a ESQL compute node in the flow, where I used the ASBITSTREAM , storing the output in the InputLocalEnvironment.Variables folder; created an XSD representing this variable, which I subsequently used in the Mapping Node to cast first and then move the data. This worked.!
I will try the Java method as you mentioned as soon as I can and let you know.
Thank you. _________________ Regards |
|
Back to top |
|
 |
|