Configuring JMS as a Handler

12-20 Developing Web Applications, Servlets, and JSPs for Oracle WebLogic Server wlps:descriptionpublisherwlps:description wlps:role-namepublisherwlps:role-name wlps:auth-constraint wlps:channel-constraint wlps:channel-constraint wlps:channel-resource-collection wlps:channel-resource-namesubscribewlps:channel-resource-name wlps:descriptionsubscribe channel constraintwlps:description wlps:channel-patternstockwlps:channel-pattern wlps:channel-operationsubscribewlps:channel-operation wlps:channel-resource-collection wlps:auth-constraint wlps:descriptionsubscriberwlps:description wlps:role-namesubscriberwlps:role-name wlps:auth-constraint wlps:channel-constraint

12.6 Advanced Topic: Using JMS as a Provider to Enable Cluster Support

Pub-sub server applications can run in a WebLogic Server clustered environment so as to provide scalability and server failover. However, pub-sub applications behave differently depending on the message handler pub-sub server itself or a JMS provider that is handling the published messages. In the default non-JMS case, the pub-sub server handles all messages and each instance of the pub-sub server on each node of the cluster is independent and isolated. This means that event messages cannot be shared between different server instances. For example, if a client subscribes to channel chat on node A of the cluster, it cannot receive messages published to channel chat on node B of the cluster. If, for a given channel, you want all messages published to all nodes of a cluster to be shareable by all clients subscribed to the channel, then you must configure the channel for JMS. You do this by updating the appropriate wlps:channel element in the weblogic-pubsub.xml deployment descriptor of your application. When a client publishes a message to a JMS-configured channel, the pub-sub server re-sends the message to a JMS topic. JMS message listeners running on each node of the cluster retrieve the messages from the JMS topics and then deliver them to the subscribed clients on their node.

12.6.1 Configuring JMS as a Handler

You configure the JMS as the message handler for an application in the weblogic-pubsub.xml deployment descriptor of the pub-sub server. First, you declare the configuration of the JMS handler using the wlps:jms-handler-mapping child element of the root wlps:weblogic-pubsub element. This is where you specify the URL of the JMS provider, the connection factory JNDI name, and the JMS topic JNDI name. Then you configure a specific channel to be a JMS channel by adding a wlps:jms-handler-name child element. The following example shows how to configure a JMS handler and channel in the weblogic-pubsub.xml deployment descriptor; only relevant information is shown in bold. See the text after the example for an explanation. Using the HTTP Publish-Subscribe Server 12-21 ?xml version=1.0 encoding=UTF-8? wlps:weblogic-pubsub xmlns:wlps=http:xmlns.oracle.comweblogicweblogic-pubsub wlps:server-config ... wlps:server-config wlps:jms-handler-mapping wlps:jms-handler-nameDefaultJmsHandlerwlps:jms-handler-name wlps:jms-handler wlps:jms-provider-urlt3:localhost:7001wlps:jms-provider-url wlps:connection-factory-jndi-nameConnectionFactoryJNDIwlps:connection-factory- jndi-name wlps:topic-jndi-nameTopicJNDIwlps:topic-jndi-name wlps:jms-handler wlps:jms-handler-mapping wlps:channel wlps:channel-patternchatwlps:channel-pattern wlps:jms-handler-nameDefaultJmsHandlerwlps:jms-handler-name wlps:channel wlps:weblogic-pubsub In the preceding example: ■ The wlps:jms-handler-mapping element defines a JMS handler named DefaultJmsHandler. The wlps:jms-handler child element configures specific properties of DefaultJmsHandler that the pub-sub server uses to delegate messages to the JMS topic; in particular, the JMS provider URL that the pub-sub server uses to access the JNDI tree of the JMS provider is t3:localhost:7001, the connection factory JNDI name is ConnectionFactoryJNDI, and the JNDI name of the topic to which the messages will be delegated is TopicJNDI. ■ The wlps:jms-handler-name child element of wlps:channel specifies that the channel with pattern chat is actually a JMS channel, with JMS configuration options specified by the DefaultJmsHandler. For the full list of JMS handler-related XML elements you can include in the weblogic-pubsub.xml deployment descriptor, see the weblogic-pubsub.xsd Schema at http:xmlns.oracle.comweblogicweblogic-pubsub1.0weblogic-pu bsub.xsd .

12.6.2 Configuring Client Session Failover