Monday 1 October 2018

Scatter-Gather behavior.



sends the same message to multiple message processors or multiple end points.
The routing message processor Scatter-Gather sends a request message to multiple targets concurrently. It collects the responses from all routes, and aggregates them into a single message, All payloads are combined to gather.

This follow Aggregator strategy && Multicast pattern





The Scatter-Gather router sends a message for concurrent processing to all configured routes. The thread executing the flow that owns the router waits until all routes complete or time out.
If there are no failures, Mule aggregates the results from each of the routes into a message collection (MessageCollection class). Failure in one route does not stop the Scatter-Gather from sending messages to its other configured routes, so it is possible that many, or all routes may fail concurrently.
By default, if any route fails, Scatter-Gather performs the following actions:
·         sets the exception payload accordingly for each route
·         throws a CompositeRoutingException, which maps each exception to its corresponding route using a sequential route ID.
By default, if any route fails, Scatter-Gather performs the following actions: sets the exception payload accordingly for each route throws a CompositeRoutingException, which maps each exception to its corresponding route using a sequential route ID Catching the CompositeRoutingException allows you to gather information on all failed routes.

MEL on Payloads

[!(payload is org.mule.transport.NullPayload)] For null check.     
#[payload != null && ((payload instanceof org.mule.transport.NullPayload) == false)]
This NullPayLoad class returning always false even payload is null.

 



Mule Object Stores


An object store is a facility for storing objects in Mule. Mule uses object stores whenever it needs data to persist for later retrieval. Internally, Mule uses object stores in various filters, routers, and other message processors that need to store state between messages. In most cases, Mule creates and manages object stores automatically, so no user configuration is necessary.

Use Cases

In most cases, Mule creates and manages object stores for you, so no configuration is necessary. However, you may explicitly configure an object store in the following cases:
·         When configuring an idempotent message filter or until a successful scope occurs.
·         When configuring a custom component that must use an object store to persist information.
·         When storing or retrieving information from a Mule flow through the Object Store module, available as an extension.
Mule provides two types of object stores:
·         In-memory store – Prior to Mule 3.5.0, in-memory store was the default. As of Mule 3.5.0, persistent store is the default. For more information, see "Object Stores and Clustering" in the Cache Scope document.
·         Persistent store – Mule persists data when an object store is explicitly configured to be persistent. Mule creates a default persistent store in the file system.

Adding Object Store Components

1.     Install the Object Store component available in Anypoint Exchange

This starts an installation Wizard. Select "ObjectStore Connector (Mule 3.6+)", click "Next", then "Next" again. Accept the terms of the license agreement and click "Finish".

Operation
Description
All keys
Returns a list of all the keys in the object store.
Contains
Checks whether the object store contains the given key.
Dual store
Stores a value using key, and also store key using value.
Remove
Remove the object for the respective key.
Retrieve
Retrieve an object from the object store and make it available in the specified property scope of a Mule Message.
Retrieve store
Retrieve and Store in the same operation.
Retrieve with lock
Retrieve the given object with lock from the object store and make it available in the specified property scope of a Mule Message.
Store
Stores an object in the object store.


 

Cloudhub: In application data we can see object store in bellow.