Package adams.scripting.engine
Class RabbitMQScriptingEngine
- java.lang.Object
-
- adams.core.logging.LoggingObject
-
- adams.core.logging.CustomLoggingLevelObject
-
- adams.core.option.AbstractOptionHandler
-
- adams.scripting.engine.AbstractScriptingEngine
-
- adams.scripting.engine.AbstractScriptingEngineWithJobQueue
-
- adams.scripting.engine.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
-
-
Constructor Summary
Constructors Constructor Description RabbitMQScriptingEngine()
-
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 class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface adams.core.option.OptionHandler
cleanUpOptions, getOptionManager, toCommandLine
-
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
-
-
-
-
Field Detail
-
m_ConnectionFactory
protected AbstractConnectionFactory m_ConnectionFactory
the connection to use.
-
m_PrefetchCount
protected int m_PrefetchCount
the prefetch count.
-
m_Action
protected AbstractChannelAction m_Action
the action to execute.
-
m_Exchange
protected String m_Exchange
the name of the exchange.
-
m_Queue
protected String m_Queue
the name of the queue.
-
m_Converter
protected AbstractConverter m_Converter
the converter.
-
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_Data
protected ArrayBlockingQueue<Object> m_Data
the data that has been received.
-
m_Tags
protected ArrayBlockingQueue<Long> m_Tags
the ack tags that have been received.
-
m_PollTimeout
protected int m_PollTimeout
the internal timeout interval for polling the queue in msec.
-
-
Method Detail
-
globalInfo
public String globalInfo()
Returns a string describing the object.- Specified by:
globalInfo
in interfaceadams.core.GlobalInfoSupporter
- Specified by:
globalInfo
in classadams.core.option.AbstractOptionHandler
- Returns:
- a description suitable for displaying in the gui
-
initialize
protected void initialize()
Initializes the members.- Overrides:
initialize
in classadams.scripting.engine.AbstractScriptingEngine
-
defineOptions
public void defineOptions()
Adds options to the internal list of options.- Specified by:
defineOptions
in interfaceadams.core.option.OptionHandler
- Overrides:
defineOptions
in classadams.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
-
getAction
public AbstractChannelAction getAction()
Returns the action to run.- Returns:
- 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 receivedtag
- the tag to use for the ack
-
doExecute
protected String doExecute()
Executes the scripting engine.- Specified by:
doExecute
in classadams.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 interfaceadams.core.Stoppable
- Overrides:
stopExecution
in classadams.scripting.engine.AbstractScriptingEngineWithJobQueue
-
main
public static void main(String[] args)
Starts the scripting engine from commandline.- Parameters:
args
- additional options for the scripting engine
-
-