Interface Message<T>
-
public interface Message<T>
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
fail(int, java.lang.String)
can be called.- Author:
- Tim Fox
-
-
Method Summary
All Methods Instance Methods Abstract Methods Default Methods Modifier and Type Method Description String
address()
The address the message was sent toT
body()
The body of the message.default void
fail(int failureCode, String message)
Signal to the sender that processing of this message failed.MultiMap
headers()
Multi-map of message headers.boolean
isSend()
Signals if this message represents a send or publish event.default void
reply(Object message)
Reply to this message.void
reply(Object message, DeliveryOptions options)
Linkreply(Object)
but allows you to specify delivery options for the reply.String
replyAddress()
The reply address.default <R> Future<Message<R>>
replyAndRequest(Object message)
Reply to this message, specifying areplyHandler
for the reply - i.e.<R> Future<Message<R>>
replyAndRequest(Object message, DeliveryOptions options)
LikereplyAndRequest(Object)
but specifyingoptions
that can be used to configure the delivery.
-
-
-
Method Detail
-
address
String address()
The address the message was sent to
-
headers
MultiMap headers()
Multi-map of message headers. Can be empty- Returns:
- the headers
-
body
T body()
The body of the message. Can be null.- Returns:
- the body, or null.
-
replyAddress
String replyAddress()
The reply address. Can be null.- Returns:
- the reply address, or null, if message was sent without a reply handler.
-
isSend
boolean isSend()
Signals if this message represents a send or publish event.- Returns:
- true if this is a send.
-
reply
default void reply(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
- the message to reply with.
-
reply
void reply(Object message, DeliveryOptions options)
Linkreply(Object)
but allows you to specify delivery options for the reply.- Parameters:
message
- the reply messageoptions
- the delivery options
-
replyAndRequest
default <R> Future<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.
- Parameters:
message
- the message to reply with.- Returns:
- a future notified when any reply from the recipient is received
-
replyAndRequest
<R> Future<Message<R>> replyAndRequest(Object message, DeliveryOptions options)
LikereplyAndRequest(Object)
but specifyingoptions
that can be used to configure the delivery.- Parameters:
message
- the message body, may benull
options
- delivery options- Returns:
- a future notified when any reply from the recipient is received
-
fail
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
- A failure code to pass back to the sendermessage
- A message to pass back to the sender
-
-