How the Pub-Sub Server Works

12-2 Developing Web Applications, Servlets, and JSPs for Oracle WebLogic Server The pub-sub server can communicate with any client that can understand the Bayeux protocol. The pub-sub server is responsible for identifying clients, negotiating trust, exchanging Bayeux messages, and, most importantly, pushing event messages to subscribed clients. The following figure describes the basic architecture of the pub-sub server included in WebLogic Server. Figure 12–1 HTTP Publish-Subscribe Server of WebLogic Server

12.1.1 How the Pub-Sub Server Works

There is a one-to-one relationship between a Web application and a pub-sub server; in other words, each Web application has access to one unique pub-sub server. Each pub-sub server has its own list of channels, which means that there can be channels with the same name used in different Web applications within the same enterprise application. The Web application uses a context object to get a handle to its associated pub-sub server. The pub-sub server itself is implemented as a Java EE library that its associated Web application references in its weblogic.xml deployment descriptor. The pub-sub server has its own deployment descriptor, called weblogic-pubsub.xml, that lives in the same directory as other Web application descriptors WEB-INF. Developers use the descriptor to configure initial channels for the pub-sub server, specify the transport and message handlers, and set up user authentication and authorization. Web application developers can optionally use server-side pub-sub APIs in their servlets or Java classes to get the pub-sub server context, manage channels, and manage the incoming and outgoing messages to and from the clients. It is not required, however, to use server-side pub-sub APIs. For example, developers can use the pub-sub server to implement a chat feature in their Web application. In a typical chat application, clients perform all the subscribe and publish tasks themselves without any need for additional server-side coding. If, however, developers need the pub-sub server to perform additional steps, such as monitoring, collecting, or interpreting incoming messages from clients, then they must use the server-side pub-sub server APIs to program this functionality. For Web 2.0 Ajax clients to communicate with the pub-sub server, the clients need a JavaScript library that supports the Bayeux protocol. The pub-sub server provides the Dojo JavaScript library implementation as part of its distribution sample. The Dojo JavaScript library provides four different transports, of which two are supported by the WebLogic pub-sub server: long-polling and callback-polling. Using the HTTP Publish-Subscribe Server 12-3 The pub-sub server can run in a clustered environment by using JMS to make the messages shareable between nodes of the cluster. In this case, the pub-sub server essentially delegates message handling to a JMS provider. You can also specify that messages be persisted to physical storage such as a file system or database. By default messages are not persisted. The following sections provide additional information about the pub-sub server: ■ Section 12.1.2, Channels