Class EmpConnector


  • public class EmpConnector
    extends Object
    Since:
    202
    Author:
    hal.hildebrand
    • Method Detail

      • start

        public Future<Boolean> start()
        Start the connector.
        Returns:
        true if connection was established, false otherwise
      • stop

        public void stop​(boolean terminateCompletely)
        Stop the connector.
        Parameters:
        terminateCompletely - indicates if this is a final shutdown (true) or a temporary stop (false).
      • stop

        public void stop()
        Stop the connector. This method is used to stop the connector without terminating the HTTP client.
      • setBearerTokenProvider

        public void setBearerTokenProvider​(Function<Boolean,​String> bearerTokenProvider)
        Set a bearer token / session id provider function that takes a boolean as input and returns a valid token. If the input is true, the provider function is supposed to re-authenticate with the Salesforce server and get a fresh session id or token.
        Parameters:
        bearerTokenProvider - a bearer token provider function.
      • subscribe

        public Future<TopicSubscription> subscribe​(String topic,
                                                   long replayFrom,
                                                   Consumer<Map<String,​Object>> consumer)
        Subscribe to a topic, receiving events after the replayFrom position
        Parameters:
        topic - - the topic to subscribe to
        replayFrom - - the replayFrom position in the event stream
        consumer - - the consumer of the events
        Returns:
        a Future returning the Subscription - on completion returns a Subscription or throws a CannotSubscribe exception
      • subscribeEarliest

        public Future<TopicSubscription> subscribeEarliest​(String topic,
                                                           Consumer<Map<String,​Object>> consumer)
        Subscribe to a topic, receiving events from the earliest event position in the stream
        Parameters:
        topic - - the topic to subscribe to
        consumer - - the consumer of the events
        Returns:
        a Future returning the Subscription - on completion returns a Subscription or throws a CannotSubscribe exception
      • subscribeTip

        public Future<TopicSubscription> subscribeTip​(String topic,
                                                      Consumer<Map<String,​Object>> consumer)
        Subscribe to a topic, receiving events from the latest event position in the stream
        Parameters:
        topic - - the topic to subscribe to
        consumer - - the consumer of the events
        Returns:
        a Future returning the Subscription - on completion returns a Subscription or throws a CannotSubscribe exception
      • addListener

        public EmpConnector addListener​(String channel,
                                        org.cometd.bayeux.client.ClientSessionChannel.MessageListener messageListener)
      • isConnected

        public boolean isConnected()
      • isDisconnected

        public boolean isDisconnected()
      • isHandshook

        public boolean isHandshook()
      • getLastReplayId

        public long getLastReplayId​(String topic)