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 Details

    • XP_CONFIG

      public static final String XP_CONFIG
      See Also:
    • GLOBAL_PUBLISH_COUNTER

      public static final String GLOBAL_PUBLISH_COUNTER
    • provider

      protected PubSubProvider provider
      The currently-configured provider.
    • subscribers

      protected Map<String,List<BiConsumer<String,byte[]>>> subscribers
      List of subscribers for each topic.
    • options

      protected Map<String,String> options
    • globalPublishCount

      protected io.dropwizard.metrics5.Counter globalPublishCount
  • Constructor Details

    • PubSubServiceImpl

      public PubSubServiceImpl()
  • Method Details

    • deactivate

      public void deactivate(ComponentContext context)
      Description copied from interface: Component
      Deactivates the component.

      This method is called by the runtime when a component is deactivated.

      Specified by:
      deactivate in interface Component
      Overrides:
      deactivate in class DefaultComponent
      Parameters:
      context - the runtime context
    • start

      public void start(ComponentContext context)
      Description copied from interface: Component
      Start the component. This method is called after all the components were resolved and activated
      Specified by:
      start in interface Component
      Overrides:
      start in class DefaultComponent
    • stop

      public void stop(ComponentContext context) throws InterruptedException
      Description copied from interface: Component
      Stop the component.
      Specified by:
      stop in interface Component
      Overrides:
      stop in class DefaultComponent
      Throws:
      InterruptedException
    • getApplicationStartedOrder

      public int getApplicationStartedOrder()
      Description copied from interface: Component
      The component notification order for Component.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 interface Component
      Returns:
      the order, 1000 by default
    • publish

      public void publish(String topic, byte[] message)
      Description copied from interface: PubSubService
      Publishes a message to the given topic.
      Specified by:
      publish in interface PubSubService
      Parameters:
      topic - the topic
      message - the message
    • registerSubscriber

      public void registerSubscriber(String topic, BiConsumer<String,byte[]> subscriber)
      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 interface PubSubService
      Parameters:
      topic - the topic
      subscriber - the subscriber, who will receive the topic and a byte[] message
    • unregisterSubscriber

      public void unregisterSubscriber(String topic, BiConsumer<String,byte[]> subscriber)
      Description copied from interface: PubSubService
      Unregisters a subscriber for the given topic.
      Specified by:
      unregisterSubscriber in interface PubSubService
      Parameters:
      topic - the topic
      subscriber - the subscriber