public final class BlobMessageTranslator extends MessageTypeTranslatorImp
Translates between AdaptrisMessage
and BlobMessage
.
In outbound scenarios (i.e. writing to ActiveMQ), there are two ways in which this translator
works with the AdaptrisMessage
.
setMetadataUrlKey(String)
has been set, then the value
associated with that metadata key is used to create a URL object so that
ActiveMQSession.createBlobMessage(URL)
can be used. If you are intending to use this,
then the data will already have been written to this URL (by the adapter or otherwise). If the
metadata key does not exist, then it assumes the next scenario.setMetadataUrlKey(String)
has not been set, then the contents of
the AdaptrisMessage object are used to form the BlobMessage, either by using
ActiveMQSession.createBlobMessage(java.io.File)
or
ActiveMQSession.createBlobMessage(InputStream)
depending on the underlying type of
AdaptrisMessage. If you are intending to use this, then you will have already configured ActiveMQ
/ underlying OS platform (e.g. for WebDAV/FTP) appropriately for handling out of band transfers.
For inbound scenarios, BlobMessage.getInputStream()
is used, this may create additional
connections to remote servers from the machine where the adapter is running.
In the adapter configuration file this class is aliased as activemq-blob-message-translator which is the preferred alternative to the fully qualified classname when building your configuration.
helper, log, session
Constructor and Description |
---|
BlobMessageTranslator() |
BlobMessageTranslator(java.lang.String metadataKey) |
Modifier and Type | Method and Description |
---|---|
void |
close()
Closes the component.
|
java.lang.String |
getMetadataUrlKey()
Get the metadata key that will be used to generate the URL.
|
void |
init()
Initialises the component.
|
void |
setMetadataUrlKey(java.lang.String metadataKey)
Set the metadata key that will be used to generate the URL.
|
void |
start()
Starts the component.
|
void |
stop()
Stop the component
|
javax.jms.Message |
translate(AdaptrisMessage msg)
Translates an
AdaptrisMessage into a BlobMessage . |
AdaptrisMessage |
translate(javax.jms.Message msg)
Translates a
BlobMessage into an 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
public BlobMessageTranslator()
public BlobMessageTranslator(java.lang.String metadataKey)
setMetadataUrlKey(String)
public javax.jms.Message translate(AdaptrisMessage msg) throws javax.jms.JMSException
Translates an AdaptrisMessage
into a BlobMessage
.
msg
- the AdaptrisMessage
to translateBlobMessage
javax.jms.JMSException
- on error.ActiveMQSession.createBlobMessage(URL)
,
ActiveMQSession.createBlobMessage(java.io.File)
,
ActiveMQSession.createBlobMessage(InputStream)
public AdaptrisMessage translate(javax.jms.Message msg) throws javax.jms.JMSException
Translates a BlobMessage
into an AdaptrisMessage
.
msg
- the BlobMessage
to translateAdaptrisMessage
javax.jms.JMSException
- on exceptionpublic void init() throws CoreException
ComponentLifecycle
Component initialisation includes config verification, creation of connections etc.
CoreException
- wrapping any underlying Exception
spublic void start() throws CoreException
ComponentLifecycle
Once a component is started it should be ready to process messages. In the case of AdaptrisMessageConsumer
, calling start
will begin message delivery.
CoreException
- wrapping any underlying Exception
spublic void stop()
ComponentLifecycle
A stopped component is not expected to be ready to process messages. In the case of AdaptrisMessageConsumer
, calling stop
will pause message delivery. Throwing a RuntimeException
may cause unintended consequences
public void close()
ComponentLifecycle
A closed component should release any connections it uses, etc. and clean up completely. Throwing a RuntimeException
may
cause unintended consequences
public java.lang.String getMetadataUrlKey()
ActiveMQSession.createBlobMessage(URL)
public void setMetadataUrlKey(java.lang.String metadataKey)
This setting only has effect when the framework invokes
translate(AdaptrisMessage)
(during the produce of the message).
metadataKey
- ActiveMQSession.createBlobMessage(URL)