Class AmqpSender

java.lang.Object
io.vertx.mutiny.amqp.AmqpSender
All Implemented Interfaces:
MutinyDelegate, StreamBase, WriteStream<AmqpMessage>

public class AmqpSender extends Object implements WriteStream<AmqpMessage>, MutinyDelegate
AMQP Sender interface used to send messages.

NOTE: This class has been automatically generated from the original non Mutiny-ified interface.

See Also:
  • AmqpSender
  • Field Details

  • Constructor Details

    • AmqpSender

      public AmqpSender(io.vertx.amqp.AmqpSender delegate)
      Create a new instance of AmqpSender delegating to the given (non-null) instance of AmqpSender.
    • AmqpSender

      public AmqpSender(Object delegate)
  • Method Details

    • getDelegate

      public io.vertx.amqp.AmqpSender getDelegate()
      Get the delegate instance.

      This method returns the instance on which this shim is delegating the calls. And so, give you access to the bare API.

      Specified by:
      getDelegate in interface MutinyDelegate
      Specified by:
      getDelegate in interface StreamBase
      Specified by:
      getDelegate in interface WriteStream<AmqpMessage>
      Returns:
      the delegate instance
    • sendWithAck

      @CheckReturnValue public io.smallrye.mutiny.Uni<Void> sendWithAck(AmqpMessage message)
      Sends an AMQP message and waits for an acknowledgement. It returns a uni marked as failed if the message has been rejected or re-routed. If the message has been accepted, the handler is called with a success.

      Unlike the bare Vert.x variant, this method returns a Uni. The uni emits the result of the operation as item. If the operation fails, the uni emits the failure.

      Don't forget to subscribe on it to trigger the operation.

      Parameters:
      message - the message, must not be null
      Returns:
      A Uni representing the asynchronous result of this operation.
      See Also:
      • io.vertx.amqp.AmqpSender#sendWithAck(AmqpMessage)
    • sendWithAckAndAwait

      public void sendWithAckAndAwait(AmqpMessage message)
      Sends an AMQP message and waits for an acknowledgement. It returns a underlying uni marked as failed if the message has been rejected or re-routed. If the message has been accepted, the handler is called with a success.

      Unlike the bare Vert.x variant, this method returns a Void. This method awaits indefinitely for the completion of the underlying asynchronous operation. If the operation completes successfully, the result is returned, otherwise the failure is thrown (potentially wrapped in a RuntimeException).

      Parameters:
      message - the message, must not be null
      See Also:
      • io.vertx.amqp.AmqpSender#sendWithAck(AmqpMessage)
    • sendWithAckAndForget

      public AmqpSender sendWithAckAndForget(AmqpMessage message)
      Sends an AMQP message and waits for an acknowledgement. It returns a underlying uni marked as failed if the message has been rejected or re-routed. If the message has been accepted, the handler is called with a success.

      Unlike the bare Vert.x variant, this method ignores the Void result or any failure.

      Parameters:
      message - the message, must not be null
      Returns:
      The current instance to chain operations if needed.
      See Also:
      • io.vertx.amqp.AmqpSender#sendWithAck(AmqpMessage)
    • close

      @CheckReturnValue public io.smallrye.mutiny.Uni<Void> close()
      Closes the sender.

      Unlike the bare Vert.x variant, this method returns a Uni. The uni emits the result of the operation as item. If the operation fails, the uni emits the failure.

      Don't forget to subscribe on it to trigger the operation.

      Returns:
      A Uni representing the asynchronous result of this operation.
      See Also:
      • AmqpSender.close()
    • closeAndAwait

      public void closeAndAwait()
      Closes the sender.

      Unlike the bare Vert.x variant, this method returns a Void. This method awaits indefinitely for the completion of the underlying asynchronous operation. If the operation completes successfully, the result is returned, otherwise the failure is thrown (potentially wrapped in a RuntimeException).

      See Also:
      • AmqpSender.close()
    • closeAndForget

      public AmqpSender closeAndForget()
      Closes the sender.

      Unlike the bare Vert.x variant, this method ignores the Void result or any failure.

      Returns:
      The current instance to chain operations if needed.
      See Also:
      • AmqpSender.close()
    • end

      @CheckReturnValue public io.smallrye.mutiny.Uni<Void> end(AmqpMessage data)
      Same as end() but writes some data to the stream before ending.

      Unlike the bare Vert.x variant, this method returns a Uni. The uni emits the result of the operation as item. If the operation fails, the uni emits the failure.

      Don't forget to subscribe on it to trigger the operation.

      Specified by:
      end in interface WriteStream<AmqpMessage>
      Parameters:
      data - the data to write
      Returns:
      A Uni representing the asynchronous result of this operation.
      See Also:
      • WriteStream.end(T)
    • endAndAwait

      public void endAndAwait(AmqpMessage data)
      Same as end() but writes some data to the stream before ending.

      Unlike the bare Vert.x variant, this method returns a Void. This method awaits indefinitely for the completion of the underlying asynchronous operation. If the operation completes successfully, the result is returned, otherwise the failure is thrown (potentially wrapped in a RuntimeException).

      Parameters:
      data - the data to write
      See Also:
      • WriteStream.end(T)
    • endAndForget

      public AmqpSender endAndForget(AmqpMessage data)
      Same as end() but writes some data to the stream before ending.

      Unlike the bare Vert.x variant, this method ignores the Void result or any failure.

      Parameters:
      data - the data to write
      Returns:
      The current instance to chain operations if needed.
      See Also:
      • WriteStream.end(T)
    • end

      @CheckReturnValue public io.smallrye.mutiny.Uni<Void> end()
      Ends the stream.

      Once the stream has ended, it cannot be used any more.

      Unlike the bare Vert.x variant, this method returns a Uni. The uni emits the result of the operation as item. If the operation fails, the uni emits the failure.

      Don't forget to subscribe on it to trigger the operation.

      Specified by:
      end in interface WriteStream<AmqpMessage>
      Returns:
      A Uni representing the asynchronous result of this operation.
      See Also:
      • WriteStream.end()
    • endAndAwait

      public void endAndAwait()
      Ends the stream.

      Once the stream has ended, it cannot be used any more.

      Unlike the bare Vert.x variant, this method returns a Void. This method awaits indefinitely for the completion of the underlying asynchronous operation. If the operation completes successfully, the result is returned, otherwise the failure is thrown (potentially wrapped in a RuntimeException).

      See Also:
      • WriteStream.end()
    • endAndForget

      public AmqpSender endAndForget()
      Ends the stream.

      Once the stream has ended, it cannot be used any more.

      Unlike the bare Vert.x variant, this method ignores the Void result or any failure.

      Returns:
      The current instance to chain operations if needed.
      See Also:
      • WriteStream.end()
    • write

      @CheckReturnValue public io.smallrye.mutiny.Uni<Void> write(AmqpMessage data)
      Write some data to the stream.

      The data is usually put on an internal write queue, and the write actually happens asynchronously. To avoid running out of memory by putting too much on the write queue, check the writeQueueFull() method before writing. This is done automatically if using a Pipe.

      When the data is moved from the queue to the actual medium, the returned Future will be completed with the write result, e.g the uni is succeeded when a server HTTP response buffer is written to the socket and failed if the remote client has closed the socket while the data was still pending for write.

      Unlike the bare Vert.x variant, this method returns a Uni. The uni emits the result of the operation as item. If the operation fails, the uni emits the failure.

      Don't forget to subscribe on it to trigger the operation.

      Specified by:
      write in interface WriteStream<AmqpMessage>
      Parameters:
      data - the data to write
      Returns:
      A Uni representing the asynchronous result of this operation.
      See Also:
      • WriteStream.write(T)
    • writeAndAwait

      public void writeAndAwait(AmqpMessage data)
      Write some data to the stream.

      The data is usually put on an internal write queue, and the write actually happens asynchronously. To avoid running out of memory by putting too much on the write queue, check the writeQueueFull() method before writing. This is done automatically if using a Pipe.

      When the data is moved from the queue to the actual medium, the returned Future will be completed with the write result, e.g the underlying uni is succeeded when a server HTTP response buffer is written to the socket and failed if the remote client has closed the socket while the data was still pending for write.

      Unlike the bare Vert.x variant, this method returns a Void. This method awaits indefinitely for the completion of the underlying asynchronous operation. If the operation completes successfully, the result is returned, otherwise the failure is thrown (potentially wrapped in a RuntimeException).

      Parameters:
      data - the data to write
      See Also:
      • WriteStream.write(T)
    • writeAndForget

      public AmqpSender writeAndForget(AmqpMessage data)
      Write some data to the stream.

      The data is usually put on an internal write queue, and the write actually happens asynchronously. To avoid running out of memory by putting too much on the write queue, check the writeQueueFull() method before writing. This is done automatically if using a Pipe.

      When the data is moved from the queue to the actual medium, the returned Future will be completed with the write result, e.g the underlying uni is succeeded when a server HTTP response buffer is written to the socket and failed if the remote client has closed the socket while the data was still pending for write.

      Unlike the bare Vert.x variant, this method ignores the Void result or any failure.

      Parameters:
      data - the data to write
      Returns:
      The current instance to chain operations if needed.
      See Also:
      • WriteStream.write(T)
    • exceptionHandler

      public AmqpSender exceptionHandler(Consumer<Throwable> handler)
      Description copied from interface: WriteStream
      Set an exception handler on the write stream.
      Specified by:
      exceptionHandler in interface StreamBase
      Specified by:
      exceptionHandler in interface WriteStream<AmqpMessage>
      Parameters:
      handler - the exception handler. Can be null.
      Returns:
      a reference to this, so the API can be used fluently
    • setWriteQueueMaxSize

      public AmqpSender setWriteQueueMaxSize(int maxSize)
      Description copied from interface: WriteStream
      Set the maximum size of the write queue to maxSize. You will still be able to write to the stream even if there is more than maxSize items in the write queue. This is used as an indicator by classes such as Pipe to provide flow control.

      The value is defined by the implementation of the stream, e.g in bytes for a NetSocket, etc...

      Specified by:
      setWriteQueueMaxSize in interface WriteStream<AmqpMessage>
      Parameters:
      maxSize - the max size of the write stream
      Returns:
      a reference to this, so the API can be used fluently
    • send

      public AmqpSender send(AmqpMessage message)
      Sends an AMQP message. The destination the configured sender address or the address configured in the message.
      Parameters:
      message - the message, must not be null
      Returns:
      the current sender
    • address

      public String address()
      Returns:
      the configured address.
    • connection

      public AmqpConnection connection()
      Gets the connection having created the sender. Cannot be null
      Returns:
      the connection having created the sender.
    • remainingCredits

      public long remainingCredits()
      Returns:
      the remaining credit, 0 is none.
    • unwrap

      public io.vertx.proton.ProtonSender unwrap()
      Returns:
      the underlying ProtonSender.
    • drainHandler

      public AmqpSender drainHandler(Runnable handler)
      Set a drain handler on the stream. If the write queue is full, then the handler will be called when the write queue is ready to accept buffers again. See Pipe for an example of this being used.

      The stream implementation defines when the drain handler, for example it could be when the queue size has been reduced to maxSize / 2.

      Specified by:
      drainHandler in interface WriteStream<AmqpMessage>
      Parameters:
      handler - the handler
      Returns:
      a reference to this, so the API can be used fluently
    • writeQueueFull

      public boolean writeQueueFull()
      This will return true if there are more bytes in the write queue than the value set using setWriteQueueMaxSize(int)
      Specified by:
      writeQueueFull in interface WriteStream<AmqpMessage>
      Returns:
      true if write queue is full
    • newInstance

      public static AmqpSender newInstance(io.vertx.amqp.AmqpSender delegate)
      Creates a new instance of the AmqpSender.
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object
    • equals

      public boolean equals(Object o)
      Overrides:
      equals in class Object
    • toString

      public String toString()
      Overrides:
      toString in class Object
    • toSubscriber

      @CheckReturnValue public Flow.Subscriber<AmqpMessage> toSubscriber()
      Converts the current write stream to a subscriber.