There are several prerequisite conditions that must be met before attempting to implement the following example:
- WebSphere Everyplace Connection Manager is configured to accept messages from WebSphere Commerce.
- WebSphere Everyplace Connection Manager transport is configured with the proper transport ID. For this example, the transport ID must be set to 7.
- The Message Type Notification message of the order status with message type id=123 is only associated with the WebSphere Everyplace Connection Manager transport.
- For this example, the store ID must be set to 201.
- For this example, the Recipient's member ID must be set to 20001001889.
The following is the sample code:
try { com.ibm.commerce.messaging.commands.SendMsgCmd api = (com.ibm.commerce.messaging.commands.SendMsgCmd) CommandFactory.createCommand(SendMsgCmd.NAME, getStoreId()); //Initialize the messaging services api.setMsgType("OrderReceived"); api.setStoreID(new Integer(201));
// Use 0 for subscribable messages and 100 for unsubscribable messages // The value used here should be the same value used for severity when the message type // is assigned to the target transport (that is, File or/and SMS Transports) api. setPriority(new Integer(100)); // EWG transport priority // Build the message in a String object and then use the setContent(). String OrderNotifyMsg = new String("Your order has been received. Thank you for shopping with us."); //Assuming TRANSPORT.TRANSPORT_ID for WebSphere Everyplace Connection Manager is 7. //or simply "null" for transport_id. Doing so will allow flexibility for site or store administrator //to change the transport by WebSphere Commerce Admin Console. api.setContent(null, null, OrderNotifyMsg); // Set the transport attributes using Configurable message data services // set up the recipients using addMember API api.addMember(new Long(20001001889)); // Send out the message using sendImmediate send service. api.sendImmediate(); // Set the command context obtained from the controller command. api.setCommandContext(getCommandContext()); // Run the outbound messaging system services api.execute(); } catch (Exception ex ) { //Catch WebSphere Commerce Messaging subsystem exceptions }