Oracle SOA Suite 11g, Resequence messages in Mediator

“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.”

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

Let’s test the first one.

For this i created the next composite

In here i just map the input of the process 1on1 to the File adapter, which will store the input of the process on filesystem.

Interface of the composite

<?xml version="1.0" encoding="UTF-8"?>
<schema attributeFormDefault="unqualified"
	elementFormDefault="qualified"
	targetNamespace="http://xmlns.oracle.com/Application1_jws/MyReSequence/ProcessEmployees"
	xmlns="http://www.w3.org/2001/XMLSchema">
	<element name="process">
		<complexType>
			<sequence>
				<element name="empID" type="string"/>
        <element name="empType" type="string"/>
        <element name="empName" type="string"/>
			</sequence>
		</complexType>
	</element>
	<element name="processResponse">
		<complexType>
			<sequence>
				<element name="result" type="string"/>
			</sequence>
		</complexType>
	</element>
</schema>

Configuration of the sequencer

Doubeclick the mediator component in the composite.

For the Resequence Level we can select ‘operations’ or ‘component’.
For Mediator components which only have 1 operation it doesn’t matter which one we select. For a Mediator component which consists of more then 1 operation and selecting the ‘component’ option means resequencing is applied to all operations in it. For this test we selected the ‘component’ option and used the ‘Standard’ mode.
Now we have several options to configurate the resequencer.

  • Group – xpath expression to the field in the payload which the resequencer will use to group our incoming messages
  • ID – xpath expression to the field which will uniquely identify our message
  • Start – Start value of the ID in the incoming message
  • Increment – Value which will be used for the increment of the id field in the upcoming messages
  • Timeout – Time to wait before a following expected message arrives at the Mediator component

And that’s it what is needed for the configuration of the ‘Standard’ resequencer.

Test

To test this scenario i will use the following 3 messages.

<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
    	<soap:Body xmlns:ns1="http://xmlns.oracle.com/Application1_jws/MyReSequence/ProcessEmployees">
        		<ns1:process>
            			<ns1:empID>1</ns1:empID>
            			<ns1:empType>IT</ns1:empType>
            			<ns1:empName>Eric</ns1:empName>
        </ns1:process>
    </soap:Body>
</soap:Envelope>
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
    	<soap:Body xmlns:ns1="http://xmlns.oracle.com/Application1_jws/MyReSequence/ProcessEmployees">
        		<ns1:process>
            			<ns1:empID>2</ns1:empID>
            			<ns1:empType>IT</ns1:empType>
            			<ns1:empName>John</ns1:empName>
        </ns1:process>
    </soap:Body>
</soap:Envelope>
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
    	<soap:Body xmlns:ns1="http://xmlns.oracle.com/Application1_jws/MyReSequence/ProcessEmployees">
        		<ns1:process>
            			<ns1:empID>3</ns1:empID>
            			<ns1:empType>IT</ns1:empType>
            			<ns1:empName>Theo</ns1:empName>
        </ns1:process>
    </soap:Body>
</soap:Envelope>

Go to the console > soa_domain > SOA > soa-infra > > and Test it.
If we trigger the process 3 times with the payloads as we describes and in the same sequence, the instances will all complete and write the files to filesystem in the same sequence.

We used the ‘Standard’ mode and selected empID for sequence-value and emptType for group-value, and the sequence should start with 1 and will increment by 1.

Now switch the last 2 messages in the sequence and see what happens. Since we’re trying to process and already processed message again we will get the next errormessage

The selected operation execute could not be invoked.
An exception occured while invoking the webservice operation. Please see logs for more details.
oracle.sysman.emSDK.webservices.wsdlapi.SoapTestException: oracle.tip.mediator.infra.exception.MediatorException: ORAMED-03003:[Storing Resequencer Group Failed]Unable to store Resequencer Group." oracle.tip.mediator.common.persistence.MediatorResequencerMessage, mediator InstanceId=E07531315F8511DFBFBF3B164F19FDA3, componentDn=default/MyReSequence!1.0/Mediator1, operation=execute, groupId=IT, sequenceId=1, status=0"Possible Fix:Unable to store Resequencer Group. Check your Database connection or check data

So change all empType to ‘HR’ instead of ‘IT’.
For example

<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
    	<soap:Body xmlns:ns1="http://xmlns.oracle.com/Application1_jws/MyReSequence/ProcessEmployees">
        		<ns1:process>
            			<ns1:empID>1</ns1:empID>
            			<ns1:empType>HR</ns1:empType>
            			<ns1:empName>Eric</ns1:empName>
        </ns1:process>
    </soap:Body>
