This section describes how to send messages to a service.
Create a message.
Syntax
import com.sap.netweaver.rtmf.messagingimpl.exception.RTMFException;
import com.sap.netweaver.rtmf.messagingimpl.messages.RTMFMessage;
import com.sap.netweaver.rtmf.messagingimpl.messages.RTMFMessageFactory;
import com.sap.netweaver.rtmf.messagingimpl.messages.RTMFMessageType;
import com.sap.netweaver.rtmf.messagingimpl.services.RTMFSyncService;
RTMFMessage message = RTMFMessageFactory.getMessage(RTMFMessageType.RTMFMessageType);
Add parameters to the message, if necessary.
Syntax
message.putParam("param1","value1");
Get an instance of the sync service to which you want to send a message.
Syntax
RTMFSyncService service = (RTMFSyncService)
RTMFServices.getRTMFServicesInstance().getService("MySyncService");
Send the message.
Syntax
List responseList = service.onMessageArrived(message);
The method returns a List of messages (RTMFMessage).
Create a message.
Syntax
RTMFMessage message = RTMFMessageFactory.getMessage(RTMFMessageType.RTMFMessageType);
Add parameters to the message, if necessary.
Syntax
message.putParam("param2","value2");
Send the message to the service.
The following sends a message to a topic service:
Syntax
message.publishToTopic("MyRTMFService");
The following sends a message to a queue service:
Syntax
message.sendToQueue("MyRTMFService");
After sending the message, the application continues with its logic. The topic or queue service can react to the message by publishing an event, to which the application can subscribe.
The RTMFMessage class provides a method for sending a message to a service when you do not know the type of service.
The following sends a message to an RTMF service, no matter the service type:
Syntax
message.sendToService("MyRTMFService");
For a sync service, the method waits for a return value. For topic and queue services, the application continues with its logic.