Friday, March 11, 2016

MuleSoft Application Development With JMS Queue Explained: Part One

Introduction

This article has two parts. This is the first part. In this part, I will demonstrate how to setup the basic flow, which involves jms inbound and outpoint points. In the mule flow, JMS the outbound-endpoint is the message producer. On the other hand, the JMS inbound-endpoint is the message consumer. The key concepts covered in this article are the following:
  • How to set JMS properties in Mule flow
  • How to configure ActiveMQ connectors
  • How to configure JMS inbound- and outbound-endpoints
For JMS, Mule support one-way and request-response exchange patterns. This part covers the one-way exchange pattern. The next part will cover the request response pattern.

ActiveMQ Connector Setup

In the Mule integration with JMS brokers like ActiveMQ, the first step is to configure the JMS connector as show the following figure.
The general tab as shown in the next figure has the connector name, brokerurl, and access to ActiveMQ credentials.
You should also pay attention to the Advanced tab. In this tab, you can configure JNDI, durable consumer, or define the PERSISTENT delivery mode, etc.. Mule has default values for all these advanced configuration.
If you want to change the delivery mode from NON-PERSISTENT to PERSISTENT, you will need to check the persistence delivery. By default, mule create 4 consumers for each queue, you may adjust that value as well accordingly.

Configure The Mule Flow With One-Way Exchange Pattern

The main purpose of this basic configuration is to demonstrate how to build mule flows to publish and consume jms message. Another point I want to make is that how Mule set the outpond properties to JMS properties.

The Use Case

  • A client will invoke a RESTful service
  • The client will send a JSON Payload
  • ESB will perform the following:
    1. transform the json to java LinkedHashMap
    2. set JMS header source_id
    3. publish the message to a queue
  • A second flow: Process_Order_Flow listen on the order.queue
  • log the payload
  • send the payload to another queue: order.special.queue The json example is provided as the following:
    { "name"   : "John Smith",
      "sku"    : "20223",
      "price"  : 23.95,
      "shipTo" : { "name" : "Jane Smith",
                   "address" : "123 Maple Street",
                   "city" : "Pretendville",
                   "state" : "NY",
                   "zip"   : "12345" },
      "billTo" : { "name" : "John Smith",
                   "address" : "123 Maple Street",
                   "city" : "Pretendville",
                   "state" : "NY",
                   "zip"   : "12345" }
    }
    

    Configure The Mule Flow For One-Way

    The Mule Flow Diagram is shown as the following:
    The xml configuration for the flow is listed as the following:
    
    
    
        
            
            
                
            
            
            
            	
            
            
        
        
        
            
    			
            
            
            
        
    
    
    

    Message Selector

    We can add jms message selector to either jms inbound-endpoint or outbound-endpoint as shown below. However, it only takes effects on the inbound-endpoint.
            
            	
            
    
    Also, noted that source_id is a JMS message property. Mule copies all the outbound properties to the JMS message properties. The inbound properties are not automatically copied to the outbound properties when the flow crosses the transport boundary. You may be tempted to reply the ATG in the message selector configuration. Unfortunately, this cannot be done, because this is pre-defined in the ActiveMQ broker configuration.

3 comments:

  1. I really appreciate for your efforts to make things easy to understand. I was really many students struggling to understand certain concepts but you made it clear and help me bring back my confidence onMulesoft Online Training Hyderabad

    ReplyDelete
  2. I am really enjoying reading your well written articles. It looks like you spend a lot of effort and time on your blog. I have bookmarked it and I am looking forward to reading new articles. Keep up the good work..

    Mulesoft online course

    ReplyDelete
  3. For Mulesoft ESB Real Time Training Contact Me at muleesbtrainer@gmail.com and 9985333565

    I will provide real time online training at low price for demo videos visit my youtube channel.
    http://youtube.com/channel/UC1lFGEh4xAPJnIm4FWmQBfA

    ReplyDelete

Anypoint Studio Error: The project is missing Munit lIbrary to run tests

Anypoint Studio 7.9 has a bug. Even if we following the article: https://help.mulesoft.com/s/article/The-project-is-missing-MUnit-libraries-...