0

I created a Mule app that takes data from some json feeds and transforms them with a custom transformer I made to create a class.

I have a parent class Event and two subclasses that inherit from it: Event1 and Event2. The return class of my custom transformer (auto-transformer) is Event.

I am using a choice flow control component so when a certain data value is reached for the Event1 a mail is sent, and when a certain data value is reached for Event2 a different mail is sent.

In Event1 I defined the method getThisData() and in Event2 I defined getThatData().

When I use #[payload.getThisData()] everything works, the value is checked, and the mail is sent if the condition is true.

However, for the Event2 branch it doesn't work. It gives me an error. It tries to look for the getThatData() in the Event1 class, and obviously it does not exist.

How can I fix this? How can I get the value from getThatData()?

I use Mule Studio.

<processor-chain>
    <auto-transformer returnClass="events.Event" name="JSONToEvent"></auto-transformer>
    <logger level="INFO" doc:name="Logger"/>
    <choice doc:name="Choice">
        <when expression="#[payload.getThisData()&gt;1200]">
            <twitter:update-status config-ref="Twitter" status="Value reached"/>
        </when>
        <when expression="#[payload.getThatData()&gt;11]">
            <twitter:update-status config-ref="Twitter" status="The other value reached"/>
        </when>
        <otherwise>
            <twitter:update-status config-ref="Twitter" status="#[payload]" doc:name="Normal"/>
        </otherwise>
    </choice>
</processor-chain>
dabadaba
  • 9,064
  • 21
  • 85
  • 155

1 Answers1

0

You could try checking the payload class in the expression:

#[payload instanceof events.Event2 &amp;&amp; payload.getThatData()&gt;11]
Anton Kupias
  • 3,945
  • 3
  • 16
  • 20
  • Now it says org.mule.api.routing.RoutePathNotFoundException: Can't process message because no route has been found matching any filter and no default route is defined. Failed to route event via endpoint: ChoiceRouter [flow-construct=flow1, started=true]. Message payload is of type: Event1 – dabadaba Apr 12 '14 at 16:24
  • This error means you have no `otherwise` branch. Did you remove it, or do you have a typo somewhere? – Anton Kupias Apr 12 '14 at 18:48