@ComponentProfile(summary="Produce a message where as part of a service chain", tag="service") public class StandaloneProducer extends ServiceImp implements AdaptrisMessageSender, ConnectedService
Wrapper for a AdaptrisConnection
and a AdaptrisMessageProducer
for convenience. Also implements
Service
for use in ServiceCollection
s.
AdaptrisMessageSender
In the adapter configuration file this class is aliased as standalone-producer which is the preferred alternative to the fully qualified classname when building your configuration.
log
Constructor and Description |
---|
StandaloneProducer()
Creates a new instance.
|
StandaloneProducer(AdaptrisConnection c,
AdaptrisMessageProducer p) |
StandaloneProducer(AdaptrisMessageProducer p) |
Modifier and Type | Method and Description |
---|---|
protected void |
closeService() |
java.lang.String |
createName()
Create a name for any
MleMarker that is generated. |
java.lang.String |
createQualifier()
Create a qualifier for any
MleMarker that is generated. |
void |
doService(AdaptrisMessage msg)
Apply the service to the message.
|
AdaptrisConnection |
getConnection()
Returns the connection to use.
|
AdaptrisMessageProducer |
getProducer()
Returns the producer to use.
|
protected void |
initService() |
void |
prepare()
Prepare for initialisation.
|
void |
produce(AdaptrisMessage msg)
Produces the
AdaptrisMessage to the default destination. |
void |
produce(AdaptrisMessage msg,
ProduceDestination dest)
Produce the
AdaptrisMessage to the supplied
ProduceDestination , over-riding any configured destinations. |
void |
setConnection(AdaptrisConnection conn)
Sets the connection to use, may not be null.
|
void |
setProducer(AdaptrisMessageProducer prod)
Sets the producer to use, may not be null.
|
void |
start()
Starts the component.
|
void |
stop()
Stop the component
|
changeState, close, continueOnFailure, getContinueOnFail, getIsTrackingEndpoint, getUniqueId, init, isBranching, isTrackingEndpoint, requestClose, requestInit, requestStart, requestStop, retrieveComponentState, setContinueOnFail, setIsTrackingEndpoint, setUniqueId
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
continueOnFailure, isBranching, setUniqueId
isTrackingEndpoint
changeState, requestClose, requestInit, requestStart, requestStop, retrieveComponentState
getUniqueId
close, init
public StandaloneProducer()
Creates a new instance. Defaults to null connection / producer.
public StandaloneProducer(AdaptrisMessageProducer p)
public StandaloneProducer(AdaptrisConnection c, AdaptrisMessageProducer p)
public void produce(AdaptrisMessage msg) throws ProduceException
AdaptrisMessageSender
AdaptrisMessage
to the default destination.produce
in interface AdaptrisMessageSender
msg
- the @link AdaptrisMessage} to produceProduceException
- wrapping any underlying Exceptionspublic void produce(AdaptrisMessage msg, ProduceDestination dest) throws ProduceException
AdaptrisMessageSender
AdaptrisMessage
to the supplied
ProduceDestination
, over-riding any configured destinations.produce
in interface AdaptrisMessageSender
msg
- the AdaptrisMessage
to producedest
- the ProduceDestination
to produce toProduceException
- wrapping any underlying Exceptionsprotected void initService() throws CoreException
initService
in class ServiceImp
CoreException
public 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.
start
in interface ComponentLifecycle
start
in class ServiceImp
CoreException
- wrapping any underlying Exception
sComponentLifecycle.start()
public 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
stop
in interface ComponentLifecycle
stop
in class ServiceImp
ComponentLifecycle.stop()
protected void closeService()
closeService
in class ServiceImp
public void prepare() throws CoreException
ComponentLifecycleExtension
prepare
in interface ComponentLifecycleExtension
CoreException
public AdaptrisConnection getConnection()
Returns the connection to use.
getConnection
in interface ConnectedService
public AdaptrisMessageProducer getProducer()
Returns the producer to use.
public void setConnection(AdaptrisConnection conn)
Sets the connection to use, may not be null.
setConnection
in interface ConnectedService
conn
- the connection to use, may not be nullpublic void setProducer(AdaptrisMessageProducer prod)
Sets the producer to use, may not be null.
prod
- the producer to use, may not be nullpublic void doService(AdaptrisMessage msg) throws ServiceException
Service
Apply the service to the message.
doService
in interface Service
msg
- the AdaptrisMessage
to processServiceException
- wrapping any underlying Exception
s#doService(com.adaptris.core.AdaptrisMessage)
public java.lang.String createName()
MessageEventGenerator
MleMarker
that is generated.
The default implementation is to return the classname of the component in question.
* @return the name for anyMleMarker
that is generated.createName
in interface MessageEventGenerator
createName
in class ServiceImp
public java.lang.String createQualifier()
MessageEventGenerator
MleMarker
that is generated.
The default implementation is to return the unique-id of the component in question, or the empty string if not configured
createQualifier
in interface MessageEventGenerator
createQualifier
in class ServiceImp
MleMarker
that is generated.