Class Message<T>

java.lang.Object
io.vertx.mutiny.core.eventbus.Message<T>
All Implemented Interfaces:
MutinyDelegate

public class Message<T> extends Object implements MutinyDelegate
Represents a message that is received from the event bus in a handler.

Messages have a body(), which can be null, and also headers(), which can be empty.

If the message was sent specifying a reply handler, it can be replied to using reply(java.lang.Object).

If you want to notify the sender that processing failed, then fail(int, java.lang.String) can be called.

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

  • Field Details

    • __TYPE_ARG

      public static final TypeArg<Message> __TYPE_ARG
    • __typeArg_0

      public final TypeArg<T> __typeArg_0
  • Constructor Details

    • Message

      public Message(io.vertx.core.eventbus.Message delegate)
    • Message

      public Message(Object delegate, TypeArg<T> typeArg_0)
    • Message

      public Message(io.vertx.core.eventbus.Message delegate, TypeArg<T> typeArg_0)
  • Method Details

    • getDelegate

      public io.vertx.core.eventbus.Message getDelegate()
      Specified by:
      getDelegate in interface MutinyDelegate
      Returns:
      the delegate used by this Mutiny object of generated type
    • toString

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

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

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

      public String address()
      Returns:
    • headers

      public MultiMap headers()
      Returns:
      the headers
    • body

      public T body()
      Returns:
      the body, or null.
    • replyAddress

      public String replyAddress()
      Returns:
      the reply address, or null, if message was sent without a reply handler.
    • isSend

      public boolean isSend()
      Returns:
      true if this is a send.
    • reply

      public void reply(Object message)
      Parameters:
      message - the message to reply with.
    • reply

      public void reply(Object message, io.vertx.core.eventbus.DeliveryOptions options)
      Parameters:
      message - the reply message
      options - the delivery options
    • replyAndRequest

      @CheckReturnValue public <R> io.smallrye.mutiny.Uni<Message<R>> replyAndRequest(Object message)
      Reply to this message, specifying a replyHandler for the reply - i.e. to receive the reply to the reply.

      If the message was sent specifying a reply handler, that handler will be called when it has received a reply. If the message wasn't sent specifying a receipt handler this method does nothing.

      Unlike the bare Vert.x variant, this method returns a Uni. Don't forget to subscribe on it to trigger the operation.

      Parameters:
      message - the message to reply with.
      Returns:
      the uni firing the result of the operation when completed, or a failure if the operation failed.
    • replyAndRequestAndAwait

      public <R> Message<R> replyAndRequestAndAwait(Object message)
      Blocking variant of replyAndRequest(Object).

      This method waits 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 to reply with.
      Returns:
      the Message instance produced by the operation.
    • replyAndRequestAndForget

      public <R> void replyAndRequestAndForget(Object message)
      Variant of replyAndRequest(Object) that ignores the result of the operation.

      This method subscribes on the result of replyAndRequest(Object), but discards the outcome (item or failure). This method is useful to trigger the asynchronous operation from replyAndRequest(Object) but you don't need to compose it with other operations.

      Parameters:
      message - the message to reply with.
    • replyAndRequest

      @CheckReturnValue public <R> io.smallrye.mutiny.Uni<Message<R>> replyAndRequest(Object message, io.vertx.core.eventbus.DeliveryOptions options)
      Like replyAndRequest(java.lang.Object) but specifying options that can be used to configure the delivery.

      Unlike the bare Vert.x variant, this method returns a Uni. Don't forget to subscribe on it to trigger the operation.

      Parameters:
      message - the message body, may be null
      options - delivery options
      Returns:
      the uni firing the result of the operation when completed, or a failure if the operation failed.
    • replyAndRequestAndAwait

      public <R> Message<R> replyAndRequestAndAwait(Object message, io.vertx.core.eventbus.DeliveryOptions options)
      Blocking variant of replyAndRequest(Object,DeliveryOptions).

      This method waits 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 body, may be null
      options - delivery options
      Returns:
      the Message instance produced by the operation.
    • replyAndRequestAndForget

      public <R> void replyAndRequestAndForget(Object message, io.vertx.core.eventbus.DeliveryOptions options)
      Variant of replyAndRequest(Object,DeliveryOptions) that ignores the result of the operation.

      This method subscribes on the result of replyAndRequest(Object,DeliveryOptions), but discards the outcome (item or failure). This method is useful to trigger the asynchronous operation from replyAndRequest(Object,DeliveryOptions) but you don't need to compose it with other operations.

      Parameters:
      message - the message body, may be null
      options - delivery options
    • fail

      public void fail(int failureCode, String message)
      Parameters:
      failureCode - A failure code to pass back to the sender
      message - A message to pass back to the sender
    • newInstance

      public static <T> Message<T> newInstance(io.vertx.core.eventbus.Message arg)
    • newInstance

      public static <T> Message<T> newInstance(io.vertx.core.eventbus.Message arg, TypeArg<T> __typeArg_T)