Friday, April 20, 2012

Single message consumption from distributed topic in WebLogic Server 11g


Most people running Oracle SOA Suite 11g or Oracle Service Bus 11g in a clustered architecture will face issues wherein their code instantiates 2 composites when consuming messages from a distributed JMS topic. This problem obviously does not occur with queues.

This post describes what you need to do both from an infrastructure setup as well as a coding perspective to ensure that messages are consumed once by your SOA code from a distributed JMS topic. It is an example, so customize it to your needs.


1. Create a subdeployment.

a. Navigate to JMS Modules > SOAJMSModule > Subdeployments and click on 'New'

b. Provide a Subdeployment Name (e.g., AhmedSubdeployment) and click 'Next'

c. Select the SOAJMSServer_auto_1 and SOAJMSServer_auto_2 targets.


2. Create a distributed topic using the subdeployment just created.

a. Navigate to JMS Modules > SOAJMSModule and click on 'New'

b. Select Distributed Topic and click 'Next'

c. Provide a Name (e.g., AhmedTopic) and JNDI (e.g., jms/AhmedTopic) and click 'Next'

d. Click on 'Advanced Targeting'

e. Select the subdeployment from the dropdown (e.g., AhmedSubdeployment) which was created earlier and click 'Finish'


3. For SOA composites, modify composite.xml and add the following to the consuming service:

<service name="JMSConsume" ui:wsdlLocation="JMSConsume.wsdl">
  <interface.wsdl interface="http://xmlns.oracle.com/pcbpel/adapter/jms/SOA11g/AhmedPOCTopicRetry/JMSConsume#wsdl.interface(Consume_Message_ptt)"/>
  <binding.jca config="JMSConsume_jms.jca">
    <property name="singleton">true</property>
  </binding.jca>
</service>

4. For OSB projects (if using the native adapter), edit the Configuration Details of the proxy service and set 'Topic Message Distribution' to 'One Copy Per Application':


Applicable Versions
  • Oracle WebLogic Server 11g (10.3.5)
  • Oracle SOA Suite 11g (11.1.1.5)
Ahmed Aboulnaga

5 comments:

REamon said...

Good post.

We have a set up pretty much as described. Clustered environment. JMS distributed topics in subdeployments. Forwarding policy set to Partitioned so that each message is processed just once.

However, we also need the messages processed in order--thus, we need to eliminate concurrency. The singleton property on the composite seems like just what we need. Alas, that was introduced at 11.1.1.5 and we're on 11.1.1.4. We're going to update but it may not be in time.

Are you aware of another way to serialize the processing of messages from a topic that we can explore? We're looking at Unit of Order on the JMS side of things, but not quite finished figuring out if it will fit. Any insight would be greatly appreciated.

Ahmed Aboulnaga said...

I hate to be the bearer of bad news, but the 'singleton' property described here won't help you. See http://docs.oracle.com/cd/E23943_01/integration.1111/e10231/life_cycle.htm#BABDAFBH for additional information.

Sequencing is going to be a bit more challenging, but you probably have a few realistic options:

1. Consider using the resequencing feature in Mediator, which is supported in 11.1.1.4 (see http://docs.oracle.com/cd/E17904_01/integration.1111/e10224/med_resequencer.htm). I don't know how well this performs in large loads and in exception cases.

2. Have the source application make synchronous invocations in order of sequence (i.e., put the burden on the source application).

3. Programmatically handle this. For example, after consuming the message, your BPEL process will have to do additional checks to first ensure that the message is not out of sequence before processing it (probably using some additional custom checkpoint tables you will have to create). There's a lot more logic to add to it, but hopefully you get the idea.

REamon said...

As seems par for Oracle documentation, it isn't quite clear exactly what the singleton property does (I had previously read the info at the link you provided). But I think I may now understand: when a topic is configured as "Partitioned" only one instance of the cluster will get a given message but all nodes in the cluster are active, correct? The singleton property changes this such that only one node is active and all others are on standby. Please advise if I've got that correct.

We're examining the resequencing feature but on first blush that doesn't seem to be a fit. And it introduces yet another component.

The source application is making sync calls in order--and putting things on the topic for subscribers. It you're suggesting removing the topic, that's not really an option in this case.

This shouldn't be this hard. I just want a composite singleton reading off the topic. What simple thing am I overlooking?

Thanks for your suggestions! We'll keep looking.

Side note: nothing in this toolset is ever simple. Every little thing one wants to do ends up with a big research effort to try to find the bit to twiddle in the copious instances of configs and settings. :-(

REamon said...

The WLS value add to JMS unit-of-order feature seems like it would be a fit. And would have the added benefit of being a bit selective on the serial vs. concurrent processing.

I'm still figuring out the details but would appreciate your thoughts on the applicability of this feature.

Ahmed Aboulnaga said...

REamon,

Check out this new blog post of mine. Hopefully it will clarify things further.

http://blog.ipnweb.com/2012/07/understanding-singleton-property-with.html