Class MQConnection
- java.lang.Object
-
- com.sonymobile.jenkins.plugins.mq.mqnotifier.MQConnection
-
- All Implemented Interfaces:
com.rabbitmq.client.ShutdownListener
,EventListener
public final class MQConnection extends Object implements com.rabbitmq.client.ShutdownListener
Creates an MQ connection.- Author:
- Örjan Percy <orjan.percy@sonymobile.com>
-
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description void
addMessageToQueue(String exchange, String routingKey, com.rabbitmq.client.AMQP.BasicProperties props, byte[] body)
Puts a message in the message queue.void
clearOutstandingConfirms()
Clear the outstanding confirms list, useful when testing.com.rabbitmq.client.Connection
getConnection()
Gets the connection.static MQConnection
getInstance()
Gets the instance.int
getSizeOutstandingConfirms()
Get the number of currently outstanding confirms.void
initialize(String name, Secret password, String uri, String vh)
Initializes this instance with supplied values.void
publish(net.sf.json.JSONObject json)
Publish json message on configured MQ server.void
publish(net.sf.json.JSONObject json, String routingKey)
Publish json message on configured MQ server.void
shutdownCompleted(com.rabbitmq.client.ShutdownSignalException cause)
-
-
-
Method Detail
-
getInstance
public static MQConnection getInstance()
Gets the instance.- Returns:
- the instance
-
getSizeOutstandingConfirms
public int getSizeOutstandingConfirms()
Get the number of currently outstanding confirms.- Returns:
- the number of currently outstanding confirms
-
clearOutstandingConfirms
public void clearOutstandingConfirms()
Clear the outstanding confirms list, useful when testing.
-
addMessageToQueue
public void addMessageToQueue(String exchange, String routingKey, com.rabbitmq.client.AMQP.BasicProperties props, byte[] body)
Puts a message in the message queue.- Parameters:
exchange
- the exchange to publish the message toroutingKey
- the routing keyprops
- other properties for the message - routing headers etcbody
- the message body
-
publish
public void publish(net.sf.json.JSONObject json)
Publish json message on configured MQ server. Helper method for testing, in order to use functional interfaces.- Parameters:
json
- the message in json format
-
publish
public void publish(net.sf.json.JSONObject json, String routingKey)
Publish json message on configured MQ server.- Parameters:
json
- the message in json formatroutingKey
- the routing key to use for the message, unless overriden by global setting.
-
getConnection
public com.rabbitmq.client.Connection getConnection()
Gets the connection.- Returns:
- the connection.
-
initialize
public void initialize(String name, Secret password, String uri, String vh)
Initializes this instance with supplied values.- Parameters:
name
- the user namepassword
- the user passworduri
- the server urivh
- the virtual host
-
shutdownCompleted
public void shutdownCompleted(com.rabbitmq.client.ShutdownSignalException cause)
- Specified by:
shutdownCompleted
in interfacecom.rabbitmq.client.ShutdownListener
-
-