Class CTSNotificationBroker

  • All Implemented Interfaces:
    NotificationBroker

    public final class CTSNotificationBroker
    extends Object
    implements NotificationBroker
    Uses the CTS to propagate notifications across an OpenAM cluster.

    When publishing, notifications are written to the CTS. A continuous query listener ContinuousQueryListener responds to new notifications in the CTS and passes them on to interested subscribers.

    This implementation uses a local-server broker to handle the brokerage of messages that come in from the CTS.

    Since:
    14.0.0
    • Constructor Detail

      • CTSNotificationBroker

        @Inject
        public CTSNotificationBroker​(CTSPersistentStore store,
                                     @Named("localBroker")
                                     NotificationBroker localBroker,
                                     @Named("ctsQueueSize")
                                     int queueSize,
                                     @Named("tokenExpirySeconds")
                                     long tokenExpirySeconds,
                                     @Named("publishFrequencyMilliseconds")
                                     long publishFrequencyMilliseconds,
                                     AMExecutorServiceFactory executorServiceFactory)
        Constructs a new broker.
        Parameters:
        store - a CTS persistent store that notifications will be written to and read from
        localBroker - a local-server broker used to propagate messages to local subscribers
        queueSize - the size of the queue of notifications waiting to be written to the CTS
        tokenExpirySeconds - the number of seconds that a notification will live in the CTS before it is deleted
        publishFrequencyMilliseconds - the number of milliseconds between each publish to the CTS
        executorServiceFactory - an executor service factory for scheduling the publish task
    • Method Detail

      • publish

        public boolean publish​(Topic topic,
                               org.forgerock.json.JsonValue notification)
        Description copied from interface: NotificationBroker
        Publish passes the notification onto subscribers of the topic. If there are no subscribers to the same topic, the notification is discarded.

        Publishing notifications may fail and this is signalled by returning false.

        Specified by:
        publish in interface NotificationBroker
        Parameters:
        topic - topic
        notification - notification
        Returns:
        attempts to give some indication whether the topic was successfully published. False gives a guarantee that publication definitely failed.
      • subscribe

        public Subscription subscribe​(Consumer consumer)
        Description copied from interface: NotificationBroker
        Creates a new subscription that is initially not bound to any topics.

        The given consumer will be called for each notification that is published to any of the bound topics.

        Specified by:
        subscribe in interface NotificationBroker
        Parameters:
        consumer - a consumer that will be called once per published notification
        Returns:
        a new subscriber
      • shutdown

        public void shutdown()
        Description copied from interface: NotificationBroker
        Initiates an orderly shutdown in which previously published notifications are delivered, but no new notifications will be accepted. Invocation has no additional effect if already shut down.
        Specified by:
        shutdown in interface NotificationBroker