public class AutoConvertMessageTranslator extends MessageTypeTranslatorImp
This handles the types TextMessage, BytesMessage, ObjectMessage by delegating to the correct MessageTypeTranslator implementation. The mapping from MapMessage to AdaptrisMessage is simplistic; the name value pairs (assumed to be String (or convertable to String)) are set as AdaptrisMessage metadata, the resulting payload is empty. The mapping from AdaptrisMessage to MapMessage results in all metadata being mapped as name value pairs in the MapMessage; the payload is ignored.
If you have used this translator for your consumer we add a new meta-data item to the AdaptrisMessage} named "adpmessagetype". The value of this item will be one of "Text", "Bytes", "Map" or "Object". This allows you to set the following item; "convert-back-to-consumed-type" on the AutoConvertMessageTranslator for your JMS producer to "true" (default is false). In this case this translator will attempt to translate the produced message to the same message type we consumed.
By default the metadata item "adpmessagetype" is removed before we convert the Adaptris message to a JMS message, so that the JMS message does not contain the key. You can override the removal of the key should you have multiple producers, by setting remove-original-message-type-key to "true".
If this converter cannot find an appropriate translator then a very basic translation will be applied. This will NOT include any payload translation. You will also see a warning in the logs to notify you a basic translation has been applied.
It is primarily a fallback translator to mitigate configuration errors.
In the adapter configuration file this class is aliased as auto-convert-message-translator which is the preferred alternative to the fully qualified classname when building your configuration.
Modifier and Type | Class and Description |
---|---|
static class |
AutoConvertMessageTranslator.SupportedMessageType
javax.jms.Message types that are supported by this translator.
|
helper, log, session
Constructor and Description |
---|
AutoConvertMessageTranslator()
Default constructor.
|
Modifier and Type | Method and Description |
---|---|
java.lang.Boolean |
getConvertBackToConsumedType() |
java.lang.String |
getJmsOutputType() |
java.lang.Boolean |
getRemoveOriginalMessageTypeKey() |
void |
setConvertBackToConsumedType(java.lang.Boolean convertBackToConsumedType) |
void |
setJmsOutputType(java.lang.String outputType)
Set the javax.jms.Message implementation that this MessageTranslator
creates when converting from AdaptrisMessage.
|
void |
setRemoveOriginalMessageTypeKey(java.lang.Boolean removeOriginalMessageTypeKey) |
javax.jms.Message |
translate(AdaptrisMessage msg)
Translates the passed
AdaptrisMessage into an instance of a
subclass of javax.jms.Message . |
AdaptrisMessage |
translate(javax.jms.Message msg)
Translates the passed
javax.jms.Message into an instance of
AdaptrisMessage . |
copyConfiguration, currentMessageFactory, currentSession, getMetadataConverters, getMetadataFilter, getMoveJmsHeaders, getReportAllErrors, metadataConverters, metadataFilter, moveJmsHeaders, registerMessageFactory, registerSession, reportAllErrors, setMetadataConverters, setMetadataFilter, setMoveJmsHeaders, setReportAllErrors, start, stop, translate, withMetadataConverters, withMetadataConverters, withMetadataFilter, withMoveJmsHeaders, withReportAllErrors
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
close, init, start, stop
public AutoConvertMessageTranslator()
public javax.jms.Message translate(AdaptrisMessage msg) throws javax.jms.JMSException
MessageTypeTranslator
Translates the passed AdaptrisMessage
into an instance of a
subclass of javax.jms.Message
.
msg
- the AdaptrisMessage
to translatejavax.jms.Message
javax.jms.JMSException
public AdaptrisMessage translate(javax.jms.Message msg) throws javax.jms.JMSException
MessageTypeTranslator
Translates the passed javax.jms.Message
into an instance of
AdaptrisMessage
.
msg
- the javax.jms.Message
to translateAdaptrisMessage
javax.jms.JMSException
public java.lang.String getJmsOutputType()
public void setJmsOutputType(java.lang.String outputType)
outputType
- the output type, one of Object, Text, Bytes, MapAutoConvertMessageTranslator.SupportedMessageType
public java.lang.Boolean getConvertBackToConsumedType()
public void setConvertBackToConsumedType(java.lang.Boolean convertBackToConsumedType)
public java.lang.Boolean getRemoveOriginalMessageTypeKey()
public void setRemoveOriginalMessageTypeKey(java.lang.Boolean removeOriginalMessageTypeKey)