<flow name="datamappingFlow1" doc:name="datamappingFlow1">
<http:inbound-endpoint exchange-pattern="request-response" host="${hostname}" port="${port}" path="account" connector-ref="ConnectorWithoutMuleSession" doc:name="HTTP"/>
<jersey:resources doc:name="REST">
<component class="com.mycompany.qb.rest.AccountMappingService"/>
</jersey:resources>
<object-to-byte-array-transformer doc:name="Object to Byte Array"/>
<byte-array-to-object-transformer doc:name="Byte Array to Object"/>
<scatter-gather doc:name="upsert to db">
<flow-ref name="test1" doc:name="Flow Reference"></flow-ref>
<flow-ref name="test2" doc:name="Flow Reference"></flow-ref>
</scatter-gather>
</flow>
<flow name="test1" doc:name="test1">
<logger message="====Input deduction data is 1======#[payload]" level="INFO" doc:name="Logger"/>
<logger message="==== Input test1 data ======#[message.inboundProperties['City']]" level="INFO" doc:name="Logger"/>
<db:insert config-ref="Oracle_Configuration" doc:name="Database">
<db:parameterized-query><![CDATA[insert into test1(City)values(#[payload.City])]]></db:parameterized-query>
</db:insert>
</flow>
<flow name="test2" doc:name="test2">
<logger message="====Input deduction data is 2======#[payload]" level="INFO" doc:name="Logger"/>
<logger message="==== Input test2 data ======#[payload.City]" level="INFO" doc:name="Logger"/>
<db:insert config-ref="Oracle_Configuration" doc:name="Database">
<db:parameterized-query><![CDATA[insert into test2(City)values(#[payload.City])]]></db:parameterized-query>
</db:insert>
</flow>
Rest Component:
@Path("/")
public class AccountMappingService {
@POST
@Path("/mapping")
@Produces(MediaType.APPLICATION_JSON)
@Consumes(MediaType.APPLICATION_JSON)
public String dataMapping(@Payload String content){
log.info("Rest Content is==>\n"+content);
return content;
}
Input data:
{
"City":"SFO1"
}
Output:
====Input deduction data is 2======{
"City":"SFO1"
}
==== Input test1 data ======null
====Input deduction data is 1======{
"City":"SFO1"
}
==== Input test2 data ======null
why I am getting null values here?
object-to-byte-array-transformer
followed by abyte-array-to-object-transformer
? They are opposite transformers so having them both has a null effect (or an adverse one if the source payload is a stream, you may end up deserializing it for no reason). – David Dossot