Class Message<T>
- java.lang.Object
-
- io.vertx.mutiny.core.eventbus.Message<T>
-
public class Message<T> extends Object
Represents a message that is received from the event bus in a handler.Messages have a
body()
, which can be null, and alsoheaders()
, 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
NOTE: This class has been automatically generated from thefail(int, java.lang.String)
can be called.original
non Mutiny-ified interface using Vert.x codegen.
-
-
Field Summary
Fields Modifier and Type Field Description static TypeArg<Message>
__TYPE_ARG
TypeArg<T>
__typeArg_0
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description String
address()
T
body()
boolean
equals(Object o)
void
fail(int failureCode, String message)
io.vertx.core.eventbus.Message
getDelegate()
int
hashCode()
MultiMap
headers()
boolean
isSend()
static <T> Message<T>
newInstance(io.vertx.core.eventbus.Message arg)
static <T> Message<T>
newInstance(io.vertx.core.eventbus.Message arg, TypeArg<T> __typeArg_T)
void
reply(Object message)
void
reply(Object message, io.vertx.core.eventbus.DeliveryOptions options)
String
replyAddress()
<R> io.smallrye.mutiny.Uni<Message<R>>
replyAndRequest(Object message)
Reply to this message, specifying areplyHandler
for the reply - i.e.<R> io.smallrye.mutiny.Uni<Message<R>>
replyAndRequest(Object message, io.vertx.core.eventbus.DeliveryOptions options)
LikereplyAndRequest(java.lang.Object)
but specifyingoptions
that can be used to configure the delivery.<R> Message<R>
replyAndRequestAndAwait(Object message)
Blocking variant ofreplyAndRequest(Object)
.<R> Message<R>
replyAndRequestAndAwait(Object message, io.vertx.core.eventbus.DeliveryOptions options)
Blocking variant ofreplyAndRequest(Object,DeliveryOptions)
.<R> void
replyAndRequestAndForget(Object message)
Variant ofreplyAndRequest(Object)
that ignores the result of the operation.<R> void
replyAndRequestAndForget(Object message, io.vertx.core.eventbus.DeliveryOptions options)
Variant ofreplyAndRequest(Object,DeliveryOptions)
that ignores the result of the operation.String
toString()
-
-
-
Method Detail
-
getDelegate
public io.vertx.core.eventbus.Message getDelegate()
-
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 messageoptions
- the delivery options
-
replyAndRequest
@CheckReturnValue public <R> io.smallrye.mutiny.Uni<Message<R>> replyAndRequest(Object message)
Reply to this message, specifying areplyHandler
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 ofreplyAndRequest(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 ofreplyAndRequest(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 fromreplyAndRequest(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)
LikereplyAndRequest(java.lang.Object)
but specifyingoptions
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 benull
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 ofreplyAndRequest(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 benull
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 ofreplyAndRequest(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 fromreplyAndRequest(Object,DeliveryOptions)
but you don't need to compose it with other operations.- Parameters:
message
- the message body, may benull
options
- delivery options
-
fail
public void fail(int failureCode, String message)
- Parameters:
failureCode
- A failure code to pass back to the sendermessage
- A message to pass back to the sender
-
newInstance
public static <T> Message<T> newInstance(io.vertx.core.eventbus.Message arg)
-
-