public abstract class AbstractMessagingService extends ServiceDelegator implements MessagingService
MessagingService interface.| Modifier and Type | Field and Description |
|---|---|
protected boolean |
forceListening |
protected static String |
FORMAT_CLOUDEVENTS |
protected MessageQueue |
queue |
protected CdsRuntime |
runtime |
protected CdsProperties.Messaging.MessagingServiceConfig |
serviceConfig |
COMPOSITE_NAME, EVENT_MESSAGING_ERROR| Modifier | Constructor and Description |
|---|---|
protected |
AbstractMessagingService(CdsProperties.Messaging.MessagingServiceConfig serviceConfig,
CdsRuntime runtime) |
| Modifier and Type | Method and Description |
|---|---|
protected void |
cloudEventsFormatter(TopicMessageEventContext context) |
protected boolean |
createOrUpdateQueuesAndSubscriptions()
Performs the initialization of the messaging service, by initializing the queues and registering the topic subscriptions.
|
protected abstract void |
createQueue(String name,
Map<String,String> properties)
Request the broker for creating a queue with the specified queue name.
|
protected abstract void |
createQueueSubscription(String queue,
String topic)
Requests the broker for creating a queue topic subscription.
|
protected void |
defaultErrorHandler(MessagingErrorEventContext context) |
void |
emit(EventContext context) |
void |
emit(String topic,
Map<String,Object> message) |
void |
emit(String topic,
String message) |
protected abstract void |
emitTopicMessage(String topic,
TopicMessageEventContext topicMessageEventContext)
Performs the message emit on the messaging broker.
|
protected BiPredicate<MessageTopic,String> |
getTopicMatcher()
The topic matcher is used when the broker subscribes to a topic pattern.
|
void |
init()
Performs the initialization of the messaging service, by initializing the queues and registering the topic subscriptions.
|
protected boolean |
isCloudEventsFormat() |
void |
on(String[] events,
String[] entities,
int order,
Handler handler) |
protected abstract void |
registerQueueListener(String queue,
MessagingBrokerQueueListener listener)
Registers the
MessagingBrokerQueueListener implementation to the specified queue of
the message broker. |
protected abstract void |
removeQueue(String name)
Request the broker for queue deletion with all its subscriptions.
|
protected void |
sendMessageEvent(TopicMessageEventContext context) |
void |
stop()
Used to stop the resources allocated by the messaging service, e.g.
|
protected String |
toFullyQualifiedQueueName(MessageQueue queue)
Translates the queue name corresponding the broker queue name specification.
|
protected String |
toFullyQualifiedTopicName(String event,
boolean inbound)
Translates the given event definition to the broker environment specific name.
|
after, after, before, before, getDelegatedService, getName, onprotected static final String FORMAT_CLOUDEVENTS
protected final CdsProperties.Messaging.MessagingServiceConfig serviceConfig
protected final CdsRuntime runtime
protected final MessageQueue queue
protected final boolean forceListening
protected AbstractMessagingService(CdsProperties.Messaging.MessagingServiceConfig serviceConfig, CdsRuntime runtime)
public void init()
public void stop()
protected boolean createOrUpdateQueuesAndSubscriptions()
public void emit(EventContext context)
emit in interface Serviceemit in class ServiceDelegatorprotected boolean isCloudEventsFormat()
public void emit(String topic, String message)
emit in interface MessagingServicepublic void emit(String topic, Map<String,Object> message)
emit in interface MessagingService@HandlerOrder(value=11000) protected void cloudEventsFormatter(TopicMessageEventContext context)
@HandlerOrder(value=-9900) protected void sendMessageEvent(TopicMessageEventContext context)
@HandlerOrder(value=11000) protected void defaultErrorHandler(MessagingErrorEventContext context)
public void on(String[] events, String[] entities, int order, Handler handler)
on in interface Serviceon in class ServiceDelegatorprotected String toFullyQualifiedQueueName(MessageQueue queue)
queue - queue specificationprotected String toFullyQualifiedTopicName(String event, boolean inbound)
event - event definitioninbound - determines whether topic is used for subscriptionprotected BiPredicate<MessageTopic,String> getTopicMatcher()
protected abstract void removeQueue(String name) throws IOException
name - queue nameIOException - In case an error occurs while creating the queueprotected abstract void createQueue(String name, Map<String,String> properties) throws IOException
name - queue nameproperties - queue configuration propertiesIOException - In case an error occurs while creating the queueprotected abstract void createQueueSubscription(String queue, String topic) throws IOException
true
only when the queue topic subscription was successfully created or already available.
Otherwise false is returned.queue - the queue nametopic - the topic the queue should subscribe toIOException - In case an error occurs during the subscriptionprotected abstract void registerQueueListener(String queue, MessagingBrokerQueueListener listener) throws IOException
MessagingBrokerQueueListener implementation to the specified queue of
the message broker.queue - the queue namelistener - implementation of the MessagingBrokerQueueListener interfaceIOException - In case when any errors occurs while registering the listener to the brokerprotected abstract void emitTopicMessage(String topic, TopicMessageEventContext topicMessageEventContext)
topic - the message topictopicMessageEventContext - the TopicMessageEventContext of the messageCopyright © 2023. All rights reserved.