Monday, September 14, 2009

wls pubsub server

 IT trends 2010 series (2)
com.bea.httppubsub.BayeuxMessage

Develop steps
  1. weblogic.xml library-ref
  2. weblogic-pubsub.xml  (weblogic-pubsub.xsd)

  3. PubSub API for publish, filter, dynamic channel (optional)
    lookup pubsub server & create local client
            publish to channel
            subscribe (listener register)
            filter chain (filter class, config chain)
    APIS:
            com.bea.httppubsub.PubSubServer
            LocalClient
            ClientManager
            MessageFilter
            DeliveredMessageListener
            BayeuxMessage

  4. Add Dojo to jsp/html for publish/subscribe msg.
    //Initialize the Dojo cometd environment
    dojo.io.cometd.init({}, "/context/cometd");
        cometd - matching default pubsub war web.xml

    //Publish a message to a channel
    dojo.io.cometd.publish("/a/channel", "message content");   //publish text msg
    dojo.io.cometd.publish("/a/channel", {"data": "content"}); // JSON object

    //Subscribe to a channe
    dojo.io.cometd.subscribe("/a/channel", null, "onUpdate");

            //JS function for call back
            function onUpdate(message) {
              if (!message.data) {
                alert("bad message format "+message);
                  return;
              }
              // fetch the data published by other clients
              var data = message.data;
            }
  5. Deploy web-app; pubsub war library  WL_HOME/common/deployable-libraries
  6. Other aspects

    • Persistent Channelsweblogic-pubsub.xml  persistent-client-timeout-secs
    • JMS as provider for cluster support weblogic-pubsub.xml

             t3://localhost:7001
             ConnectionFactoryJNDI
             TopicJNDI
    • Requiring SSL for pub-sub Via web.xml INTEGRAL
    • AuthCookieEnabled to Access SSL resources
      _WL_AUTHCOOKIE_JSESSIONID created (cookie or URL rewrite). This is default behavior
    •  Locking Down the Pub-Sub Server (5-*)
    *Configure SSL for pub-sub.
    *Require authentication (BASIC, FORM, and so forth.)
    *Ensure auth-cookie is enabled.
    *Ensure that all the channels are constrained in the weblogic-pubsub.xml file.
    *Lock subscribe operations, which are allowed by default.

No comments: