Create an outbound message
In addition to the supported XML and WebSphere Commerce outbound messages, we can add support for new outbound messages. To add a new outbound message, we must write a new controller command to build the content of the new outbound message and send the message to the back-end system using the send services of the outbound messaging system.
Task info
There are two methods for building the content of new outbound messages. The first method is to build your new outbound message in our own String buffer and assign it to the outbound messaging system through the use of its message content setting services that set the message content directly. This alternative requires you to include the logic of building the message in the controller command that you write. The second method is to build your new outbound message through the use of the outbound messaging system composition services. Through the use of JSP pages, the composition services generates an outbound message according to the message layout and content you defined in the JSP page.Outbound messaging system interface Interactions with the outbound messaging system can be done through the SendMsgCmd task command. This task command externalizes all available interfaces to methods provided by the messaging system to set necessary parameters to construct and use the messaging system object. The following is a list of all available services in the SendMsgCmd command interface:
- Initialization services
- Message content setting services
- Add e-mail parts or attachments services
- Configuration of transport services used for a message
- Sending services
- Other services
Procedure
- Create a new controller command or customize an existing task command to send a message with a certain message ID or name.
- Add a row into MSGTYPES table assign a msgtype_id with a new viewname, based on the command. Use a message type ID number above 1000. Prepend the viewname and message type name with your company name.
- Create a new row with the name in WebSphere Commerce Struts framework and assign the devicefmt_id, and JSP page (with the full path).
- Create a profile in the PROFILE table using the Administration Console, and assign the message type to the correct transport (for example, e-mail) and device format (for example, standard device format). See Assigning a message type to a transport method for a site or store. A valid device format ID, as specified in the Struts configuration file, must be specified for each transport to be used. This device format ID (for example, DEVICEFMT_ID) must match with the one added into Struts configuration files in order to be able to pick the right JSP template file for composition. The following are the values you should use in the Struts configuration file:
SOAP XML data transmitted via HTTP = -1 HTTP Browser = Reserved for IBM Standard Device Format = -3 IBM MQ Adapter for XML = -4 IBM MQ Adapter for WCS (Legacy message) = -5
Note: Most predefined message types (regardless for which transport they were designed) are designed to use the standard device format. What choice to pick is strictly dependent on how the entries for the Struts configuration file are created. The default values of device format ID may change in future releases.
- Create a messaging system object using the SendMsgCmd task command. Use the setMsgType(String) and setStoreId(Integer) described in the topic Initialization services.
- Invoke the SendMsgCmd.execute() method.
- Enable outbound messaging SendReceiveImmediate services
WebSphere Commerce can interact with other systems through the outbound messaging SendReceiveImmediate (formally Send/Receive) services. This allows WebSphere Commerce to send a message to another system and wait for a reply. The behavior of SendMsgCmd.sendReceiveImmediate() is similar to the SendMsgCmd.sendImmediate() method except that it waits for a return reply from the system receiving its message request.- Creating different outbound queues for different message types for IBM MQ
We can create different outbound queues for different message types for IBM MQ.- Defining outbound connector specifications without specifying inbound queue parameters for IBM MQ
We can change the outbound connector specifications to omit the inbound queue parameter if we are using IBM MQ for only outbound messages and do not want to create an inbound queue. In this scenario, you do not have to define a JMS object for the inbound queue.- Error handling in the messaging system composition service
When an error occurs in the processing of a JavaServer page, the result of the page typically contains extensive information generated when the system is running. If this is not the desired result on a JavaServer page failure, there are two potential approaches to make the behavior more predictable.- Invoke the messaging system compose method
To invoke the compose() method of the outbound messaging system interface, specify the following parameters:- 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:- Examples: Outbound messaging using SendMsgCmd
The following Java code segment shows how interactions with the outbound messaging system can take place. Example 1 shows you how to build a new XML message and send it through the outbound messaging system. Example 2 shows you how to build an email message and send it through the outbound messaging system: