Skip to content

Instantly share code, notes, and snippets.

View dfeist's full-sized avatar

Daniel Feist dfeist

  • MuleSoft
  • Wokingham, UK
View GitHub Profile
public interface MessageProcessor
{
MuleEvent process(MuleEvent event) throws MuleException;
}
public interface MessageSource
{
void setListener(MessageProcessor listener);
}
public interface InterceptingMessageProcessor extends MessageProcessor, MessageSource {}
public interface MessageRouter extends MessageProcessor
{
void addRoute(MessageProcessor processor);
void removeRoute(MessageProcessor processor);
}
<flow name="..">
- 0..1 Message Source(s)
- 1..n Message Processor(s)
- 0..1 Exception Handler
- 0..1 Threading Profile
</flow>
<flow>
<file:inbound-endpoint path="/myDirectory">
<file:filename-wildcard-filter pattern="*.xml"/>
</file:inbound-endpoint>
<xml:xslt-transformer file="transform-to-my-format.xslt"/>
<splitter expresion="xpath://order"/>
<!-- The following message processors will be invoked for each order in the xml file -->
<choice>
<when evaluator="xpath" expression="xpath:/order[@type='book']">
<component class="org.my.company.BookOrderService"/>
<flow name="orderProcessingFlow">
<inbound-endpoint ref="orderEndpoint"/>
<enricher target="#[variable:address]">
<outbound-endpoint ref="stateLookup"/>
</enricher>
<outbound-endpoint ref="orderStep2"/>
</flow>
<flow name="orderProcessingFlow">
<inbound-endpoint ref="orderEndpoint"/>
<enricher target="#[variable:address]">
<outbound-endpoint ref="stateLookup">
<expression-transformer evaluator="xpath" expression="/order/address/zip" />
</outbound-endpoint>
</enricher>
<outbound-endpoint ref="orderStep2"/>
</flow>
<flow name="orderProcessingFlow">
<inbound-endpoint ref="orderEndpoint"/>
<enricher>
   <authorizenet:authorization-and-capture cardNumber="#[xpath://order/cc/number]"
amount="#[xpath://order/amount"
expDate="#[xpath://order/cc/expDate]"/>
    <enrich target="#[variable:paymentValidated]" source="#[bean:responseCode]"/>
      <enrich target="#[variable:paymentMessage]" source="#[bean:responseReasonText]"/>
</enricher>
<outbound-endpoint ref="orderStep2"/>
<flow name="orderProcessingFlow">
<inbound-endpoint ref="orderEndpoint"/>
<enricher>
<authorizenet:authorize cardNumber="/order/cc/number" />
<enrich target="#[header:paymentValidated]" source="/authorizenet/authorization/@valid" />
<enrich target="#[header:paymentAuthCode]" source="/authorizenet/authorization/code"/>
</enricher>
<outbound-endpoint ref="orderStep2"/>
</flow