Mule if flowVar used in Dataweave Transformer payload converted to Map -


i have issue mule dataweave transformer getting error, occurs if :-

  1. an enricher present wrapping json:json-to-object-transformer

     <enricher target="#[flowvars.myvar]" doc:name="message enricher">      <json:json-to-object-transformer returnclass="java.util.hashmap" doc:name="json object"/> </enricher> 
  2. a flowvar involved in dataweave transformer

the exception occurs on 2nd dataweave :-

error 2017-08-15 09:09:52,239 [amqpreceiver.02] org.mule.exception.rollbackmessagingexceptionstrategy:  ******************************************************************************** message               : exception while executing:  {bar=1, foo=0}  ^ unexpected character 'b' @ index 1 (line 1, position 2), expected '"' payload               : com.mulesoft.weave.reader.bytearrayseekablestream@39e7a0d3 element               : /subscribe-to-changeflow4/processors/4 @ voa-009-mule-authorisation-search-api:test3.xml:58 (transform message) element xml           : <dw:transform-message doc:name="transform message">                         <dw:input-payload mimetype="application/json"></dw:input-payload>                         <dw:set-payload>%dw 1.0%output application/json---{field1: payload.foo,field2: payload.bar,field3: flowvars.myflowvar}</dw:set-payload>                         </dw:transform-message> -------------------------------------------------------------------------------- root exception stack trace: com.mulesoft.weave.reader.json.jsonreaderexception: unexpected character 'b' @ index 1 (line 1, position 2), expected '"'     @ com.mulesoft.weave.reader.json.jsontokenizer.fail(jsontokenizer.scala:193)     @ com.mulesoft.weave.reader.json.jsontokenizer.require(jsontokenizer.scala:190)     @ com.mulesoft.weave.reader.json.jsontokenizer.readstring(jsontokenizer.scala:74)     @ com.mulesoft.weave.reader.json.jsontokenizer.readobjectmembers(jsontokenizer.scala:146)     @ com.mulesoft.weave.reader.json.jsontokenizer.com$mulesoft$weave$reader$json$jsontokenizer$$readobject(jsontokenizer.scala:140)     @ com.mulesoft.weave.reader.json.jsontokenizer$$anonfun$readvalue$1.apply$mcv$sp(jsontokenizer.scala:37) 

what happens flowvar added 2nd data weave, payload seems show map rather json.

  • the enricher nested json-to-object-transformer required take payload , allow json accessed. if enricher removed works fine
  • the seek(0) required reset stream after json-to-object-transformer answered in last question
  • if flowvar removed 2nd dataweave works fine

test case

  <flow name="subscribe-to-changeflow4" processingstrategy="synchronous">          <amqp:inbound-endpoint numberofchannels="1" ref="authorisationchangequeuedef4" responsetimeout="10000" doc:name="authorisation-change-consumer" />          <dw:transform-message doc:name="transform message">         <dw:set-payload> <![cdata[%dw 1.0 %output application/json --- {     foo:0,     bar:1 }]]>         </dw:set-payload>     </dw:transform-message>      <enricher target="#[flowvars.myvar]" doc:name="message enricher">          <json:json-to-object-transformer returnclass="java.util.hashmap" doc:name="json object"/>     </enricher>      <expression-component doc:name="expression">         <![cdata[payload.seek(0);]]>     </expression-component>      <set-variable variablename="myflowvar" value="1234" doc:name="variable" />      <dw:transform-message doc:name="transform message">         <dw:input-payload mimetype="application/json"/>         <dw:set-payload> <![cdata[%dw 1.0 %output application/json --- {        field1: payload.foo,     field2: payload.bar,     field3: flowvars.myflowvar } ]]>          </dw:set-payload>     </dw:transform-message>      <logger  level="info" message="#[message.payloadas(java.lang.string)]" doc:name="logger "/>       </flow> 

this bug in mule , can raise in mule jira

which mule runtime version using?

i tested locally , found issue mule runtime 3.8.0 , mule runtime 3.8.1: enter image description here

but worked fine mule runtime 3.8.2 , mule 3.8.5
tested mule 3.7.3 locally , worked fine below:-

enter image description here


Comments

Popular posts from this blog

android - InAppBilling registering BroadcastReceiver in AndroidManifest -

python Tkinter Capturing keyboard events save as one single string -

sql server - Why does Linq-to-SQL add unnecessary COUNT()? -