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 IT consultant and has been working in IT since 1997. He is monitoring the latest development in new technologies (Mobile, Cloud, Big Data) closely and particularly interested in Java open source tool stacks, cloud related technologies like AWS and mobile development like building iOS apps with Swift. Specialties: Java/JEE/Spring Amazon AWS API/REST Big Data Continuous Delivery Swift/iOS
This entry was posted in Mule and tagged . Bookmark the permalink.