public final class ServiceMessage extends Object
| Modifier and Type | Class and Description |
|---|---|
static class |
ServiceMessage.Builder |
| Modifier and Type | Field and Description |
|---|---|
static String |
DEFAULT_DATA_FORMAT
Default data format.
|
static String |
HEADER_DATA_FORMAT
Data format header.
|
static String |
HEADER_DATA_TYPE
This is a system header which used by transport for serialization and deserialization purpose.
|
static String |
HEADER_ERROR_TYPE
Error type header.
|
static String |
HEADER_QUALIFIER
Qualifier header.
|
static int |
NULL_ERROR_TYPE
Null value for error type.
|
| Modifier and Type | Method and Description |
|---|---|
static ServiceMessage.Builder |
builder()
Instantiates new empty message builder.
|
<T> T |
data()
Return the message data, which can be byte array, string or any type.
|
String |
dataFormat()
Returns data format of the message data.
|
String |
dataFormatOrDefault()
Returns data format of the message data or default one.
|
static ServiceMessage |
error(String qualifier,
int errorType,
int errorCode,
String errorMessage)
Instantiates new message with error qualifier for given error type and specified error code and
message.
|
int |
errorType()
Returns error type.
|
static ServiceMessage.Builder |
from(ServiceMessage message)
Instantiates new message with the same data and headers as at given message.
|
boolean |
hasData() |
boolean |
hasData(Class<?> dataClass)
Verify that this message contains data.
|
String |
header(String name)
Returns header value by given header name.
|
Map<String,String> |
headers()
Returns the message headers.
|
boolean |
isError()
Describes whether the message is an error.
|
String |
qualifier()
Returns message's qualifier.
|
String |
toString() |
public static final String DEFAULT_DATA_FORMAT
public static final String HEADER_QUALIFIER
public static final String HEADER_DATA_TYPE
public static final String HEADER_DATA_FORMAT
public static final String HEADER_ERROR_TYPE
public static final int NULL_ERROR_TYPE
public static ServiceMessage.Builder from(ServiceMessage message)
message - the message to be copiedpublic static ServiceMessage error(String qualifier, int errorType, int errorCode, String errorMessage)
qualifier - origin qualifier.errorType - the error type to be used in message qualifier.errorCode - the error code.errorMessage - the error message.public static ServiceMessage.Builder builder()
public String header(String name)
name - header namepublic String qualifier()
public String dataFormat()
public String dataFormatOrDefault()
public <T> T data()
T - data typepublic boolean hasData()
public boolean hasData(Class<?> dataClass)
dataClass - the expected class of the datapublic boolean isError()
true if error, otherwise false.public int errorType()
Copyright © 2015–2021. All rights reserved.