Class RabbitMQScriptingEngine

  • All Implemented Interfaces:
    adams.core.Destroyable, adams.core.GlobalInfoSupporter, adams.core.logging.LoggingLevelHandler, adams.core.logging.LoggingSupporter, adams.core.option.OptionHandler, adams.core.Pausable, adams.core.SizeOfHandler, adams.core.Stoppable, adams.core.StoppableWithFeedback, adams.flow.core.FlowContextHandler, adams.scripting.engine.JobQueueHandler, adams.scripting.engine.RemoteScriptingEngine, adams.scripting.processor.RemoteCommandProcessorHandler, Serializable

    public class RabbitMQScriptingEngine
    extends adams.scripting.engine.AbstractScriptingEngineWithJobQueue
    RabbitMQ implementation of scripting engine for remote commands.
    Author:
    FracPete (fracpete at waikato dot ac dot nz)
    See Also:
    Serialized Form
    • Field Summary

      Fields 
      Modifier and Type Field Description
      protected AbstractChannelAction m_Action
      the action to execute.
      protected com.rabbitmq.client.Channel m_Channel
      the channel action to use.
      protected com.rabbitmq.client.Connection m_Connection
      the current connection.
      protected AbstractConnectionFactory m_ConnectionFactory
      the connection to use.
      protected AbstractConverter m_Converter
      the converter.
      protected ArrayBlockingQueue<Object> m_Data
      the data that has been received.
      protected String m_Exchange
      the name of the exchange.
      protected int m_PollTimeout
      the internal timeout interval for polling the queue in msec.
      protected int m_PrefetchCount
      the prefetch count.
      protected String m_Queue
      the name of the queue.
      protected ArrayBlockingQueue<Long> m_Tags
      the ack tags that have been received.
      • Fields inherited from class adams.scripting.engine.AbstractScriptingEngineWithJobQueue

        m_Executor, m_MaxConcurrentJobs
      • Fields inherited from class adams.scripting.engine.AbstractScriptingEngine

        m_CommandHandler, m_CommandProcessor, m_FlowContext, m_Paused, m_PermissionHandler, m_RemoteScriptingEngineHandler, m_RequestHandler, m_ResponseHandler, m_Running, m_Stopped
      • Fields inherited from class adams.core.option.AbstractOptionHandler

        m_OptionManager
      • Fields inherited from class adams.core.logging.LoggingObject

        m_Logger, m_LoggingIsEnabled, m_LoggingLevel
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      String actionTipText()
      Returns the tip text for this property.
      protected void close()
      Closes the connection.
      protected String connect()
      Starts up a RabbitMQ connection.
      String connectionFactoryTipText()
      Returns the tip text for this property.
      String converterTipText()
      Returns the tip text for this property.
      void defineOptions()
      Adds options to the internal list of options.
      protected String doExecute()
      Executes the scripting engine.
      String exchangeTipText()
      Returns the tip text for this property.
      AbstractChannelAction getAction()
      Returns the action to run.
      AbstractConnectionFactory getConnectionFactory()
      Returns the connection factory to use.
      AbstractConverter getConverter()
      Returns the converter 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 globalInfo()
      Returns a string describing the object.
      protected void handleMessage​(Object data, Long tag)
      Handles the received object.
      protected void initialize()
      Initializes the members.
      static void main​(String[] args)
      Starts the scripting engine from commandline.
      String prefetchCountTipText()
      Returns the tip text for this property.
      String queueTipText()
      Returns the tip text for this property.
      void setAction​(AbstractChannelAction value)
      Sets the action to run.
      void setConnectionFactory​(AbstractConnectionFactory value)
      Sets the connection factory to use.
      void setConverter​(AbstractConverter value)
      Sets the converter 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 stopExecution()
      Stops the execution.
      • Methods inherited from class adams.scripting.engine.AbstractScriptingEngineWithJobQueue

        executeJob, getMaxConcurrentJobs, maxConcurrentJobsTipText, pauseExecution, resumeExecution, setMaxConcurrentJobs
      • Methods inherited from class adams.scripting.engine.AbstractScriptingEngine

        commandProcessorTipText, execute, forCommandLine, forName, getCommandHandler, getCommandProcessor, getDefaultCommandHandler, getDefaultCommandProcessor, getDefaultPermissionHandler, getDefaultRequestHandler, getDefaultResponseHandler, getFlowContext, getPermissionHandler, getRemoteScriptingEngineHandler, getRequestHandler, getResponseHandler, isPaused, isRunning, isStopped, permissionHandlerTipText, requestHandlerTipText, responseHandlerTipText, runScriptingEngine, runScriptingEngine, setCommandHandler, setCommandProcessor, setFlowContext, setPermissionHandler, setRemoteScriptingEngineHandler, setRequestHandler, setResponseHandler
      • Methods inherited from class adams.core.option.AbstractOptionHandler

        cleanUpOptions, destroy, finishInit, getDefaultLoggingLevel, getOptionManager, loggingLevelTipText, newOptionManager, reset, setLoggingLevel, toCommandLine, toString
      • 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
      • Methods inherited from interface adams.core.Pausable

        isPaused
      • Methods inherited from interface adams.scripting.processor.RemoteCommandProcessorHandler

        getCommandProcessor, setCommandProcessor
      • Methods inherited from interface adams.scripting.engine.RemoteScriptingEngine

        execute, getCommandHandler, getFlowContext, getPermissionHandler, getRemoteScriptingEngineHandler, getRequestHandler, getResponseHandler, isRunning, permissionHandlerTipText, requestHandlerTipText, responseHandlerTipText, setCommandHandler, setFlowContext, setPermissionHandler, setRemoteScriptingEngineHandler, setRequestHandler, setResponseHandler
      • Methods inherited from interface adams.core.StoppableWithFeedback

        isStopped
    • 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 name of the queue.
      • m_Connection

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

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

        protected int m_PollTimeout
        the internal timeout interval for polling the queue in msec.
    • Constructor Detail

      • RabbitMQScriptingEngine

        public RabbitMQScriptingEngine()
    • 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
      • initialize

        protected void initialize()
        Initializes the members.
        Overrides:
        initialize in class adams.scripting.engine.AbstractScriptingEngine
      • 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.scripting.engine.AbstractScriptingEngineWithJobQueue
      • 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.
      • setAction

        public void setAction​(AbstractChannelAction value)
        Sets the action to run.
        Parameters:
        value - the action
      • actionTipText

        public String actionTipText()
        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.
      • setConverter

        public void setConverter​(AbstractConverter value)
        Sets the converter to use.
        Parameters:
        value - the converter
      • getConverter

        public AbstractConverter getConverter()
        Returns the converter to use.
        Returns:
        the converter
      • converterTipText

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

        protected void close()
        Closes the connection.
      • connect

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

        protected void handleMessage​(Object data,
                                     Long tag)
        Handles the received object.
        Parameters:
        data - the data received
        tag - the tag to use for the ack
      • doExecute

        protected String doExecute()
        Executes the scripting engine.
        Specified by:
        doExecute in class adams.scripting.engine.AbstractScriptingEngine
        Returns:
        error message in case of failure to start up or run, otherwise null
      • stopExecution

        public void stopExecution()
        Stops the execution.
        Specified by:
        stopExecution in interface adams.core.Stoppable
        Overrides:
        stopExecution in class adams.scripting.engine.AbstractScriptingEngineWithJobQueue
      • main

        public static void main​(String[] args)
        Starts the scripting engine from commandline.
        Parameters:
        args - additional options for the scripting engine