Using MuleSoft to perform some data changes. This is relatively new and Java language itself. After many Googling attempts, I thought I would ask here.
By dragging data from an 11G Oracle database, I have a database query that is being sent to a MuleMessage according to AnyPoint Studio, the DB query has a production list.
I can successfully call the Java component as an event. To see the bit data, it was lost on the way to remove the payload content. In fact, I would like to add prices to another list map for further processing.
Here's my DB:
select the name country, from test_customer a, test_country B, where a.id = b.id
I want to capture the name and the country, and want to put it in my map. The map then goes to the list of maps.
package org.mule.transformers; Import org.mule.api.MuleEventContext; Import org.mule.api.MuleMessage; Import org.mule.api.lifecycle.Callable; Import org.mule.api.transformer.TransformerException; Import org.mule.transformer.AbstractMessageTransformer; Import java.util.list; Import java.util.ArrayList; Import java.util.HashMap; Import java.util.Map; Public class myTransformer workable {@Override} Public Event On Call (MuleEventContext eventContext) applies {exception} {MuleMessage message = eventContext.getMessage (); Object payload = new object (); & Lt; Maps & LT; String, string & gt; & Gt; MyList = New Arrestist & lt; Maps & lt; String, string & gt; & Gt; (); // map list map & lt; String, string & gt; MyMap = New Hashmop & lt; String, string & gt; (); // Map holding string test; String Test 2; Payload = message.getPayload (); Test = message.getInboundProperty ("name"); Test2 = message.getInboundProperty ("Country"); MyMap.put (test, test2); MyList.add (myMap); Return my list; }}
I do not think there is a way to correctly reference the MuleMessage variable to drag this kind of data. The documentation is not useful, or I'm just reading the wrong stuff.
Do I have to use Mel to do this? Or can I use it to use some Java functions?
Any help would be appreciated!
The results of the query (if you are using a database connector) are in payload and in inbound properties If not you are searching the results in the wrong place "."
Maybe the result list & lt; Maps & lt; String, Object & gt; & Gt;
is in the format, so you should do something like this:
list & lt; Maps & lt; String, Object & gt; & Gt; Results = (list & lt; map & lt; string, object & gt; & gt;) message.getPayload (); Maps & lt; String, Object & gt; FirstRow = results.get (0); Test = firstRow.get ("name"); Test2 = firstRow.get ("Country");
However, you should debug your components and inspect what is the correct type of payload.
No comments:
Post a Comment