Sunday, August 8, 2010

How to Subscribe to Distributed Topic without Message Duplication

Mastering BEA WebLogic Server: Best Practices for Building and Deploying J2EE ApplicationsThis is about very interesting scenario I came across and I think many of you might have also faced the smiliar situation.

Scenario : I have one distributed topic in my Integration scenario, and I am subscribing to that Distributed topic (Clustered Environment ofcourse) with a proxy service (Oracle service Bus 10g) and storing the same message again into another distributed Queue. So whenever message is getting published to the Distributed Topic, Message is stored in both the clusters and as a result I was ending up with two same messages in single Distributed Topic, each message in one cluster. Because of this, my proxy service was getting called twice for the same message and same two messages were getting stored in Distributed Queue.

WebLogic: The Definitive GuideWell so issue here is duplicate messages in distributed topic, but I guess writing a word "issue" is not correct, because Distributed Topics are made to behave like this. This is what we call expected behaviour. But my requirement was how to remove this duplication from Distributed Topic.

Here is the trick, Create two seperate Topic (Not distributed Topic) and targeting both the clusters one by one. Now we have something called "Local JNDI Name" in Topic. Set the same value for this field for both the topic and refer to this common name while refering to Topic. This will give very much similar functionaliy like Distributed Topic and yeah ofcourse without message duplication.

Limitation : All limitations applied to local JNDI name will be implicit to this solution.

Sun Cluster Data Service for Weblogic Server Guide for Solaris OS 
Oracle Application Server 10g: J2EE Deployment and Administration 

3 comments:

  1. Hi,

    I am facing the same issue on Oracle Weblogic server 11g. Tried the option mentioned in your post. But still I am getting duplicate messages.

    After creating the topics, I could target it to only one server at a time.

    Any steps I am missing here ?

    Thanks and Regards,
    Sayama Ahmed

    ReplyDelete
  2. Hi Sayama,

    It should be simple topic not the distributed one and you should be setting the same "local jndi name" not the jndi name itself. First create two different topics and target it to different single servers and then after that you can update them with same local jndi name.

    Regards,
    Niraj

    ReplyDelete
  3. Thanks. Great blog. The workaround works just fine.

    ReplyDelete