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
FieldsModifier and TypeFieldDescriptionstatic final Stringprotected io.dropwizard.metrics5.Counterprotected PubSubProviderThe currently-configured provider.protected Map<String,List<BiConsumer<String, byte[]>>> List of subscribers for each topic.static final StringFields inherited from class org.nuxeo.runtime.model.DefaultComponent
lastModified, name -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoiddeactivate(ComponentContext context) Deactivates the component.intThe component notification order forComponent.start(ComponentContext).voidPublishes a message to the given topic.voidregisterSubscriber(String topic, BiConsumer<String, byte[]> subscriber) Registers a subscriber for the given topic.voidstart(ComponentContext context) Start the component.voidstop(ComponentContext context) Stop the component.voidunregisterSubscriber(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:ComponentDeactivates the component.This method is called by the runtime when a component is deactivated.
- Specified by:
deactivatein interfaceComponent- Overrides:
deactivatein classDefaultComponent- Parameters:
context- the runtime context
-
start
Description copied from interface:ComponentStart the component. This method is called after all the components were resolved and activated- Specified by:
startin interfaceComponent- Overrides:
startin classDefaultComponent
-
stop
Description copied from interface:ComponentStop the component.- Specified by:
stopin interfaceComponent- Overrides:
stopin classDefaultComponent- Throws:
InterruptedException
-
getApplicationStartedOrder
public int getApplicationStartedOrder()Description copied from interface:ComponentThe 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:
getApplicationStartedOrderin interfaceComponent- Returns:
- the order, 1000 by default
-
publish
Description copied from interface:PubSubServicePublishes a message to the given topic.- Specified by:
publishin interfacePubSubService- Parameters:
topic- the topicmessage- the message
-
registerSubscriber
Description copied from interface:PubSubServiceRegisters 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:
registerSubscriberin interfacePubSubService- Parameters:
topic- the topicsubscriber- the subscriber, who will receive the topic and abyte[]message
-
unregisterSubscriber
Description copied from interface:PubSubServiceUnregisters a subscriber for the given topic.- Specified by:
unregisterSubscriberin interfacePubSubService- Parameters:
topic- the topicsubscriber- the subscriber
-