Package adams.scripting.connection
Class RabbitMQConnection
- java.lang.Object
-
- adams.core.logging.LoggingObject
-
- adams.core.logging.CustomLoggingLevelObject
-
- adams.core.option.AbstractOptionHandler
-
- adams.scripting.connection.AbstractConnection
-
- adams.scripting.connection.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
-
-
Field Summary
Fields Modifier and Type Field Description protected com.rabbitmq.client.Channel
m_Channel
the channel action to use.protected com.rabbitmq.client.Connection
m_Connection
the connection.protected AbstractConnectionFactory
m_ConnectionFactory
the connection to use.protected String
m_Exchange
the name of the exchange.protected int
m_PrefetchCount
the prefetch count.protected String
m_Queue
the queue in use.protected AbstractConverter
m_SendConverter
the converter for sending.
-
Constructor Summary
Constructors Constructor Description RabbitMQConnection()
-
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
-
-
-
-
Field Detail
-
m_ConnectionFactory
protected AbstractConnectionFactory m_ConnectionFactory
the connection to use.
-
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.
-
-
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
-
defineOptions
public void defineOptions()
Adds options to the internal list of options.- Specified by:
defineOptions
in interfaceadams.core.option.OptionHandler
- Overrides:
defineOptions
in classadams.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 interfaceadams.core.QuickInfoSupporter
- Overrides:
getQuickInfo
in classadams.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 sendprocessor
- 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 classadams.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 classadams.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 interfaceadams.core.CleanUpHandler
- Overrides:
cleanUp
in classadams.scripting.connection.AbstractConnection
-
-