Understanding Orchestration Using Mule

Orchestration is how Mule facilitates the process of moving data through a Mule implementation based on flow. Orchestration can be seen as combining service calls to create higher-level, more useful composite services, and implies implementing business-level processes combining business-specific services across applications and information systems.

Orchestration and Flow

Orchestration involves decoupling point-to-point integration in favor of chains of messages sent to endpoints that can be reused or changed as systems or business needs change. It involves moving beyond patterns into a service-based framework, where you wrap multiple components with endpoints to decouple them from protocols and routing requirements, enabling multiple services to work as one when implementation requirements demand it. Some common use cases that flow easily orchestrates include simple integration, scheduled data processing, connecting cloud and on-premise applications, and event processing where multiple services must be composed and operate simultaneously.

How Flow Enables Implementation of Orchestration

Flow enables new ways to orchestrate service mediation—for example, you can combine an arbitrary number of endpoints, routers, transformers, and components that work in concert to achieve implementation requirements. Flow enables you to orchestrate new forms of data movement based on flow-specific routers. Orchestration enables you to create and reuse subflows, chain together multiple components in one flow, and integrate endpoints or connectors anywhere in a flow.

When to Use Orchestration

You use orchestration when you need to combine existing services to meet business requirements. For example, use orchestration when you’re adding a new employee who needs to be entered in both the payroll system and the HR system. In another example of when to use orchestration, you might use it when you accept an order, make sure the order is in the inventory system, use the credit check system to ensure you trust the customer’s credit, then put the order in the billing system, and finally, put the order in the shipping system.

An Example of Orchestration

The following example of orchestration uses a flow to accept a book order in an XML file and transform the file’s contents into a standard format that contains one or more specific orders. Next, the orders are split out to be processed separately, and any non-book orders are filtered out. Now two services are called: one to check whether the book is in our inventory, and another to create a customer order. This is both e-mailed to the customer and stored in a database. If anything in this process fails, the message is placed in a JMS queue of failed orders, where it can be checked, any error fixed, and finally resubmitted.

    <file:inbound-endpoint path="/myDirectory">
        <file:filename-filter name="*.xml"/>
    <xml:xslt-transformer xsl-file="createBbookOrdersTransformation.xsl"/>
    <splitter expression="xpath://order"/>
    <!-- The following message processors will be invoked for each order in the xml file -->
    <expression-filter expression="xpath://order[@type='book']"/>
    <component class=""/>
    <component class=""/>
    <smtp:outbound-endpoint subject="Order Confirmation" to="#{xpath://customer/email]"/>
    <jdbc:outbound-endpoint queryKey="storeOrder"/>
        <jms:outbound-endpoint queue="failedOrders"/>