Oracle Mediator Resequencer

Oracle Mediator Resequencer

Oracle Mediator Resequencer:

Please find all details regarding Oracle Mediator Resequencer being used in SOA and AIA applications.

A Resequencer is used to rearrange a stream of related but out-of-sequence messages back into order. It sequences the incoming messages that arrive in a random order and then send them to the target services in an orderly manner. The sequencing is done based on the sequencing strategy selected.

The Mediator Resequencer is the component of the Oracle SOA Suite designed to implement in-order transaction processing, eliminating the need for custom development.

The Resequencer performs single threaded asynchronous processing based on groups. Transactions for each group are processed single threaded in sequence and groups are processed in parallel. The result is higher throughput than a straight single threaded implementation. The Resequencer can be used to guarantee processing in the order that transactions are received from the source or used to order transactions based on defined Groups and Sequence IDs.

For the resequencer to work we need to have 2 values in the source payload. The first one is a sequenceID, and the next one is a groupdID. The sequenceID will be used as identifier for the message itself. The groupID will be used to group the messages in which the resequencer will rearrange the messages based on the sequenceID. Different groups will have seperate processing, so they won’t have any influence on each other.

The mediator supplies us 3 types of resequencers:

  • Standard Resequencer
  • FIFO Resequencer
  • BestEffort Resequencer

The Oracle Mediator supports three patterns for resequencing:

  1. Standard– Processes transactions contiguously within a Group, based on a defined Group and Sequence ID.  Groups are processed in parallel. Mediator Processing without Resequencing  Mediator Processing with Standard Resequencing.

The standard resequencer is useful for applications that use identifiers from a simple numeric identifier sequence in their messages. The standard resequencer receives a stream of messages that might not arrive in order; it then stores the out-of-sequence messages until a complete sequence based on the sequence IDs is received. The in-sequence messages are then processed asynchronously based on their sequence ID.

It is important to note that the messages to outbound services of the standard resequencer Oracle Mediator service component are guaranteed to arrive in sequence. The standard resequencer does not modify the message contents; it just orders them

When using the standard resequencer in Oracle Mediator, you must always specify a group XPath expression and a sequence ID XPath expression. These specify where the Oracle Mediator resequencer can find the group and the sequence ID in the messages. You must also supply the sequence numbering in terms of the start sequence ID and the sequence ID incremental delta. This numbering is used to form each group. In addition to the group, sequence ID, and increment properties, you can also specify a time period, in seconds, to wait for the expected messages.

  1. FIFO(First-In-First-Out) – Processes transactions based on the time they are received by the Resequencer. Mediator Processing with FIFO Resequencing.

The FIFO resequencer is useful for applications that need sequencing based on the time the messages arrive to the Oracle Mediator.

The FIFO resequencer receives a stream of messages that are in order and processes them in sequence for each group based on the arrival time of the messages.

It is important to note that the messages to outbound services of the Oracle Mediator acting as a FIFO resequencer are guaranteed to arrive in order based on arrival time. Therefore, the messages are delivered in the order they were stored in the resequencer data store.

When using the FIFO resequencer, you must always specify a group XPath expression. However, you do not need to specify a sequence ID because the messages are processed according to the time of arrival to the Oracle Mediator service component that is configured for FIFO resequencing. The group XPath expression specifies where the FIFO resequencer should find the group information in the message to group the messages. No further configuration is needed for a FIFO pattern.

  1. Best Effort– Processes transactions based on Sequence ID in increasing order at predefined intervals. Best Effort transaction processing is not always contiguous. Mediator Processing with Best Effort Resequencing.

The best effort pattern is useful for applications that produce a large number of messages in a short period of time and cannot provide information to the resequencer about the identifier to use for sequencing. Typically, the identifier used for sequencing in such scenarios is of a dateTime type or numeric type. Using the dateTime field as the sequence ID XPath enables you to control the sequencing. The messages are expected to be sent in sequence by the applications, thus the date and time the messages are sent can be used for sequencing. The Oracle Mediator makes the best effort to ensure that the messages are delivered in sequence.

The best effort resequencer can reorder messages based on no knowledge about the increment of the sequence ID. This means that unlike the standard resequencer, you do not need to define the increment of the sequence ID for the best effort resequencer in advance. When the messages are processed, they are processed in sequence based on the specified sequence ID and the messages that have arrived, whether a true sequence is received. The sequence IDs are either numeric or dateTime. Therefore, sequencing occurs on the numeric order or the dateTime order of the sequence IDs.

The best effort resequencer processes messages asynchronously based on one of two message selection strategies: Maximum rows selected or time window. The messages selected and processed at any one time are based either on the maximum number of rows you specify or on a window of time in which they arrive.

Maximum Rows Selected

When the best effort resequencer is configured to use a maximum number of rows, it performs the following steps whenever new messages are available in the resequencer database:

  1. The resequencer orders the messages according to the specified sequence ID (typically a date and time stamp).
  2. The resequencer locks and selects the number of messages equal to the value of the maxRowsRetrieved parameter from the ordered messages above.
  3. The resequencer processes the selected messages one after another in its own transaction in sequence.

Time Window

When the best effort resequencer is configured to use a time window instead of a maximum number rows, the messages to select and process at one time are based on a period of time you specify plus an optional buffer time. Each message belongs to a specific time window, and messages that are part of one time window are processed separately from messages belonging to a different time window.

In addition to the time window, you can specify a buffer time, which is an overlap between two sequential time windows that allows messages that arrive a little late to be associated with the first time window. By default, the buffer time is 10% of the time window you specify.

When the best effort resequencer is configured to use a time window, groups are processed in an iterative manner and messages are processed in the following steps:

  1. The first message arrives and the time window begins.
  2. The buffer is added to the time window, and processing begins after the buffer time.
  3. The resequencer retrieves the messages that arrived within the time window, and identifies the maximum sequence ID (typically a date and time stamp) from all the messages.
  4. The resequencer retrieves any messages that arrive within the buffer time and that have a sequence ID that is less than the maximum sequence ID identified above.
  5. The resequencer sorts all messages retrieved in the above steps in ascending order of the sequence IDs and processes the messages.

The Resequencer uses two tables in the SOAINFRA database to persist and manage transactions:

  1. Mediator_Resequencer_Message– Stores meta-data about the transaction
  2. Mediator_Group_Status– Stores Group related information about the transaction

These tables can be queried to obtain the status of Messages and Groups and the overall health of the Resequencer composite components

In real time we use the resequencer for Order fulfilment. Where order id is used as group id and unique id is used as sequence id. Order fulfilment usually has many stages each stage is passed to end service in sequential order by using resequencing option in mediator. Even though the status updates the Order fulfilment we receive from the client is random we make it sequential.

Related Post: