Class RabbitMQProducer
- java.lang.Object
-
- org.apache.synapse.message.store.impl.rabbitmq.RabbitMQProducer
-
- All Implemented Interfaces:
MessageProducer
public class RabbitMQProducer extends Object implements MessageProducer
The message producer responsible to store message into RabbitMQ queue
-
-
Constructor Summary
Constructors Constructor Description RabbitMQProducer(RabbitMQStore store)
The RabbitMQ producer
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description boolean
cleanup()
Used to close the channel opened in this object instance.String
getId()
Get ID of this RabbitMQ producerboolean
isInitialized()
Verify to whether producer was initializedvoid
setChannel(com.rabbitmq.client.Channel channel)
Set theChannel
objectvoid
setConnection(com.rabbitmq.client.Connection connection)
Set theConnection
objectvoid
setExchangeName(String exchangeName)
Set the exchange name to publish the messagevoid
setId(int id)
Set ID of this RabbitMQ producervoid
setPublisherConfirmsEnabled(boolean publisherConfirmsEnabled)
Set the publisher confirm enabled or notvoid
setRoutingKey(String routingKey)
Set the routing key bind with the exchangeboolean
storeMessage(MessageContext synCtx)
Store the given message into the queue and return whether the operation success or not
-
-
-
Constructor Detail
-
RabbitMQProducer
public RabbitMQProducer(RabbitMQStore store)
The RabbitMQ producer- Parameters:
store
- theRabbitMQStore
object
-
-
Method Detail
-
storeMessage
public boolean storeMessage(MessageContext synCtx)
Store the given message into the queue and return whether the operation success or not- Specified by:
storeMessage
in interfaceMessageProducer
- Parameters:
synCtx
- Message to be saved.- Returns:
true
if storing of the message is successful,false
otherwise.
-
cleanup
public boolean cleanup()
Used to close the channel opened in this object instance. This should be called after the end of each call on storeMessage method But instead of this, try with resources will close the channel- Specified by:
cleanup
in interfaceMessageProducer
- Returns:
true
if clean up is successful,false
otherwise.
-
getId
public String getId()
Get ID of this RabbitMQ producer- Specified by:
getId
in interfaceMessageProducer
- Returns:
- the ID
-
setId
public void setId(int id)
Set ID of this RabbitMQ producer- Specified by:
setId
in interfaceMessageProducer
- Parameters:
id
- ID
-
setRoutingKey
public void setRoutingKey(String routingKey)
Set the routing key bind with the exchange- Parameters:
routingKey
- the message routing key
-
setExchangeName
public void setExchangeName(String exchangeName)
Set the exchange name to publish the message- Parameters:
exchangeName
- the exchange to publish the message to
-
setConnection
public void setConnection(com.rabbitmq.client.Connection connection)
Set theConnection
object- Parameters:
connection
- aConnection
object
-
setChannel
public void setChannel(com.rabbitmq.client.Channel channel)
Set theChannel
object- Parameters:
channel
- aChannel
object
-
setPublisherConfirmsEnabled
public void setPublisherConfirmsEnabled(boolean publisherConfirmsEnabled)
Set the publisher confirm enabled or not- Parameters:
publisherConfirmsEnabled
- publsher confirm enabled or not
-
isInitialized
public boolean isInitialized()
Verify to whether producer was initialized- Returns:
- is initialized
-
-