Thursday, September 19, 2013

Configuring SOA Distributed Destination Topics using WLST

The organization of topics and the granularity of subscriptions to them is an important part of a publish/subscribe application’s architecture. A message delivered to a topic is distributed to all consumers that are subscribed to that topic. Ensuring that a clustered application gets exactly one copy of each message, and parallel processing of topics messages may require significant additional configuration, coding, and message hops. To address such limitations, WebLogic JMS provides load balancing and failover for physical JMS destination members (queues or topics) through its "Distributed Destinations" that applications can leverage.

In a typical SOA Suite production cluster deployment, load balancing the JMS topic messages against the SOA composites will be a common requirement. It is to ensure that messages are evenly distributed (load balanced) to SOA cluster members, and to avoid duplication in some scenarios. This can be achieved by configuring the SOA JMS Topic to use a "Distributed Destination" setting the appropriate forwarding policy and other advanced parameters.

Here is a sample WLST offline script:

import sys
#=======================================================================
# Function to configure WLS JMS Uniform Distributed Topic
#=======================================================================
def configureWlsJMSDistributedTopic (jmsModule, jmsTopic, jndiName, forwardPolicy, subDeploymentName):
print '========= START Configuring WLS JMS Distributed Topic for ['+jmsTopic+'] ========='
try:
cd ('/')
# assumes 'jmsModule' already exists
cd ('/JMSSystemResource/'+jmsModule+'/JmsResource/NO_NAME_0')
# create Uniform Distributed Topic (UDT)
create (jmsTopic, 'UniformDistributedTopic')
cd ('UniformDistributedTopic/'+jmsTopic)
# set UDT properties
cmo.setJNDIName(jndiName)
# forwarding policy - Partitioned / Replicated (default)
cmo.setForwardingPolicy(forwardPolicy)
# assumes 'subDeploymentName' already exists
cmo.setSubDeploymentName(subDeploymentName)
except Exception, detail:
raise Exception ('Exception configuring WLS JMS Uniform Distributed Topic')
print '-------------- END Configuring WLS JMS Uniform Distributed Topic for ['+jmsTopic+'] --------------'
########################################################################
# MAIN
########################################################################
wlsDomainHome= " "
try:
wlsDomainHome = sys.argv[1]
except:
print 'WARNING:Not all command line parameters specified'
if (wlsDomainHome == " "):
sys.exit()
# read Domain
try:
readDomain(wlsDomainHome)
print '***** Read Domain: %s' % wlsDomainHome
except :
print 'XXXXX Could not Read Domain: %s' % wlsDomainHome
exit()
try:
# create WLS JMS Uniform Distributed Topic
configureWlsJMSDistributedTopic ("TestJMSModule", "SampleUDTopic", "jms/test/SampleUDTopic",
"Partitioned", "TestSubDeployment")
print 'Updating and Closing Domain'
updateDomain()
closeDomain()
except Exception, detail:
print 'FINAL Exception:', detail
dumpStack()
exit()

Note that there in no support to define the UniformDistributed Queue/Topic in weblogic application extension templates' file config/jms/<%jms-module%>-jms.xml (as of the latest SOA PS6 release). Refer the "Fusion Middleware Programming JMS for Oracle WebLogic Server" guide for more details on WLS JMS Distributed Destinations.