Example: Using the messaging system composition service

The following example shows how we might use the messaging system composition service. If you have a store named MyStore, and we want to assign two transports, e-mail and file, to the CompanyAOrderCreateMsg message type, you would: Add an entry to Struts configuration files for the JSP file to use for composing this outbound message. The keys for the Struts configuration files are the view name, the store ID, and the device format ID which can be identified from the name attribute "OrderCreateXMLFormatView/0/-3" For example, in WebSphere Commerce Version 9.0.0.x, the keys are defined as follows:

In Version 9.0.1+, they are defined this way:

Important: Each view created to be used by the Messaging System's compose service must use the Messaging View Command for the interface and class name fields. It must also contain the name of the JSP file and any sub-directory relative to the Stores.war and store directory in the path field. To summarize:

In the following example the MyStore STOREENT_ID is 10001 and the viewname is CompanyAOrderAuthorizedView. To avoid possible migration problems, ensure that you prefix the both the view name and the message type name with a unique prefix. In the name attribute, "CompanyAOrderAuthorizedView/10001/-3" represents viewname, store ID and device format ID respectively.

In Version 9.0.0.x, the code is as follows:

In Version 9.0.1+, it is:

Use the Administration Console to assign the e-mail and file transports to the CompanyAOrderCreateMsg message and configure the settings. This can be done using either site or store level administration authority. Creating settings on site level will make it accessible to all stores.

In the implementation of a command, instantiate the SendMsgCmd command to use messaging services and call the setMsgType() and setStoreID() methods, using the message type name of the CompanyAOrderCreateMsg message type and the store ID of storeent_id of 10001. Place the CompanyAOrderCreateMsg.jsp file in the store's root directory.

To use site-level configuration, do the following:

  1. Specify the STOREENT_ID as 0.

  2. Add PROPERTIES of storeDir=no to the JSP file name.

  3. Place the JSP file in the WC_eardir/Stores.war directory.

  4. Invoke the compose method of the outbound messaging system interface and pass any additional parameters in the form of a TypedProperty object. Refer to the topic Message content setting services.

  5. Call sendImediate or sendTransacted on SendMsgCmd if we want the message to be sent immediately or after the transaction has successfully been committed. Refer to the Messaging System documentation for a further explanation of the use of each method.

  6. Call execute method of the SendMsgCmd to execute sending.


Related concepts
Outbound messaging system


Related tasks
Configure a transport method for the site
Encoding for e-mail transmission


Related reference
Outbound messages