Creating an Output Message
Every module must create a new output message before completing. The output message becomes the input for the next module in the route. If the current module is the last module in the route, the output message is used to construct the HTTP response that the Akula Server sends to the client. The output message body becomes the body of the HTTP response, and the output message headers become the HTTP response headers.
You create a new output message by using the
newMessage() method. This creates a message with an empty body.
You add content to the new message by using the
setBody() method. This method takes an Object such as a String or a Document as an argument. The value of the new object replaces the entire body of the message.
The following example replaces the entire response body with "Hello World":
You can also simply take the input message of the previous module and set it to be the output message of the current module. In effect, you create a pass-through module. The following example does nothing but set the input to the output and passes the message body to the next module in the route:
More commonly, you will set the response body to an XML document or JSON object so that you can process the results in your client with the Akula libraries.