Package org.nuxeo.runtime.pubsub
Class PubSubServiceImpl
java.lang.Object
org.nuxeo.runtime.model.DefaultComponent
org.nuxeo.runtime.pubsub.PubSubServiceImpl
- All Implemented Interfaces:
Adaptable
,Component
,Extensible
,PubSubService
,TimestampedService
Implementation for the Publish/Subscribe Service.
- Since:
- 9.1
-
Field Summary
Modifier and TypeFieldDescriptionstatic final String
protected io.dropwizard.metrics5.Counter
protected PubSubProvider
The currently-configured provider.protected Map<String,
List<BiConsumer<String, byte[]>>> List of subscribers for each topic.static final String
Fields inherited from class org.nuxeo.runtime.model.DefaultComponent
lastModified, name
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionvoid
deactivate
(ComponentContext context) Deactivates the component.int
The component notification order forComponent.start(ComponentContext)
.void
Publishes a message to the given topic.void
registerSubscriber
(String topic, BiConsumer<String, byte[]> subscriber) Registers a subscriber for the given topic.void
start
(ComponentContext context) Start the component.void
stop
(ComponentContext context) Stop the component.void
unregisterSubscriber
(String topic, BiConsumer<String, byte[]> subscriber) Unregisters a subscriber for the given topic.Methods inherited from class org.nuxeo.runtime.model.DefaultComponent
activate, addRuntimeMessage, addRuntimeMessage, getAdapter, getDescriptor, getDescriptors, getLastModified, getRegistry, register, registerContribution, registerExtension, setLastModified, setModifiedNow, setName, unregister, unregisterContribution, unregisterExtension
-
Field Details
-
XP_CONFIG
- See Also:
-
GLOBAL_PUBLISH_COUNTER
-
provider
The currently-configured provider. -
subscribers
List of subscribers for each topic. -
options
-
globalPublishCount
protected io.dropwizard.metrics5.Counter globalPublishCount
-
-
Constructor Details
-
PubSubServiceImpl
public PubSubServiceImpl()
-
-
Method Details
-
deactivate
Description copied from interface:Component
Deactivates the component.This method is called by the runtime when a component is deactivated.
- Specified by:
deactivate
in interfaceComponent
- Overrides:
deactivate
in classDefaultComponent
- Parameters:
context
- the runtime context
-
start
Description copied from interface:Component
Start the component. This method is called after all the components were resolved and activated- Specified by:
start
in interfaceComponent
- Overrides:
start
in classDefaultComponent
-
stop
Description copied from interface:Component
Stop the component.- Specified by:
stop
in interfaceComponent
- Overrides:
stop
in classDefaultComponent
- Throws:
InterruptedException
-
getApplicationStartedOrder
public int getApplicationStartedOrder()Description copied from interface:Component
The component notification order forComponent.start(ComponentContext)
.Components are notified in increasing order. Order 1000 is the default order for components that don't care. Order 100 is the repository initialization.
- Specified by:
getApplicationStartedOrder
in interfaceComponent
- Returns:
- the order, 1000 by default
-
publish
Description copied from interface:PubSubService
Publishes a message to the given topic.- Specified by:
publish
in interfacePubSubService
- Parameters:
topic
- the topicmessage
- the message
-
registerSubscriber
Description copied from interface:PubSubService
Registers a subscriber for the given topic.The subscriber must deal with the message without delay and return immediately, usually by storing it in a thread-safe datastructure.
- Specified by:
registerSubscriber
in interfacePubSubService
- Parameters:
topic
- the topicsubscriber
- the subscriber, who will receive the topic and abyte[]
message
-
unregisterSubscriber
Description copied from interface:PubSubService
Unregisters a subscriber for the given topic.- Specified by:
unregisterSubscriber
in interfacePubSubService
- Parameters:
topic
- the topicsubscriber
- the subscriber
-