A mediation can convert a message from one format to another without changing the semantic meaning of the message. This operation is referred to as transcoding a message.
private static final String NEW_FORMAT = "JMS:text"; public boolean(MessageContext context) throws MessageContextException { try { SIMessageContext msgCtx = (SIMessageContext)context; SIMessage msg = msgCtx.getMessage(); DataGraph newDg = msg.getNewDataGraph(NEW_FORMAT); msg.setDataGraph(newDg,NEW_FORMAT); return true; } catch(Exception e) { // Reroute the original message to the exception destination MessageContextException mce = new MessageContextException("Unable to transcode to "+NEW_FORMAT",e); throw mce; } }
To JMS: | To JMS:text | To JMS:bytes | To JMS:stream | To JMS:object | To SOAP: | To Bean: | |
---|---|---|---|---|---|---|---|
From JMS: | DG=null (1) | DG=null (1) | DG=null (1) | DG=null (1) | DG=null (1) | DG=null (1) | DG=null (1) |
From JMS:text | DG=null (2) | Yes (3) | Yes, bytes contain UTF-8 | Yes, if text contains XML that conforms to the correct schema. | No | Yes, if message content is valid SOAP. | Yes, if message content is valid SOAP. |
From JMS:bytes | DG=null (2) | Yes, but only when the bytes can correctly be interpreted as a UTF-8 string. | Yes (3) | Yes, if bytes contain XML that conforms to the correct schema. | Yes, assume that bytes are a serialized object. | Yes, if message content is valid SOAP. | Yes, if message content is valid SOAP. |
From JMS:stream | DG=null (2) | Yes, text is XML transcoding. | Yes, bytes contain XML transcoding. | Yes (3) | No | No | No |
From JMS:object | DG=null (2) | No | Yes, bytes contain the object serialization. | No | Yes (3) | No | No |
From SOAP: | DG=null (2) | Yes | Yes | No | No | Yes (3) - if message content matches the new WSDL. | Yes |
From Bean: | DG=null (2) | Yes | Yes | No | No | Yes | Yes (3) - if message content matches the new WSDL. |