vertx / io.vertx.core.eventbus / Message

Message

interface Message<T : Any>

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 will also have a #replyAddress. In that case the message can be replied to using that reply address, or, more simply by just using #reply.

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

Author
Tim Fox

Functions

address

abstract fun address(): String

The address the message was sent to

body

abstract fun body(): T

The body of the message. Can be null.

fail

abstract fun fail(failureCode: Int, message: String): Unit

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.

headers

abstract fun headers(): MultiMap

Multi-map of message headers. Can be empty

isSend

abstract fun isSend(): Boolean

Signals if this message represents a send or publish event.

reply

abstract fun reply(message: Any): Unit

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.

abstract fun <R : Any> reply(message: Any, replyHandler: Handler<AsyncResult<Message<R>>>): Unit

The same as reply(R message) but you can specify handler for the reply - i.e. to receive the reply to the reply.

abstract fun reply(message: Any, options: DeliveryOptions): Unit

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

abstract fun <R : Any> reply(message: Any, options: DeliveryOptions, replyHandler: Handler<AsyncResult<Message<R>>>): Unit

The same as reply(R message, DeliveryOptions) but you can specify handler for the reply - i.e. to receive the reply to the reply.

replyAddress

abstract fun replyAddress(): String

The reply address. Can be null.