public final class Message extends Object implements Externalizable
| Modifier and Type | Class and Description |
|---|---|
static class |
Message.Builder |
| Modifier and Type | Field and Description |
|---|---|
static String |
HEADER_CORRELATION_ID
This header is supposed to be used by application in order to correlate request and response
messages.
|
static String |
HEADER_QUALIFIER
This header is supposed to be used by application in case if same data type can be reused for
several messages so it will allow to qualify the specific message type.
|
static String |
HEADER_SENDER
This header represents sender address of type
Address. |
| Constructor and Description |
|---|
Message() |
| Modifier and Type | Method and Description |
|---|---|
static Message.Builder |
builder()
Instantiates new empty message builder.
|
String |
correlationId()
Returns message correlation id.
|
<T> T |
data()
Return the message data, which can be byte array, string or any type.
|
static Message |
from(Message message)
Instantiates new message with the same data and headers as at given message.
|
static Message |
fromData(Object data)
Instantiates a new message with the given data and without headers.
|
static Message |
fromHeaders(Map<String,String> headers)
Instantiates a new message with the given headers and with empty data.
|
static Message |
fromQualifier(String qualifier)
Instantiates a new message with the given qualifier header and with empty data.
|
String |
header(String name)
Returns header value by given header name.
|
Map<String,String> |
headers()
Returns the message headers.
|
String |
qualifier()
Returns message qualifier.
|
void |
readExternal(ObjectInput in) |
io.scalecube.net.Address |
sender()
Returns
Address of the sender of this message. |
String |
toString() |
static Message.Builder |
with(Message message)
Instantiates new message builder with the same data and headers as at given message.
|
static Message.Builder |
withData(Object data)
Instantiates a new message builder with the given data and without headers.
|
static Message.Builder |
withHeaders(Map<String,String> headers)
Instantiates a new message builder with the given headers and with empty data.
|
static Message.Builder |
withQualifier(String qualifier)
Instantiates a new message builder with the given qualifier header and with empty data.
|
void |
writeExternal(ObjectOutput out) |
public static final String HEADER_QUALIFIER
public static final String HEADER_CORRELATION_ID
public static final String HEADER_SENDER
Address. It's an address of message
originator. This header is optional.public static Message fromData(Object data)
data - the data to build a message frompublic static Message.Builder withData(Object data)
data - the initial data for the builderpublic static Message fromHeaders(Map<String,String> headers)
headers - an initial headers to build a message frompublic static Message.Builder withHeaders(Map<String,String> headers)
headers - the initial headers for the builderpublic static Message fromQualifier(String qualifier)
qualifier - the qualifier to build a message frompublic static Message.Builder withQualifier(String qualifier)
qualifier - the initial qualifier for the builderpublic static Message from(Message message)
message - the message to be copiedpublic static Message.Builder with(Message message)
message - the message to instantiate the new builder frompublic static Message.Builder builder()
public String header(String name)
name - header namepublic String qualifier()
public String correlationId()
public <T> T data()
T - data typepublic io.scalecube.net.Address sender()
Address of the sender of this message.public void writeExternal(ObjectOutput out) throws IOException
writeExternal in interface ExternalizableIOExceptionpublic void readExternal(ObjectInput in) throws IOException, ClassNotFoundException
readExternal in interface ExternalizableIOExceptionClassNotFoundExceptionCopyright © 2015–2020. All rights reserved.