The Web messaging service reads configuration information from the file, webmsg.json, located in a JavaTM Platform, Enterprise Edition (Java EE) application Web module WebContent/WEB-INF directory. This information is read on application start and stop to initialize the Web messaging service with configuration information. This file resides alongside the web.xml file of a Web module and the location of this file cannot be changed. The webmsg.json file is specified in JavaScriptTM Object Notation (JSON) format, specifically the contents of the file should represent a JSON object. A JSON object is a collection of key/value pairs. See the following example of the Web messaging configuration file:
{ "WebMsgServlet": { "busName": "thebus", "destination": "Default.Topic.Space", "clientCanPublish": false, "longPollTimeout": 30 } } |
Each key in the JSON object specifies an existing servlet name in the same Web module where the webmsg.json file is specified. The value for each key is another JSON object where Web messaging configuration options are specified. Incoming Web messaging requests are determined by the servlet mappings for the specified servlet. These incoming requests are processed with the specified configuration options. The following example is an snippet of a web.xml file containing the WebMsgServlet servlet and associated servlet mappings:
<servlet> <display-name>WebMsgServlet</display-name> <servlet-name>WebMsgServlet</servlet-name> <servlet-class> com.ibm.websphere.webmsg.servlet.WebMsgServlet </servlet-class> </servlet> <servlet-mapping> <servlet-name>WebMsgServlet</servlet-name> <url-pattern>/stockServlet</url-pattern> </servlet-mapping> |
In the previous example, the WebMsgServlet servlet is mapped to /stockServlet. Any incoming Web messaging request that maps to /stockServlet are processed with the configuration parameters in the webmsg.json previous example. In this case, the Web messaging requests use service integration bus; thebus, the default topic space Default.Topic.Space, the Bayeux long poll timeout is 30, and Web messaging clients cannot publish messages to the server.
Most configurations only need to create one servlet and related webmsg.json configuration entry. There are times when multiple definitions msut be created in a single Web module. Examples include connecting to different service integration buses, specifying a different default destination, or separating clients by Bayeux long poll timeout. To separate incoming requests based on configuration parameters, a new servlet definition mapped to com.ibm.websphere.webmsg.servlet.WebMsgServlet and a new servlet mapping must be created. Finally create a new entry in the webmsg.json with desired configuration parameters. This entry must have a key that maps to the newly created servlet.
The following sub sections describe all possible Web messaging configuration options in detail.