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 booleancleanup()Used to close the channel opened in this object instance.StringgetId()Get ID of this RabbitMQ producerbooleanisInitialized()Verify to whether producer was initializedvoidsetChannel(com.rabbitmq.client.Channel channel)Set theChannelobjectvoidsetConnection(com.rabbitmq.client.Connection connection)Set theConnectionobjectvoidsetExchangeName(String exchangeName)Set the exchange name to publish the messagevoidsetId(int id)Set ID of this RabbitMQ producervoidsetPublisherConfirmsEnabled(boolean publisherConfirmsEnabled)Set the publisher confirm enabled or notvoidsetRoutingKey(String routingKey)Set the routing key bind with the exchangebooleanstoreMessage(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- theRabbitMQStoreobject
-
-
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:
storeMessagein interfaceMessageProducer- Parameters:
synCtx- Message to be saved.- Returns:
trueif storing of the message is successful,falseotherwise.
-
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:
cleanupin interfaceMessageProducer- Returns:
trueif clean up is successful,falseotherwise.
-
getId
public String getId()
Get ID of this RabbitMQ producer- Specified by:
getIdin interfaceMessageProducer- Returns:
- the ID
-
setId
public void setId(int id)
Set ID of this RabbitMQ producer- Specified by:
setIdin 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 theConnectionobject- Parameters:
connection- aConnectionobject
-
setChannel
public void setChannel(com.rabbitmq.client.Channel channel)
Set theChannelobject- Parameters:
channel- aChannelobject
-
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
-
-