Class PublishToDefaultExchange

java.lang.Object
com.adaptris.core.ServiceImp
interlok.rabbitmq.PublishToDefaultExchange
All Implemented Interfaces:
com.adaptris.core.AdaptrisComponent, com.adaptris.core.ComponentLifecycle, com.adaptris.core.ComponentLifecycleExtension, com.adaptris.core.ConfigComment, com.adaptris.core.ConnectedService, com.adaptris.core.MessageEventGenerator, com.adaptris.core.Service, com.adaptris.core.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 com.adaptris.core.ServiceImp implements com.adaptris.core.ConnectedService
Wraps StandardMessageProducer as 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 StandardMessageProducer and is included as a convenience to simply publish a message to a RabbitMQ Queue. It does expose a RabbitMqConnection as configuration so you will have the opportunity to share connections.

  • Nested Class Summary

    Nested Classes
    Modifier and Type
    Class
    Description
    static enum 
    Controls behaviour when publishing the messsage.
  • Field Summary

    Fields inherited from class com.adaptris.core.ServiceImp

    log
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    final void
     
    void
    doService(com.adaptris.core.AdaptrisMessage msg)
     
    What to do after publishing the message depending on whether that was successful or not.
    com.adaptris.core.AdaptrisConnection
    The RabbitMQ Connection.
    How to build the required BasicProperties if required.
    The queue to publish to.
    final void
     
    final void
     
    void
    What to do after publishing the message depending on whether that was successful or not.
    void
    setConnection(com.adaptris.core.AdaptrisConnection connection)
    The RabbitMQ Connection.
    void
    How to build the required BasicProperties if required.
    void
    The queue to publish to.
    void
     
    void
     
     
     

    Methods inherited from class com.adaptris.core.ServiceImp

    changeState, close, continueOnFailure, createName, createQualifier, enabled, getComments, getContinueOnFail, getEnabled, getIsTrackingEndpoint, getUniqueId, init, isBranching, isTrackingEndpoint, requestClose, requestInit, requestStart, requestStop, retrieveComponentState, setComments, setContinueOnFail, setEnabled, 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.ConfigComment

    getComments, setComments

    Methods inherited from interface com.adaptris.core.MessageEventGenerator

    createName, createQualifier, isTrackingEndpoint

    Methods inherited from interface com.adaptris.core.Service

    continueOnFailure, enabled, isBranching, setUniqueId

    Methods inherited from interface com.adaptris.core.StateManagedComponent

    changeState, requestClose, requestInit, requestStart, requestStop, retrieveComponentState
  • Constructor Details

    • PublishToDefaultExchange

      public PublishToDefaultExchange()
  • Method Details

    • doService

      public void doService(com.adaptris.core.AdaptrisMessage msg) throws com.adaptris.core.ServiceException
      Specified by:
      doService in interface com.adaptris.core.Service
      Throws:
      com.adaptris.core.ServiceException
    • prepare

      public final void prepare() throws com.adaptris.core.CoreException
      Specified by:
      prepare in interface com.adaptris.core.ComponentLifecycleExtension
      Throws:
      com.adaptris.core.CoreException
    • initService

      public final void initService() throws com.adaptris.core.CoreException
      Specified by:
      initService in class com.adaptris.core.ServiceImp
      Throws:
      com.adaptris.core.CoreException
    • closeService

      public final void closeService()
      Specified by:
      closeService in class com.adaptris.core.ServiceImp
    • start

      public void start() throws com.adaptris.core.CoreException
      Specified by:
      start in interface com.adaptris.core.ComponentLifecycle
      Overrides:
      start in class com.adaptris.core.ServiceImp
      Throws:
      com.adaptris.core.CoreException
    • stop

      public void stop()
      Specified by:
      stop in interface com.adaptris.core.ComponentLifecycle
      Overrides:
      stop in class com.adaptris.core.ServiceImp
    • withConnection

      public PublishToDefaultExchange withConnection(RabbitMqConnection c)
    • withQueue

      public PublishToDefaultExchange withQueue(String q)
    • getQueue

      public String getQueue()
      The queue to publish to.
    • setQueue

      public void setQueue(String queue)
      The queue to publish to.
    • getPropertyBuilder

      public Translator.BasicPropertiesBuilder getPropertyBuilder()
      How to build the required BasicProperties if required.

      The default if not explicitly specified is to return a null object which uses the default behaviour of RabbitMQ.

    • setPropertyBuilder

      public void setPropertyBuilder(Translator.BasicPropertiesBuilder propertyBuilder)
      How to build the required BasicProperties if required.

      The default if not explicitly specified is to return a null object 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 com.adaptris.core.AdaptrisConnection getConnection()
      The RabbitMQ Connection.
      Specified by:
      getConnection in interface com.adaptris.core.ConnectedService
    • setConnection

      public void setConnection(com.adaptris.core.AdaptrisConnection connection)
      The RabbitMQ Connection.
      Specified by:
      setConnection in interface com.adaptris.core.ConnectedService