Class RabbitMQConnection

  • All Implemented Interfaces:
    adams.core.CleanUpHandler, adams.core.Destroyable, adams.core.GlobalInfoSupporter, adams.core.logging.LoggingLevelHandler, adams.core.logging.LoggingSupporter, adams.core.option.OptionHandler, adams.core.QuickInfoSupporter, adams.core.SizeOfHandler, adams.scripting.connection.Connection, Serializable, Comparable<adams.scripting.connection.Connection>

    public class RabbitMQConnection
    extends adams.scripting.connection.AbstractConnection
    Uses RabbitMQ to send commands via a exchange or queue.
    Author:
    FracPete (fracpete at waikato dot ac dot nz)
    See Also:
    Serialized Form
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void cleanUp()
      Cleans up data structures, frees up memory.
      protected String connect()
      Starts up a RabbitMQ connection.
      String connectionFactoryTipText()
      Returns the tip text for this property.
      void defineOptions()
      Adds options to the internal list of options.
      protected void disconnect()
      Disconnects the FTP session, if necessary.
      protected String doSend​(adams.scripting.command.RemoteCommand cmd, adams.scripting.processor.RemoteCommandProcessor processor)
      Sends the command to the specified sscripting engine.
      protected String doSendRequest​(adams.scripting.command.RemoteCommand cmd, adams.scripting.processor.RemoteCommandProcessor processor)
      Sends the request command.
      protected String doSendResponse​(adams.scripting.command.RemoteCommand cmd, adams.scripting.processor.RemoteCommandProcessor processor)
      Sends the response command.
      String exchangeTipText()
      Returns the tip text for this property.
      protected com.rabbitmq.client.Channel getChannel()
      Returns the channel object.
      AbstractConnectionFactory getConnectionFactory()
      Returns the connection factory to use.
      String getExchange()
      Returns the name of the exchange.
      int getPrefetchCount()
      Returns the maximum number of unacked jobs a client can pull off a queue.
      String getQueue()
      Returns the name of the queue.
      String getQuickInfo()
      Returns a quick info about the object, which can be displayed in the GUI.
      AbstractConverter getSendConverter()
      Returns the converter to use for sending.
      String globalInfo()
      Returns a string describing the object.
      String prefetchCountTipText()
      Returns the tip text for this property.
      String queueTipText()
      Returns the tip text for this property.
      String sendConverterTipText()
      Returns the tip text for this property.
      void setConnectionFactory​(AbstractConnectionFactory value)
      Sets the connection factory to use.
      void setExchange​(String value)
      Sets the name of the exchange.
      void setPrefetchCount​(int value)
      Sets the maximum number of unacked jobs a client can pull off a queue.
      void setQueue​(String value)
      Sets the name of the queue.
      void setSendConverter​(AbstractConverter value)
      Sets the converter to use for sending.
      • Methods inherited from class adams.scripting.connection.AbstractConnection

        checkRequest, checkResponse, compareTo, equals, sendRequest, sendResponse, toString
      • Methods inherited from class adams.core.option.AbstractOptionHandler

        cleanUpOptions, destroy, finishInit, getDefaultLoggingLevel, getOptionManager, initialize, loggingLevelTipText, newOptionManager, reset, setLoggingLevel, toCommandLine
      • Methods inherited from class adams.core.logging.LoggingObject

        configureLogger, getLogger, getLoggingLevel, initializeLogging, isLoggingEnabled, sizeOf
      • Methods inherited from interface adams.core.Destroyable

        destroy
      • Methods inherited from interface adams.core.logging.LoggingLevelHandler

        getLoggingLevel
      • Methods inherited from interface adams.core.option.OptionHandler

        cleanUpOptions, getOptionManager, toCommandLine
    • Field Detail

      • m_PrefetchCount

        protected int m_PrefetchCount
        the prefetch count.
      • m_Exchange

        protected String m_Exchange
        the name of the exchange.
      • m_Queue

        protected String m_Queue
        the queue in use.
      • m_SendConverter

        protected AbstractConverter m_SendConverter
        the converter for sending.
      • m_Connection

        protected transient com.rabbitmq.client.Connection m_Connection
        the connection.
      • m_Channel

        protected transient com.rabbitmq.client.Channel m_Channel
        the channel action to use.
    • Constructor Detail

      • RabbitMQConnection

        public RabbitMQConnection()
    • Method Detail

      • globalInfo

        public String globalInfo()
        Returns a string describing the object.
        Specified by:
        globalInfo in interface adams.core.GlobalInfoSupporter
        Specified by:
        globalInfo in class adams.core.option.AbstractOptionHandler
        Returns:
        a description suitable for displaying in the gui
      • defineOptions

        public void defineOptions()
        Adds options to the internal list of options.
        Specified by:
        defineOptions in interface adams.core.option.OptionHandler
        Overrides:
        defineOptions in class adams.core.option.AbstractOptionHandler
      • setConnectionFactory

        public void setConnectionFactory​(AbstractConnectionFactory value)
        Sets the connection factory to use.
        Parameters:
        value - the factory
      • getConnectionFactory

        public AbstractConnectionFactory getConnectionFactory()
        Returns the connection factory to use.
        Returns:
        the factory
      • connectionFactoryTipText

        public String connectionFactoryTipText()
        Returns the tip text for this property.
        Returns:
        tip text for this property suitable for displaying in the GUI or for listing the options.
      • setPrefetchCount

        public void setPrefetchCount​(int value)
        Sets the maximum number of unacked jobs a client can pull off a queue.
        Parameters:
        value - the count, 0 = unlimited, 1 = fair
      • getPrefetchCount

        public int getPrefetchCount()
        Returns the maximum number of unacked jobs a client can pull off a queue.
        Returns:
        the count, 0 = unlimited, 1 = fair
      • prefetchCountTipText

        public String prefetchCountTipText()
        Returns the tip text for this property.
        Returns:
        tip text for this property suitable for displaying in the GUI or for listing the options.
      • setExchange

        public void setExchange​(String value)
        Sets the name of the exchange.
        Parameters:
        value - the name
      • getExchange

        public String getExchange()
        Returns the name of the exchange.
        Returns:
        the name
      • exchangeTipText

        public String exchangeTipText()
        Returns the tip text for this property.
        Returns:
        tip text for this property suitable for displaying in the GUI or for listing the options.
      • setQueue

        public void setQueue​(String value)
        Sets the name of the queue.
        Parameters:
        value - the name
      • getQueue

        public String getQueue()
        Returns the name of the queue.
        Returns:
        the name
      • queueTipText

        public String queueTipText()
        Returns the tip text for this property.
        Returns:
        tip text for this property suitable for displaying in the GUI or for listing the options.
      • setSendConverter

        public void setSendConverter​(AbstractConverter value)
        Sets the converter to use for sending.
        Parameters:
        value - the converter
      • getSendConverter

        public AbstractConverter getSendConverter()
        Returns the converter to use for sending.
        Returns:
        the converter
      • sendConverterTipText

        public String sendConverterTipText()
        Returns the tip text for this property.
        Returns:
        tip text for this property suitable for displaying in the GUI or for listing the options.
      • getQuickInfo

        public String getQuickInfo()
        Returns a quick info about the object, which can be displayed in the GUI.
        Specified by:
        getQuickInfo in interface adams.core.QuickInfoSupporter
        Overrides:
        getQuickInfo in class adams.scripting.connection.AbstractConnection
        Returns:
        null if no info available, otherwise short string
      • connect

        protected String connect()
        Starts up a RabbitMQ connection.
        Returns:
        null if OK, otherwise error message
      • disconnect

        protected void disconnect()
        Disconnects the FTP session, if necessary.
      • getChannel

        protected com.rabbitmq.client.Channel getChannel()
        Returns the channel object.
        Returns:
        the FTP client, null if failed to connect
      • doSend

        protected String doSend​(adams.scripting.command.RemoteCommand cmd,
                                adams.scripting.processor.RemoteCommandProcessor processor)
        Sends the command to the specified sscripting engine.
        Parameters:
        cmd - the command to send
        processor - for formatting/parsing
        Returns:
        null if successfully sent, otherwise error message
      • doSendRequest

        protected String doSendRequest​(adams.scripting.command.RemoteCommand cmd,
                                       adams.scripting.processor.RemoteCommandProcessor processor)
        Sends the request command.
        Specified by:
        doSendRequest in class adams.scripting.connection.AbstractConnection
        Parameters:
        cmd - the command to send
        Returns:
        null if successful, otherwise error message
      • doSendResponse

        protected String doSendResponse​(adams.scripting.command.RemoteCommand cmd,
                                        adams.scripting.processor.RemoteCommandProcessor processor)
        Sends the response command.
        Specified by:
        doSendResponse in class adams.scripting.connection.AbstractConnection
        Parameters:
        cmd - the command to send
        Returns:
        null if successful, otherwise error message
      • cleanUp

        public void cleanUp()
        Cleans up data structures, frees up memory.
        Specified by:
        cleanUp in interface adams.core.CleanUpHandler
        Overrides:
        cleanUp in class adams.scripting.connection.AbstractConnection