In some cases it`s useful to map a single incoming request to several responses. One such example is delegating to helper service methods. In Java, one can do this using the following basic pattern:
@Service(request = "my.request", response = "*")
public void myService(Message requestMessage, Message responseMessage) {
String responseMessageType = "";
if (some condition)
responseMessageType = myServiceHelper(requestMessage, responseMessage);
else
responseMessageType = myOtherServiceHelper(requestMessage,responseMessage);
responseMessage.setType(responseMessageType);
}
Obviously, the helpers above need to return a String with the appropriate message type (name). It is, of course, also possible to just set the type in the helper.
Also, the helpers should populate the data payload of the response (one reason for using this pattern).

Recent Comments