Example of using Component Binding in Mule2

In my last Mule project we had to implement a situation that I would call a conversational pattern. Now one could consider almost all communication by messages between systems part of a conversation, but in this case I had the following situation:

  • I offer a message containing an order line to an application to add it to a certain order
  • I receive back a ‘response’ message with one of the following responses:
    • A. Order line is added to order
    • B. Order to add orderline to, is not found
    • C. Order status does not allow adding new orderline
    • D. Some other functional exception
  • Based on the response I had to react differently:
    • In case of situation A and D the conversation was over
    • In situation B and C however, I wanted to modify the original message that was sent with the orderline and resend it to the application.

  • The problem with this situation was that the original message was taken from a JMS queue and sent by HTTP to the application, so at the time I received the response from the HTTP endpoint and interpreted it, I didn’t have access to the original message anymore. So while thinking about the best way to solve this issue I was pointed by the Mule forum to use a ‘component binding’ for this. I wasn’t familiar with this functionality of Mule but it turned out to be exactly what I needed!
    Next are the most important pieces that should give you a good hint how to solve this if come across the same pattern. The part of the mule-config.xml where this conversation starts:

    <service name="OrderService">
        <vm:inbound-endpoint path="order-service"/>
          <vm:outbound-endpoint path="order-post-service" synchronous="true">
              <byte-array-to-string-transformer />
          <vm:outbound-endpoint path="process-response">
            <transformer ref="JaxbXmlToObject"/>

    What I do here (as usual with complex problems) is that I divided them in two less complex situations:

    1. the processing of the original message and combining of the original and the response message
    2. determine the response and react to that by altering the original message and resend it

    In the next to posts I will dive deeper into the details of each of these steps.

About Pascal Alma

Pascal is a senior software developer and architect. Pascal has been designing and building applications since 2001. He is particularly interested in Open Source toolstack (Mule, Spring Framework, JBoss) and technologies like Web Services, SOA and Cloud technologies. Lately he is having great fun by building iOS apps with Swift. Specialties: JEE AWS XML/XSD/XSLT Web Services/SOA Mule ESB/ WSO2 ESB Maven Cloud Technology Swift/ iOS
This entry was posted in Mule and tagged . Bookmark the permalink.