Package com.tccc.kos.core.service.app
Class AppMessageBroker
java.lang.Object
com.tccc.kos.core.service.app.AppMessageBroker
- All Implemented Interfaces:
MessageBroker
Wrapper for the system message broker that prefixes the topics
with the application id.
- Since:
- 1.0
- Version:
- 2023-02-01
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidSends a broker message from the specified session.voidSends a broker message to the given topic.voidSends a broker message to the given topic with the given data.voidSends a broker message to the given topic with the given data.voidSends a broker message from the specified session where the body is already in parsed JSON form.voidsubscribe(Object session, String topic, MessageBrokerCallback callback) Subscribes to the specified topic.voidsubscribe(Object session, String topic, Class<?> bodyClass, MessageBrokerCallback callback) Subscribes to the specified topic.voidsubscribe(String topic, MessageBrokerCallback callback) Subscribes to the specified topic.voidsubscribe(String topic, Class<?> bodyClass, MessageBrokerCallback callback) Subscribes to the specified topic.voidunsubscribe(Object session) Unsubscribes from all topics in the specified session.voidunsubscribe(Object session, String topic) Unsubscribes from the specified topic.voidunsubscribe(String topic) Unsubscribes from the specified topic.
-
Constructor Details
-
AppMessageBroker
public AppMessageBroker()
-
-
Method Details
-
subscribe
Subscribes to the specified topic. If the message has a body, then it will be accessible via jsonBody in the message data.The subscription will be linked to the application and will automatically be removed when the application unloads.
- Parameters:
topic- the topic to subscribe tocallback- the callback to use
-
subscribe
Subscribes to the specified topic. If a message has a body, it will be serialized to JSON. The callback has access to the JSON representation of the data in jsonBody. If a class is specified, the JSON will be deserialized at the specified class and placed in the body property of the message data.The subscription will be linked to the application and will automatically be removed when the application unloads.
- Parameters:
topic- the topic to subscribe tobodyClass- the class to serialize the body to (optional)callback- the callback to use
-
unsubscribe
Unsubscribes from the specified topic. The unsubscribed topic must match the topic used to subscribe.This will unsubscribe an associated subscription made using the non-session subscribe calls.
- Parameters:
topic- the topic to unsubscribe form
-
subscribe
Description copied from interface:MessageBrokerSubscribes to the specified topic. If the message has a body, then it will be accessible via jsonBody in the message data.- Specified by:
subscribein interfaceMessageBroker- Parameters:
session- the session keytopic- the topic to subscribe tocallback- the callback to use
-
subscribe
public void subscribe(Object session, String topic, Class<?> bodyClass, MessageBrokerCallback callback) Description copied from interface:MessageBrokerSubscribes to the specified topic. If a message has a body, it will be serialized to JSON. The callback has access to the JSON representation of the data in jsonBody. If a class is specified, the JSON will be deserialized at the specified class and placed in the body property of the message data.- Specified by:
subscribein interfaceMessageBroker- Parameters:
session- the session keytopic- the topic to subscribe tobodyClass- the class to serialize the body to (optional)callback- the callback to use
-
unsubscribe
Description copied from interface:MessageBrokerUnsubscribes from the specified topic. The unsubscribed topic must match the topic used to subscribe.- Specified by:
unsubscribein interfaceMessageBroker- Parameters:
session- the session key (optional: no-op if null)topic- the topic to unsubscribe form
-
unsubscribe
Description copied from interface:MessageBrokerUnsubscribes from all topics in the specified session.- Specified by:
unsubscribein interfaceMessageBroker- Parameters:
session- the session key (optional: no-op if null)
-
send
Description copied from interface:MessageBrokerSends a broker message to the given topic.- Specified by:
sendin interfaceMessageBroker- Parameters:
topic- the topic to send
-
send
Description copied from interface:MessageBrokerSends a broker message to the given topic with the given data.- Specified by:
sendin interfaceMessageBroker- Parameters:
topic- the topic to sendbody- the message body (optional)
-
send
Description copied from interface:MessageBrokerSends a broker message to the given topic with the given data.- Specified by:
sendin interfaceMessageBroker- Parameters:
topic- the topic to sendbody- the message body (optional)
-
send
Description copied from interface:MessageBrokerSends a broker message from the specified session. This session will not receive the message.- Specified by:
sendin interfaceMessageBroker- Parameters:
session- the sending key (optional)topic- the topic to sendbody- the message body (optional)jsonView- the view to use when converting to JSON (optional)
-
sendJson
Description copied from interface:MessageBrokerSends a broker message from the specified session where the body is already in parsed JSON form. This session will NOT receive the message.- Specified by:
sendJsonin interfaceMessageBroker- Parameters:
session- the sending session key (optional)topic- the topic to sendjsonBody- the message body in parsed JSON (optional)
-