Class MessageData
java.lang.Object
com.kosdev.kos.commons.core.broker.MessageData
A
MessageBroker message forwarded to a subscriber, typically via the
MessageBrokerCallback interface.
Messages are routed through the broker based on the topic of the message, which is a filesystem path style string. As topics are inherently hierarchical, it is possible to subscribe to a sub-topic using a wildcard to receive all child topics. When using wildcards, the message topic does not necessarily match the subscription topic so both are included as properties:
topic: The topic the sender used to send the message.subscription: The topic that was used during the subscribe call.
jsonBody property. If the subscribe call included
a java POJO class then the body will contain an instance of the specified
class, deserialized from jsonBody.
Example
public class MyClass {
@Autowired
private MessageBroker broker;
...
broker.subscribe(mySession, "/topic/goes/here", Pojo.class, (msg) -> {
Pojo body = msg.getBody();
}
}
- Since:
- 1
- Version:
- 1
- See Also:
-
Constructor Summary
ConstructorsConstructorDescriptionMessageData(Object session, String topic, String subscription, Object body, com.fasterxml.jackson.databind.JsonNode jsonBody) -
Method Summary
Modifier and TypeMethodDescriptionbooleangetBody()com.fasterxml.jackson.databind.JsonNodegetTopic()inthashCode()voidvoidsetJsonBody(com.fasterxml.jackson.databind.JsonNode jsonBody) voidsetSession(Object session) voidsetSubscription(String subscription) voidtoString()
-
Constructor Details
-
MessageData
public MessageData() -
MessageData
-
-
Method Details
-
getSession
-
getTopic
-
getSubscription
-
getBody
-
getJsonBody
public com.fasterxml.jackson.databind.JsonNode getJsonBody() -
setSession
-
setTopic
-
setSubscription
-
setBody
-
setJsonBody
public void setJsonBody(com.fasterxml.jackson.databind.JsonNode jsonBody) -
equals
-
hashCode
public int hashCode() -
toString
-