Class AutoConvertMessageTranslator
- java.lang.Object
-
- com.adaptris.core.jms.MessageTypeTranslatorImp
-
- com.adaptris.core.jms.AutoConvertMessageTranslator
-
- All Implemented Interfaces:
AdaptrisMessageTranslator
,ComponentLifecycle
,MessageTypeTranslator
,MetadataHandlerContext
public class AutoConvertMessageTranslator extends MessageTypeTranslatorImp
Perform a best guess routine on the JMSMessage when translating to an AdaptrisMessage.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.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
AutoConvertMessageTranslator.SupportedMessageType
javax.jms.Message types that are supported by this translator.
-
Field Summary
-
Fields inherited from class com.adaptris.core.jms.MessageTypeTranslatorImp
helper, log, session
-
-
Constructor Summary
Constructors Constructor Description AutoConvertMessageTranslator()
Default constructor.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method 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 passedAdaptrisMessage
into an instance of a subclass ofjavax.jms.Message
.AdaptrisMessage
translate(javax.jms.Message msg)
Translates the passedjavax.jms.Message
into an instance ofAdaptrisMessage
.-
Methods inherited from class com.adaptris.core.jms.MessageTypeTranslatorImp
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
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface com.adaptris.core.ComponentLifecycle
close, init, start, stop
-
-
-
-
Method Detail
-
translate
public javax.jms.Message translate(AdaptrisMessage msg) throws javax.jms.JMSException
Description copied from interface:MessageTypeTranslator
Translates the passed
AdaptrisMessage
into an instance of a subclass ofjavax.jms.Message
.- Parameters:
msg
- theAdaptrisMessage
to translate- Returns:
- a
javax.jms.Message
- Throws:
javax.jms.JMSException
-
translate
public AdaptrisMessage translate(javax.jms.Message msg) throws javax.jms.JMSException
Description copied from interface:MessageTypeTranslator
Translates the passed
javax.jms.Message
into an instance ofAdaptrisMessage
.- Parameters:
msg
- thejavax.jms.Message
to translate- Returns:
- a
AdaptrisMessage
- Throws:
javax.jms.JMSException
-
getJmsOutputType
public java.lang.String getJmsOutputType()
-
setJmsOutputType
public void setJmsOutputType(java.lang.String outputType)
Set the javax.jms.Message implementation that this MessageTranslator creates when converting from AdaptrisMessage.- Parameters:
outputType
- the output type, one of Object, Text, Bytes, Map- See Also:
AutoConvertMessageTranslator.SupportedMessageType
-
getConvertBackToConsumedType
public java.lang.Boolean getConvertBackToConsumedType()
-
setConvertBackToConsumedType
public void setConvertBackToConsumedType(java.lang.Boolean convertBackToConsumedType)
-
getRemoveOriginalMessageTypeKey
public java.lang.Boolean getRemoveOriginalMessageTypeKey()
-
setRemoveOriginalMessageTypeKey
public void setRemoveOriginalMessageTypeKey(java.lang.Boolean removeOriginalMessageTypeKey)
-
-