Top Description Methods
io.vertx.core.eventbus

public Interface Message<T>

Known Direct Implementers
io.vertx.core.eventbus.impl.MessageImpl
Annotations
@VertxGen
Imports
io.vertx.codegen.annotations.CacheReturn, .Nullable, .VertxGen, io.vertx.core.AsyncResult, .Future, .Handler, .MultiMap

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.

If you want to notify the sender that processing failed, then fail can be called.

Author
Tim Fox

Method Summary

Modifier and TypeMethod and Description
public String
address()

The address the message was sent to

public T

Returns:

the body, or null.
body
()

The body of the message.

public default void
fail(int
A failure code to pass back to the sender
failureCode
,
String
A message to pass back to the sender
message
)

Signal to the sender that processing of this message failed.

public MultiMap

Returns:

the headers
headers
()

Multi-map of message headers.

public boolean

Returns:

true if this is a send.
isSend
()

Signals if this message represents a send or publish event.

public default void
reply(@Nullable Object
the message to reply with.
message
)

Reply to this message.

public void
reply(@Nullable Object
the reply message
message
,
DeliveryOptions
the delivery options
options
)

Link reply(Object) but allows you to specify delivery options for the reply.

public @Nullable String

Returns:

the reply address, or null, if message was sent without a reply handler.
replyAddress
()

The reply address.

public default <R> void
replyAndRequest(@Nullable Object
the message to reply with.
message
,
Handler<AsyncResult<Message<R>>>
the reply handler for the reply.
replyHandler
)

Reply to this message, specifying a replyHandler for the reply - i.e. to receive the reply to the reply.

public default <R> Future<Message<R>>
replyAndRequest(@Nullable Object message)

Like replyAndRequest(Object, Handler) but returns a Future of the asynchronous result

public default <R> void
replyAndRequest(@Nullable Object
the message body, may be null
message
,
DeliveryOptions
delivery options
options
,
Handler<AsyncResult<Message<R>>>
reply handler will be called when any reply from the recipient is received
replyHandler
)

Like replyAndRequest(Object, Handler) but specifying options that can be used to configure the delivery.

public <R> Future<Message<R>>
replyAndRequest(@Nullable Object message, DeliveryOptions options)

Like replyAndRequest(Object, DeliveryOptions, Handler) but returns a Future of the asynchronous result

Method Detail

addressback to summary
public String address()

The address the message was sent to

bodyback to summary
public T body()

The body of the message. Can be null.

Returns:T

the body, or null.

Annotations
@CacheReturn
failback to summary
public default void fail(int failureCode, String message)

Signal to the sender that processing of this message failed.

If the message was sent specifying a result handler the handler will be called with a failure corresponding to the failure code and message specified here.

Parameters
failureCode:int

A failure code to pass back to the sender

message:String

A message to pass back to the sender

headersback to summary
public MultiMap headers()

Multi-map of message headers. Can be empty

Returns:MultiMap

the headers

isSendback to summary
public boolean isSend()

Signals if this message represents a send or publish event.

Returns:boolean

true if this is a send.

replyback to summary
public default void reply(@Nullable Object message)

Reply to this message.

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.

Parameters
message:@Nullable Object

the message to reply with.

replyback to summary
public void reply(@Nullable Object message, DeliveryOptions options)

Link reply(Object) but allows you to specify delivery options for the reply.

Parameters
message:@Nullable Object

the reply message

options:DeliveryOptions

the delivery options

replyAddressback to summary
public @Nullable String replyAddress()

The reply address. Can be null.

Returns:@Nullable String

the reply address, or null, if message was sent without a reply handler.

replyAndRequestback to summary
public default <R> void replyAndRequest(@Nullable Object message, Handler<AsyncResult<Message<R>>> replyHandler)

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.

Parameters
message:@Nullable Object

the message to reply with.

replyHandler:Handler<AsyncResult<Message<R>>>

the reply handler for the reply.

replyAndRequestback to summary
public default <R> Future<Message<R>> replyAndRequest(@Nullable Object message)

Like replyAndRequest(Object, Handler) but returns a Future of the asynchronous result

replyAndRequestback to summary
public default <R> void replyAndRequest(@Nullable Object message, DeliveryOptions options, Handler<AsyncResult<Message<R>>> replyHandler)

Like replyAndRequest(Object, Handler) but specifying options that can be used to configure the delivery.

Parameters
message:@Nullable Object

the message body, may be null

options:DeliveryOptions

delivery options

replyHandler:Handler<AsyncResult<Message<R>>>

reply handler will be called when any reply from the recipient is received

replyAndRequestback to summary
public <R> Future<Message<R>> replyAndRequest(@Nullable Object message, DeliveryOptions options)

Like replyAndRequest(Object, DeliveryOptions, Handler) but returns a Future of the asynchronous result