Skip to content

Message Relay

Message Relay enables WSO2 Micro Integrator to pass messages along without building or processing them unless specifically requested to do so. When Message Relay is enabled, an incoming message is wrapped inside a default SOAP envelope as binary content and sent through the Micro Integrator. This is useful for scenarios where the Micro Integrator does not need to work on the full message but can work on message properties like request URLs or transport headers instead. With Message Relay, the Micro Integrator can achieve a very high throughput.

See also PassThrough Transport.

Configuring Message Relay

The user can replace the expected content types with the Message Relay builder and formatter to pass these messages through WSO2 Micro Integrator without building them.


Content cannot be altered once the binary relay is enabled. Therefore, if you are enabling the binary relay, content-aware

Message Relay Builder and Formatter Class Names

  • Builder: org.wso2.carbon.relay.BinaryRelayBuilder
  • Formatter: org.wso2.carbon.relay.ExpandingMessageFormatter

Sample Configuration for Message Builder

application_xml = "org.wso2.carbon.relay.BinaryRelayBuilder"
form_urlencoded = "org.wso2.carbon.relay.BinaryRelayBuilder"
multipart_form_data = "org.wso2.carbon.relay.BinaryRelayBuilder"
text_plain = "org.wso2.carbon.relay.BinaryRelayBuilder"
application_json = "org.wso2.micro.integrator.core.json.JsonStreamBuilder"
json_badgerfish = "org.apache.axis2.json.JSONBadgerfishOMBuilder"
text_javascript = "org.apache.axis2.json.JSONBuilder"
octet_stream =  "org.wso2.carbon.relay.BinaryRelayBuilder"
application_binary = "org.apache.axis2.format.BinaryBuilder"

Sample Configuration for Message Formatter

form_urlencoded =  "org.wso2.carbon.relay.ExpandingMessageFormatter"
multipart_form_data =  "org.wso2.carbon.relay.ExpandingMessageFormatter"
application_xml = "org.wso2.carbon.relay.ExpandingMessageFormatter"
text_xml = "org.wso2.carbon.relay.ExpandingMessageFormatter"
text_plain = "org.wso2.carbon.relay.ExpandingMessageFormatter"
application_json =  "org.wso2.carbon.relay.ExpandingMessageFormatter"
json_badgerfish = "org.wso2.carbon.relay.ExpandingMessageFormatter"


If you want the Micro Integrator to receive messages of the image/png content type, add the following to the deployment.toml file:

class = "org.wso2.carbon.relay.BinaryRelayBuilder"
content_type = "image/png"
class = "org.wso2.carbon.relay.ExpandingMessageFormatter"
content_type = "image/png"

Message Relay Module Policy

Syntax of Relay Module Policy.

<wsp:Policy wsu:Id="MessageRelayPolicy" xmlns:wsp=""
                        <wsmr:includeHiddenServices>false | false</wsmr:includeHiddenServices>
                            <wsmr:service>Name of the service</wsmr:service>*
                            <wsmr:messageBuilder contentType="content type of the message" class="message builder implementation class" class="message formatter implementation class"/>

These are the assertions:

  • includeHiddenServices - If this is true message going to the services with hiddenService parameter will be built.
  • wsmr:services - Messages going to these services will be built.
  • wsmr:service - Name of the service.
  • wsmr:builders - Message builders to be used for building the message.
  • wsmr:builder - A message builder to be used for a content type.

After changing the policy, the user has to restart the Micro Integrator for the changes to take effect.

If the Message Relay is enabled for particular content type, there cannot be any services with security enabled for that content type.