12-6 Developing Web Applications, Servlets, and JSPs for Oracle WebLogic Server
■
Section 12.5, Enabling Security
■
Section 12.6, Advanced Topic: Using JMS as a Provider to Enable Cluster Support
■
Section 12.7, Advanced Topic: Persisting Messages to Physical Storage
12.3.1 Creating the weblogic-pubsub.xml File
The weblogic-pubsub.xml deployment descriptor is an XML file that configures the pub-sub server, in particular by specifying the initial channels, configuration
properties of the pub-sub server, and security specifications for the clients that subscribe to the channels. Some of this information can be updated at run time by the
pub-sub server using the server-side APIs.
The root element of the deployment descriptor is wlps:weblogic-pubsub, where the wlps namespace is
http:xmlns.oracle.comweblogicweblogic-pubsub.
For a full description of the elements of the weblogic-pubsub.xml file, see the Schema. The following list includes some of the more commonly used elements; see
the end of this section for a typical example of a weblogic-pubsub.xml file:
■
wlps:server-config: Configures the pub-sub server. Child elements of this element include:
– wlps:work-manager: Specifies the name of the work manager that
delivers messages to clients.
– wlps:publish-without-connect-allowed: Specifies whether clients
can publish messages without having explicitly connected to the pub-sub server.
– wlps:supported-transport: Specifies the supported transports.
Currently, the two supported transports are long-polling and callback-polling.
– wlps:client-timeout-secs: Specifies the number of seconds after
which the pub-sub server disconnects a client if the client does has not sent back a connectreconnect message
■
wlps:channel: Defines and configures the initial channels. Child elements of this element include:
– wlps:channel-pattern: Specifies the channel pattern, similar to the
way servlet URL patterns are specified, such as foobar, foobar, foobar.
■
wlps:channel-persistence: Specifies whether the channel is persistent. For details, sees
Section 12.7, Advanced Topic: Persisting Messages to Physical Storage
. –
wlps:jms-handler-name: Specifies that this channel uses a JMS handler, rather than the default. For details, see
Section 12.6, Advanced Topic: Using JMS as a Provider to Enable Cluster Support
. –
wlps:message-filter: Configures a message filter chain. For details, see Section 12.3.3, Configuring and Programming Message Filter Chains
.
■
wlps:channel-constraints: Configures security for the channel, such which roles are allowed to perform which operations for a given channel. For
details, see Section 12.5, Enabling Security
.
Using the HTTP Publish-Subscribe Server 12-7
■
wlps:jms-handler-mapping: Configures a JMS handler. For details, see Section 12.6, Advanced Topic: Using JMS as a Provider to Enable Cluster
Support .
The following sample weblogic-pubsub.xml file shows a simple configuration for an application that uses the pub-sub server; see the explanation after the example for
details:
?xml version=1.0 encoding=UTF-8? wlps:weblogic-pubsub
xmlns:wlps=http:xmlns.oracle.comweblogicweblogic-pubsub wlps:server-config
wlps:publish-without-connect-allowedtruewlps:publish-without-connect-allowed wlps:supported-transport
wlps:client-timeout-secs100wlps:client-timeout-secs wlps:persistent-client-timeout-secs400wlps:persistent-client-timeout-secs
wlps:interval-millisecs1000wlps:interval-millisecs wlps:multi-frame-interval-millisecs2000wlps:multi-frame-interval-millisecs
wlps:server-config wlps:channel
wlps:channel-patternchatroomswlps:channel-pattern wlps:channel
wlps:channel-constraint wlps:channel-resource-collection
wlps:channel-resource-nameall-permissionswlps:channel-resource-name wlps:descriptionGrant all permissions for everything by
everyonewlps:description wlps:channel-patternchatroomswlps:channel-pattern
wlps:channel-resource-collection wlps:channel-constraint
wlps:weblogic-pubsub
In the preceding example:
■
The wlps:server-config element configures the pub-sub server itself. In particular, it specifies that clients can publish messages to the pub-sub server
without explicitly connecting to it and that the server disconnects the client after 100 seconds if the client has not sent a reconnect message during that time. The
wlps:persistent-client-timeout-secs element specifies that, in the case of persistent channels, the client has up to 400 seconds to be disconnected to
still receive messages published during that time after it reconnects. The wlps:interval-milliseconds element specifies that the client can delay
up to 1000 milliseconds subsequent requests to the metaconnect channel. Finally, the wlps:multi-frame-interval-millisecs element specifies
that the client can delay up to 2000 milliseconds subsequent requests to the metaconnect channel when multi-frame is detected.
■
The wlps:channel element configures a single initial channel to which users can subscribe. This channel is identified with the pattern chatrooms; this
pattern is the top of the channel hierarchy.
■
The wlps:channel-constraints element provides security constraints about how the chatrooms channel can be used. In this case, all permissions
are granted to all users for all channels for all operations.
12-8 Developing Web Applications, Servlets, and JSPs for Oracle WebLogic Server
12.3.2 Programming Using the Server-Side Pub-Sub APIs