Interface ClientProducer
-
- All Superinterfaces:
java.lang.AutoCloseable
public interface ClientProducer extends java.lang.AutoCloseableA ClientProducer is used to send messages to a specific address. Messages are then routed on the server to any queues that are bound to the address. A ClientProducer can either be created with a specific address in mind or with none. With the latter the address must be provided using the appropriate send() method.
The sending semantics can change depending on what blocking semantics are set via
ServerLocator.setBlockOnDurableSend(boolean)andServerLocator.setBlockOnNonDurableSend(boolean). If set to true then for each message type, durable and non durable respectively, any exceptions such as the address not existing or security exceptions will be thrown at the time of send. Alternatively if set to false then exceptions will only be logged on the server.
The send rate can also be controlled via
ServerLocator.setProducerMaxRate(int)and theServerLocator.setProducerWindowSize(int).
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description voidclose()Closes the ClientProducer.org.apache.activemq.artemis.api.core.SimpleStringgetAddress()Returns the address where messages will be sent.intgetMaxRate()Returns the maximum rate at which a ClientProducer can send messages per second.booleanisBlockOnDurableSend()Returns whether the producer will block when sending durable messages.booleanisBlockOnNonDurableSend()Returns whether the producer will block when sending non-durable messages.booleanisClosed()Returns whether the producer is closed or not.voidsend(java.lang.String address, Message message)Sends a message to the specified address instead of the ClientProducer's address.voidsend(Message message)Sends a message to an address.voidsend(Message message, SendAcknowledgementHandler handler)Sends a message to the specified address instead of the ClientProducer's address.voidsend(org.apache.activemq.artemis.api.core.SimpleString address, Message message)Sends a message to the specified address instead of the ClientProducer's address.voidsend(org.apache.activemq.artemis.api.core.SimpleString address, Message message, SendAcknowledgementHandler handler)Sends a message to the specified address instead of the ClientProducer's address.
-
-
-
Method Detail
-
getAddress
org.apache.activemq.artemis.api.core.SimpleString getAddress()
Returns the address where messages will be sent.
The address can benullif the ClientProducer was creating without specifying an address, that is by usingClientSession.createProducer().- Returns:
- the address where messages will be sent
-
send
void send(Message message) throws org.apache.activemq.artemis.api.core.ActiveMQException
Sends a message to an address. specified inClientSession.createProducer(String)or similar methods.
This will block until confirmation that the message has reached the server has been received ifServerLocator.setBlockOnDurableSend(boolean)orServerLocator.setBlockOnNonDurableSend(boolean)are set totruefor the specified message type.- Parameters:
message- the message to send- Throws:
org.apache.activemq.artemis.api.core.ActiveMQException- if an exception occurs while sending the message
-
send
void send(Message message, SendAcknowledgementHandler handler) throws org.apache.activemq.artemis.api.core.ActiveMQException
Sends a message to the specified address instead of the ClientProducer's address.
This message will be sent asynchronously.The handler will only get called if
-1.- Parameters:
message- the message to sendhandler- handler to call after receiving a SEND acknowledgement from the server- Throws:
org.apache.activemq.artemis.api.core.ActiveMQException- if an exception occurs while sending the message
-
send
void send(org.apache.activemq.artemis.api.core.SimpleString address, Message message) throws org.apache.activemq.artemis.api.core.ActiveMQExceptionSends a message to the specified address instead of the ClientProducer's address.
This will block until confirmation that the message has reached the server has been received ifServerLocator.setBlockOnDurableSend(boolean)orServerLocator.setBlockOnNonDurableSend(boolean)are set to true for the specified message type.- Parameters:
address- the address where the message will be sentmessage- the message to send- Throws:
org.apache.activemq.artemis.api.core.ActiveMQException- if an exception occurs while sending the message
-
send
void send(org.apache.activemq.artemis.api.core.SimpleString address, Message message, SendAcknowledgementHandler handler) throws org.apache.activemq.artemis.api.core.ActiveMQExceptionSends a message to the specified address instead of the ClientProducer's address.
This message will be sent asynchronously as long asServerLocator.setConfirmationWindowSize(int)was set.Notice that if no confirmationWindowsize is set
- Parameters:
address- the address where the message will be sentmessage- the message to sendhandler- handler to call after receiving a SEND acknowledgement from the server- Throws:
org.apache.activemq.artemis.api.core.ActiveMQException- if an exception occurs while sending the message
-
send
void send(java.lang.String address, Message message) throws org.apache.activemq.artemis.api.core.ActiveMQExceptionSends a message to the specified address instead of the ClientProducer's address.
This will block until confirmation that the message has reached the server has been received ifServerLocator.setBlockOnDurableSend(boolean)orServerLocator.setBlockOnNonDurableSend(boolean)are set to true for the specified message type.- Parameters:
address- the address where the message will be sentmessage- the message to send- Throws:
org.apache.activemq.artemis.api.core.ActiveMQException- if an exception occurs while sending the message
-
close
void close() throws org.apache.activemq.artemis.api.core.ActiveMQExceptionCloses the ClientProducer. If already closed nothing is done.- Specified by:
closein interfacejava.lang.AutoCloseable- Throws:
org.apache.activemq.artemis.api.core.ActiveMQException- if an exception occurs while closing the producer
-
isClosed
boolean isClosed()
Returns whether the producer is closed or not.- Returns:
trueif the producer is closed,falseelse
-
isBlockOnDurableSend
boolean isBlockOnDurableSend()
Returns whether the producer will block when sending durable messages.- Returns:
trueif the producer blocks when sending durable,falseelse
-
isBlockOnNonDurableSend
boolean isBlockOnNonDurableSend()
Returns whether the producer will block when sending non-durable messages.- Returns:
trueif the producer blocks when sending non-durable,falseelse
-
getMaxRate
int getMaxRate()
Returns the maximum rate at which a ClientProducer can send messages per second.- Returns:
- the producers maximum rate
-
-