Package interlok.rabbitmq
Class PublishToDefaultExchange
- java.lang.Object
-
- com.adaptris.core.ServiceImp
-
- interlok.rabbitmq.PublishToDefaultExchange
-
- All Implemented Interfaces:
AdaptrisComponent,ComponentLifecycle,ComponentLifecycleExtension,ConnectedService,MessageEventGenerator,Service,StateManagedComponent
@ComponentProfile(summary="Put the message payload onto an AMQP Queue", recommended=RabbitMqConnection.class, since="4.3.0", tag="amqp,rabbitmq") public class PublishToDefaultExchange extends ServiceImp implements ConnectedServiceWrapsStandardMessageProduceras a service for discoverability purposes.This is the simplest way to publish a message to RabbitMQ to an exchange of
""which is equivalent to the default exchange.It does not expose all the configuration possible to
StandardMessageProducerand is included as a convenience to simply publish a message to a RabbitMQ Queue. It does expose aRabbitMqConnectionas configuration so you will have the opportunity to share connections.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classPublishToDefaultExchange.BehaviourControls behaviour when publishing the messsage.
-
Field Summary
-
Fields inherited from class com.adaptris.core.ServiceImp
log
-
-
Constructor Summary
Constructors Constructor Description PublishToDefaultExchange()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidcloseService()voiddoService(AdaptrisMessage msg)PublishToDefaultExchange.BehaviourgetBehaviour()What to do after publishing the message depending on whether that was successful or not.AdaptrisConnectiongetConnection()The RabbitMQ Connection.Translator.BasicPropertiesBuildergetPropertyBuilder()How to build the requiredBasicPropertiesif required.java.lang.StringgetQueue()The queue to publish to.voidinitService()voidprepare()voidsetBehaviour(PublishToDefaultExchange.Behaviour behaviour)What to do after publishing the message depending on whether that was successful or not.voidsetConnection(AdaptrisConnection connection)The RabbitMQ Connection.voidsetPropertyBuilder(Translator.BasicPropertiesBuilder propertyBuilder)How to build the requiredBasicPropertiesif required.voidsetQueue(java.lang.String queue)The queue to publish to.voidstart()voidstop()PublishToDefaultExchangewithConnection(RabbitMqConnection c)PublishToDefaultExchangewithQueue(java.lang.String q)-
Methods inherited from class com.adaptris.core.ServiceImp
changeState, close, continueOnFailure, createName, createQualifier, getContinueOnFail, getIsTrackingEndpoint, getUniqueId, init, isBranching, isTrackingEndpoint, requestClose, requestInit, requestStart, requestStop, retrieveComponentState, setContinueOnFail, setIsTrackingEndpoint, setUniqueId
-
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.AdaptrisComponent
getUniqueId
-
Methods inherited from interface com.adaptris.core.ComponentLifecycle
close, init
-
Methods inherited from interface com.adaptris.core.MessageEventGenerator
createName, createQualifier, isTrackingEndpoint
-
Methods inherited from interface com.adaptris.core.Service
continueOnFailure, isBranching, setUniqueId
-
Methods inherited from interface com.adaptris.core.StateManagedComponent
changeState, requestClose, requestInit, requestStart, requestStop, retrieveComponentState
-
-
-
-
Method Detail
-
doService
public void doService(AdaptrisMessage msg) throws ServiceException
- Specified by:
doServicein interfaceService- Throws:
ServiceException
-
prepare
public final void prepare() throws CoreException- Specified by:
preparein interfaceComponentLifecycleExtension- Throws:
CoreException
-
initService
public final void initService() throws CoreException- Specified by:
initServicein classServiceImp- Throws:
CoreException
-
closeService
public final void closeService()
- Specified by:
closeServicein classServiceImp
-
start
public void start() throws CoreException- Specified by:
startin interfaceComponentLifecycle- Overrides:
startin classServiceImp- Throws:
CoreException
-
stop
public void stop()
- Specified by:
stopin interfaceComponentLifecycle- Overrides:
stopin classServiceImp
-
withConnection
public PublishToDefaultExchange withConnection(RabbitMqConnection c)
-
withQueue
public PublishToDefaultExchange withQueue(java.lang.String q)
-
getQueue
public java.lang.String getQueue()
The queue to publish to.
-
setQueue
public void setQueue(java.lang.String queue)
The queue to publish to.
-
getPropertyBuilder
public Translator.BasicPropertiesBuilder getPropertyBuilder()
How to build the requiredBasicPropertiesif required.The default if not explicitly specified is to return a
nullobject which uses the default behaviour of RabbitMQ.
-
setPropertyBuilder
public void setPropertyBuilder(Translator.BasicPropertiesBuilder propertyBuilder)
How to build the requiredBasicPropertiesif required.The default if not explicitly specified is to return a
nullobject which uses the default behaviour of RabbitMQ.
-
getBehaviour
public PublishToDefaultExchange.Behaviour getBehaviour()
What to do after publishing the message depending on whether that was successful or not.- TRADITIONAL : act like a traditional service and throw an exception if publishing was not successful
- NO_EXCEPTION: Never throw an exception, add metadata against the key "queue_publish_status" indicating success or failure. Failure will contain the stacktrace from the exception but no exception will be thrown by the service.
-
setBehaviour
public void setBehaviour(PublishToDefaultExchange.Behaviour behaviour)
What to do after publishing the message depending on whether that was successful or not.- TRADITIONAL : act like a traditional service and throw an exception if publishing was not successful
- NO_EXCEPTION: Never throw an exception, add metadata against the key "queue_publish_status" indicating success or failure. Failure will contain the stacktrace from the exception but no exception will be thrown by the service.
-
getConnection
public AdaptrisConnection getConnection()
The RabbitMQ Connection.- Specified by:
getConnectionin interfaceConnectedService
-
setConnection
public void setConnection(AdaptrisConnection connection)
The RabbitMQ Connection.- Specified by:
setConnectionin interfaceConnectedService
-
-