</soap:Envelope>

The sequence we’re now going to use is empID=1, empID=3, empID=2

After sending the second message (empID=3), you will notice the instance won’t complete. Because the resequencer expects an empID=2. In this case it will wait till this message arrives.

<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
    	<soap:Body xmlns:ns1="http://xmlns.oracle.com/Application1_jws/MyReSequence/ProcessEmployees">
        		<ns1:process>
            			<ns1:empID>2</ns1:empID>
            			<ns1:empType>HR</ns1:empType>
            			<ns1:empName>Eric</ns1:empName>
        </ns1:process>
    </soap:Body>
</soap:Envelope>


Now use the last test message (empID=2) and see what happens.

Instance 30030 changes from Running to Completed. This is because it received the next message in the sequence (empID=2), and after that the instance 30030 (empID=3) could continue.
If we check the files on filesystem we also see (compair the datetime of the files) that the files are stored in the correct sequence.

Other Resequencers

Besides the ‘Standard’ resequencer wel also have the ‘FIFO’- and the ‘BestEffort’ resequencer.
See this document to decide what resequencer suits best for your case.

test

Share this Post:
Digg Google Bookmarks reddit Mixx StumbleUpon Technorati Yahoo! Buzz DesignFloat Delicious BlinkList Furl

14 Responses to “Oracle SOA Suite 11g, Resequence messages in Mediator”

commenter

I think too many features also not good for some instences.

commenter

Hi Eric ,

Well illustrated.I have not gone through FIFO and Best Effort .The below is the immediate flashed in after going through your blog.

“We select an Sequence ID and the group Id from the payload.That’s make sense for grouping messages but bit concerned about initializing the value for the Sequence ID.

Say if the composite or server is down and later when it comes up the composite would be expecting again from the start ???

commenter

Hi ,
I tried the same thing but it’s not working .. even if i give id =1 the mediator goes to a running state ..i have no idea why it’s not showing completed// i am using 11.1.1.2.0 SOA Suite with a JDEV of 11.1.1.3.0 version..please help

commenter

What’s the ‘start’ value you used? (in the configuration)

commenter

I am trying to work with the resequencing in mediators .. i am simply taking two inputs fro the client ..dat is input_ id and input_ group ..and i am using resequencing on component level and it is the Standard one ..it’s increment id is 1 and starts with 1 ..
when i am testing it .. i am giving input as 1GPS ..
when i am checking the instance the mediator is showing in running state whereas it should have shown completed as the id is not 2 or 3 that it will wait for other messages to arrive ..
i have also checked the table named ‘mediator_resequencer_message’ ..the entry is stored there as Sequence_ id=1 and group_id= GPS ..
i have no clue why it’s not working ..
Any suggestion or help is highly appreciated …
Thanks

commenter

Can you show me the GROUP and ID values and the xml you use

commenter

1
GPS
Andy
CRM

commenter

Hi Eric,
One more thing ..can you please tell me whether the fault policies will work with the execution Type being Resequence instead of parallel?I tried once but it didnt work ..
Thanks

commenter

Hi Eric,
I have a requirement wherein I have to call two processes from mediator.The condition is that the output of the first process must be the input of the second process. How do we achieve this using a mediator ?

commenter

Hi Abhay,

See : http://download.oracle.com/docs/cd/E14571_01/integration.1111/e10224/med_interactions.htm
24.1 Understanding a One-way Message Exchange Pattern

Request Response
Response is forwarded to another target or event.

is this what you need?

commenter

Hi Eric,
Thanks for your response.
My requirement is somewhat similar to the above posting. The exact req is , mediator should first call a webservice and get some data. This original request to the mediator has to be enriched with this data and then conditionally call the second process. The condition to call the second process depends on the output of the first call, basically i need to add a filter for the second call and that filter should be based upon the output of the first call. Also if the filter expression evaluates to true, the input of the second process should be the enriched input.
If we map this to OSB it is somewhat similar to have a service callout first and then enrich the input and call a route node or a service callout then.

commenter

Hm ok. And why do you want to try this with just the mediator and not with some extra bpel process with does it all for you ?

commenter

Is it not possible to do with a mediator ? As sugegsted by you we have done it now by introducing a new BPEL prcoess which call the process one first and then second process through the mediator ? Was just thinking if the same design is possible in Mediator or not ?

commenter

I’m not sure about it. Would need to do some investigation myself too, sorry

Leave a Reply:

Name (required):
Mail (will not be published) (required):
Website:
Comment (required):
XHTML: You can use these tags: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>