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
public class PubSubServiceImpl extends DefaultComponent implements PubSubService
Implementation for the Publish/Subscribe Service.- Since:
- 9.1
-
-
Field Summary
Fields Modifier and Type Field Description protected Map<String,String>optionsprotected PubSubProviderproviderThe currently-configured provider.protected Map<String,List<BiConsumer<String,byte[]>>>subscribersList of subscribers for each topic.static StringXP_CONFIG-
Fields inherited from class org.nuxeo.runtime.model.DefaultComponent
lastModified, name
-
-
Constructor Summary
Constructors Constructor Description PubSubServiceImpl()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voiddeactivate(ComponentContext context)Deactivates the component.intgetApplicationStartedOrder()The component notification order forComponent.applicationStarted(org.nuxeo.runtime.model.ComponentContext).voidpublish(String topic, byte[] message)Publishes 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
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface org.nuxeo.runtime.model.Component
applicationStarted
-
-
-
-
Field Detail
-
XP_CONFIG
public static final String XP_CONFIG
- See Also:
- Constant Field Values
-
provider
protected PubSubProvider provider
The currently-configured provider.
-
subscribers
protected Map<String,List<BiConsumer<String,byte[]>>> subscribers
List of subscribers for each topic.
-
-
Constructor Detail
-
PubSubServiceImpl
public PubSubServiceImpl()
-
-
Method Detail
-
deactivate
public void deactivate(ComponentContext context)
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
public void start(ComponentContext context)
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
public void stop(ComponentContext context) throws InterruptedException
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.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.
- Specified by:
getApplicationStartedOrderin interfaceComponent- Returns:
- the order, 1000 by default
-
publish
public void publish(String topic, byte[] message)
Description copied from interface:PubSubServicePublishes a message to the given topic.- Specified by:
publishin interfacePubSubService- Parameters:
topic- the topicmessage- the message
-
registerSubscriber
public void registerSubscriber(String topic, BiConsumer<String,byte[]> subscriber)
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
public void unregisterSubscriber(String topic, BiConsumer<String,byte[]> subscriber)
Description copied from interface:PubSubServiceUnregisters a subscriber for the given topic.- Specified by:
unregisterSubscriberin interfacePubSubService- Parameters:
topic- the topicsubscriber- the subscriber
-
-