Sunday 9 June 2013

SOA Suite 11g: truly singleton with AQ Adapter

If you need to consume messages one by one from an AQ using a composite, here's how you accomplish this.

Go to your dequeue interface and set the following properties:
1
activationInstances = 1
2
singleton = true
 

Binding properties for singleton behaviour


By doing this, you're telling the engine to use only one thread (the activationInstances parameter) on each managed server to do the dequeue, and then you tell it to run the process from just one managed server (the singleton parameter, obviously). If the node elected to run the process goes down, the engine recognizes this and another node is selected to run it, so there's no human intervention associated.

With this configuration, you have only one thread listening to events from the database, but as the nature of AQ is asynchronous, once this thread instantiates a composite, it goes back to the database to get another message. In order to avoid this, you have to change the binding WSDL to include a response.
To keep it simple, I created the output part using the input data structure:
1
<wsdl:portType name="DEQUEUE_ptt">
2
   <wsdl:operation name="DEQUEUE">

3
      <wsdl:input message="tns:WF_EVENT_T_msg"/>
4
      <wsdl:output message="tns:WF_EVENT_T_msg"/>

5
   </wsdl:operation>
6
</wsdl:portType>

Now, you have to add a reply action to your BPEL - if there's no BPEL flow associated to the interface, no worries - when you create it, the reply will be generate automatically. If you already have a flow, update the interface and insert the action:

BPEL with Reply action


That's it. Deploy your project, and it will start consuming messages one by one, no concurrency whatsoever.
Tested with SOA Suite 11.1.1.5.

One last word: my understanding about this approach is that if you need to go this way (environment-wide singleton), there's a slight chance that something is wrong with your design. Check it carefully. I got to this configuration while exploring the adapter's behaviour - not intend to use it anytime soon :-)

2 comments:

  1. Did you copy the article from here:

    http://mazanatti.info/index.php?/archives/81-SOA-Suite-11g-truly-singleton-with-AQ-Adapter.html

    ?

    ReplyDelete
  2. I meant, here:

    http://web.archive.org/web/20130729190141/http://mazanatti.info/index.php?/archives/81-SOA-Suite-11g-truly-singleton-with-AQ-Adapter.html

    ReplyDelete