Show TOC Start of Content Area

Procedure documentation Sending Messages to Services  Locate the document in its SAP Library structure

This section describes how to send messages to a service.

Sync Service

...

       1.      Create a message.

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);

       2.      Add parameters to the message, if necessary.

message.putParam("param1","value1");

       3.      Get an instance of the sync service to which you want to send a message.

RTMFSyncService service = (RTMFSyncService)
    RTMFServices.getRTMFServicesInstance().getService(
"MySyncService");

       4.      Send the message.

List responseList = service.onMessageArrived(message);

The method returns a Listof messages (RTMFMessage).

Topic and Queue Service

...

       1.      Create a message.

RTMFMessage message = RTMFMessageFactory
    .getMessage(RTMFMessageType.
RTMFMessageType);

       2.      Add parameters to the message, if necessary.

message.putParam("param2","value2");

       3.      Send the message to the service.

The following sends a message to a topic service:

message.publishToTopic("MyRTMFService");

The following sends a message to a queue service:

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.

Generic API

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:

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.

End of Content Area