![]() |
Open Kilda Java Documentation
|
Public Member Functions | |
BaseMessage (@JsonProperty(TIMESTAMP) final long timestamp) | |
BaseMessage () | |
long | getTimestamp () |
void | setTimestamp (long timestamp) |
Static Public Member Functions | |
static final< T extends BaseMessage > T | getMessage (String json, Class< T > type) throws java.io.IOException |
static final< T extends BaseMessage > T | tryGetMessage (String json, Class< T > type) |
Protected Attributes | |
long | timestamp = 0L |
BaseMessage is the base class for all OpenKilda messages. There are several use cases we can solve with a common base class:
(1) we can use it for message deserialization everywhere, guaranteeing that that we have a known entity, and any failure to deserialize is really a failure and worthy of a Warning. (2) we can introduce common functionality that we'd like to have - Destination / Source / Return information. Possibly desired kilda topic to help with traceability.
Initial base member will have a timestamp field.
Definition at line 44 of file BaseMessage.java.
org.openkilda.messaging.BaseMessage.BaseMessage | ( | @JsonProperty(TIMESTAMP) final long | timestamp | ) |
Instance constructor.
timestamp | message timestamp |
Definition at line 63 of file BaseMessage.java.
org.openkilda.messaging.BaseMessage.BaseMessage | ( | ) |
Create a BaseMessage with the current time as the timestamp
Definition at line 70 of file BaseMessage.java.
|
static |
Uses the standard MAPPER to retrieve a message, with the right type information
json | The JSON string |
type | The expected type of the message |
<T> | The type |
Definition at line 101 of file BaseMessage.java.
long org.openkilda.messaging.BaseMessage.getTimestamp | ( | ) |
void org.openkilda.messaging.BaseMessage.setTimestamp | ( | long | timestamp | ) |
Sets the timestamp.
timestamp | The timestamp, eg System.currentTimeMillis() |
Definition at line 89 of file BaseMessage.java.
|
static |
Similar to consume message, but suppress the exception. This is useful if you want to see if the object can be mapped to the type, returning null if unsuccessful.
NB: this does have the potential of hiding problems; consider replacing if we can be more emphatic wrt when we deserialize.
json | The JSON string |
type | The expected type of the message |
<T> | The type |
Definition at line 118 of file BaseMessage.java.
|
protected |
Message timestamp.
Definition at line 54 of file BaseMessage.java.