Resequence Message Store
The Resequence Message Store is used to store a stream of related but out-of-sequence messages to put them back into the correct order. It collects and re-orders the stored messages based on a defined sequence number derived from some part of the message, so that they can be published to the output channel in a specific order. This is advantageous specially when the order of message delivery is important to avoid some messages arriving earlier than others.
The resequencing store is an extension of the existing JDBC-based message store. Hence, it inherits most of its properties from the JDBC Message Store.
UI Configuration
In the WSO2 ESB Management Console, click Main, click Message Stores in the Service Bus menu, and then click Resequence Message Store, to configure it as follows.
Enter the configuration details in the below screen.
When you add a Resequence Message Store, it is required to specify values for the following:
- Name: A unique name for the RabbitMQ message store.Â
- Database Table:Â Table name of the database in which, messages will be stored.
- Connection Information: If the database is connected via a Carbon datasource or via a connection pool.
- Driver:Â The class name of the database driver.
- Url: URL of the database.
- User:Â The username to access the database.
- Password:Â The password to access the database.
- Resequence Timeout (Seconds):Â The time the Message Processor waits for a message, which is missing to reorder them based on a specified order.
- Sequence ID Path:Â The path from which, the Store identifies the sequence ID from the message content.
The following is a sample ESB configuration of the Resequence Message Store.
<?xml version="1.0" encoding="UTF-8"?> <messageStore xmlns="http://ws.apache.org/ns/synapse" class="org.apache.synapse.message.store.impl.resequencer.ResequenceMessageStore" name="RStore"> <parameter name="store.resequence.timeout">-1</parameter> <parameter name="store.producer.guaranteed.delivery.enable">false</parameter> <parameter name="store.failover.message.store.name">RStore</parameter> <parameter xmlns:m0="http://services.samples" name="store.resequence.id.path" expression="substring-after(//m0:placeOrder/m0:order/m0:symbol,'-')"/> <parameter name="store.jdbc.password">root</parameter> <parameter name="store.jdbc.driver">com.mysql.jdbc.Driver</parameter> <parameter name="store.jdbc.username">root</parameter> <parameter name="store.jdbc.connection.url">jdbc:mysql://localhost:3306/resequenceDB</parameter> <parameter name="store.jdbc.table">tbl_resequence</parameter> </messageStore>
The following are the properties related to the Resequence Message Store.Â
Property Name | Description | Required | Possible Values |
---|---|---|---|
store.resequence.timeout | The time the Processor waits for a message, which is missing to reorder them based on a specified order. If the current message sequence is 3, its predecessor would be 2 and the successor would be 4, and thereby, if 4 is not present, then there is a gap in the sequence. Therefore, the processor waits until the specified set time-out exceeds, and selects the next minimum sequence ID available as the predecessor. However, the time-out will be a rough estimate. The durations could vary depending on the load of the machine. | Yes | Specify a positive integer for the count and the timeout in seconds. If you specify the count as -1, then the processor will wait indefinitely until the correct sequence ID is present to fill the gap. |
store.producer.guaranteed.delivery.enable | Whether you want to enable guaranteed delivery or not. For more information, see Guaranteed Delivery with Failover Message Store and Scheduled Failover Message Forwarding Processor. | No | True/False |
store.failover.message.store.name | The name of the Message Store used if the original message store fails. For more information, see Guaranteed Delivery with Failover Message Store and Scheduled Failover Message Forwarding Processor. | No | An appropriate String value |
store.resequence.id.path | The path from which, the Store identifies the sequence ID from the message content. The path could be either XPath or JSON. You can specify it in the expression field. Â | Yes | Set a positive integer as the sequence ID. The store expects the sequence ID to start from 1. |
store.jdbc.password | The password to access the database. | No | An appropriate String value |
store.jdbc.driver | The class name of the database driver. | Yes | An appropriate String value |
store.jdbc.username | The username to access the database. | Yes | An appropriate String value |
store.jdbc.connection.url | The database URL. | Yes | An appropriate String value of a URL. |
store.jdbc.table | Table name of the database in which, messages will be stored. | Yes | An appropriate String value |
For more information on its usage, go to Resequencer Pattern in the EIP Guide.