Example: Using the messaging system composition service
The following example shows how you might use the messaging system composition service. If you have a store named MyStore, and you want to assign two transports, e-mail and file, to the CompanyAOrderCreateMsg message type, you would:
<forward className="com.ibm.commerce.struts.ECActionForward"
name="OrderCreateXMLFormatView/0/-3" path="/OrderCreateXML.jsp">
<set-property property="resourceClassName" value="com.ibm.commerce.messaging.viewcommands.MessagingViewCommandImpl"/>
<set-property property="properties" value="storeDir=no"/>
<set-property property="interfaceName" value="com.ibm.commerce.messaging.viewcommands.MessagingViewCommand"/>
<set-property property="implClassName" value="com.ibm.commerce.messaging.viewcommands.MessagingViewCommandImpl"/>
<set-property property="direct" value="true"/>
</forward>
- INTERFACENAME
- com.ibm.commerce.messaging.viewcommands.MessagingViewCommand
- CLASSNAME
- com.ibm.commerce.messaging.viewcommands.MessagingViewCommandImpl
- PATH
- The parameter containing the JSP file name pre-pended with any sub-directory relative to the store directory.
- PROPERTIES
- Use the following format to point to the JSP file 'docname=jsp file'.
- DEVICEFMT_ID
- Represents the device format and should use the value -3 (the standard device format) unless using custom device formats for your application. The DEVICEFMT_ID must correspond to the device format selected when assigning a message type to a transport.
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 hhe name attribute, "CompanyAOrderAuthorizedView/10001/-3" represents viewname, store ID and device format ID respectively.
<forward className="com.ibm.commerce.struts.ECActionForward"
name="CompanyAOrderAuthorizedView/10001/-3" path="/Store_10001_Dir/OrderCreateXML.jsp">
<set-property property="resourceClassName" value="com.ibm.commerce.messaging.viewcommands.MessagingViewCommandImpl"/>
<set-property property="interfaceName" value="com.ibm.commerce.messaging.viewcommands.MessagingViewCommand"/>
<set-property property="implClassName" value="com.ibm.commerce.messaging.viewcommands.MessagingViewCommandImpl"/>
<set-property property="direct" value="true"/>
</forward>
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:
- Specify the STOREENT_ID as 0.
- Add PROPERTIES of storeDir=no to the JSP file name.
- Place the JSP file in the WC_eardir/Stores.war directory.
- 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.
- Call sendImediate or sendTransacted on SendMsgCmd if you 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.
- Call execute method of the SendMsgCmd to execute sending.