public class PubSubServiceImpl extends DefaultComponent implements PubSubService
Modifier and Type | Field and Description |
---|---|
protected Map<String,String> |
options |
protected PubSubProvider |
provider
The currently-configured provider.
|
protected Map<String,List<BiConsumer<String,byte[]>>> |
subscribers
List of subscribers for each topic.
|
static String |
XP_CONFIG |
lastModified, name
Constructor and Description |
---|
PubSubServiceImpl() |
Modifier and Type | Method and Description |
---|---|
void |
deactivate(ComponentContext context)
Deactivates the component.
|
int |
getApplicationStartedOrder()
The component notification order for
Component.applicationStarted(org.nuxeo.runtime.model.ComponentContext) . |
void |
publish(String topic,
byte[] message)
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.
|
activate, getAdapter, getDescriptor, getDescriptors, getLastModified, getRegistry, register, registerContribution, registerExtension, setLastModified, setModifiedNow, setName, unregister, unregisterContribution, unregisterExtension
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
applicationStarted
public static final String XP_CONFIG
protected PubSubProvider provider
protected Map<String,List<BiConsumer<String,byte[]>>> subscribers
public PubSubServiceImpl()
public void deactivate(ComponentContext context)
Component
This method is called by the runtime when a component is deactivated.
deactivate
in interface Component
deactivate
in class DefaultComponent
context
- the runtime contextpublic void start(ComponentContext context)
Component
start
in interface Component
start
in class DefaultComponent
public void stop(ComponentContext context) throws InterruptedException
Component
stop
in interface Component
stop
in class DefaultComponent
InterruptedException
public int getApplicationStartedOrder()
Component
Component.applicationStarted(org.nuxeo.runtime.model.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.
getApplicationStartedOrder
in interface Component
public void publish(String topic, byte[] message)
PubSubService
publish
in interface PubSubService
topic
- the topicmessage
- the messagepublic void registerSubscriber(String topic, BiConsumer<String,byte[]> subscriber)
PubSubService
The subscriber must deal with the message without delay and return immediately, usually by storing it in a thread-safe datastructure.
registerSubscriber
in interface PubSubService
topic
- the topicsubscriber
- the subscriber, who will receive the topic and a byte[]
messagepublic void unregisterSubscriber(String topic, BiConsumer<String,byte[]> subscriber)
PubSubService
unregisterSubscriber
in interface PubSubService
topic
- the topicsubscriber
- the subscriberCopyright © 2019 Nuxeo. All rights reserved.