Interface ClientProducer

All Superinterfaces:
AutoCloseable

public interface ClientProducer extends AutoCloseable
A 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) and ServerLocator.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 the ServerLocator.setProducerWindowSize(int).

  • Method Details

    • getAddress

      SimpleString getAddress()
      Returns the address where messages will be sent; the address can be null if the ClientProducer was created without specifying an address, e.g. by using ClientSession.createProducer().
      Returns:
      the address where messages will be sent; the address can be null if the ClientProducer was created without specifying an address, e.g. by using ClientSession.createProducer()
    • send

      void send(Message message) throws ActiveMQException
      Sends a message to an address. specified in ClientSession.createProducer(String) or similar methods.

      This will block until confirmation that the message has reached the server has been received if ServerLocator.setBlockOnDurableSend(boolean) or ServerLocator.setBlockOnNonDurableSend(boolean) are set to true for the specified message type.

      Parameters:
      message - the message to send
      Throws:
      ActiveMQException - if an exception occurs while sending the message
    • send

      void send(Message message, SendAcknowledgementHandler handler) throws 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 send
      handler - handler to call after receiving a SEND acknowledgement from the server
      Throws:
      ActiveMQException - if an exception occurs while sending the message
    • send

      void send(SimpleString address, Message message) throws ActiveMQException
      Sends 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 if ServerLocator.setBlockOnDurableSend(boolean) or ServerLocator.setBlockOnNonDurableSend(boolean) are set to true for the specified message type.

      Parameters:
      address - the address where the message will be sent
      message - the message to send
      Throws:
      ActiveMQException - if an exception occurs while sending the message
    • send

      void send(SimpleString address, Message message, SendAcknowledgementHandler handler) throws ActiveMQException
      Sends a message to the specified address instead of the ClientProducer's address.

      This message will be sent asynchronously as long as ServerLocator.setConfirmationWindowSize(int) was set.

      Notice that if no confirmationWindowsize is set

      Parameters:
      address - the address where the message will be sent
      message - the message to send
      handler - handler to call after receiving a SEND acknowledgement from the server
      Throws:
      ActiveMQException - if an exception occurs while sending the message
    • send

      void send(String address, Message message) throws ActiveMQException
      Sends 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 if ServerLocator.setBlockOnDurableSend(boolean) or ServerLocator.setBlockOnNonDurableSend(boolean) are set to true for the specified message type.

      Parameters:
      address - the address where the message will be sent
      message - the message to send
      Throws:
      ActiveMQException - if an exception occurs while sending the message
    • close

      void close() throws ActiveMQException
      Closes the ClientProducer. If already closed nothing is done.
      Specified by:
      close in interface AutoCloseable
      Throws:
      ActiveMQException - if an exception occurs while closing the producer
    • isClosed

      boolean isClosed()
      Returns true if the producer is closed, false else.
      Returns:
      true if the producer is closed, false else
    • isBlockOnDurableSend

      boolean isBlockOnDurableSend()
      Returns true if the producer blocks when sending durable messages, false else.
      Returns:
      true if the producer blocks when sending durable messages, false else
    • isBlockOnNonDurableSend

      boolean isBlockOnNonDurableSend()
      Returns true if the producer blocks when sending non-durable messages, false else.
      Returns:
      true if the producer blocks when sending non-durable messages, false else
    • getMaxRate

      int getMaxRate()
      Returns the maximum rate at which a ClientProducer can send messages per second.
      Returns:
      the maximum rate at which a ClientProducer can send messages per second