Class EmpConnector
- java.lang.Object
-
- org.wso2.carbon.inbound.salesforce.poll.EmpConnector
-
public class EmpConnector extends Object
- Since:
- 202
- Author:
- hal.hildebrand
-
-
Constructor Summary
Constructors Constructor Description EmpConnector(BayeuxParameters parameters, ConnectionFailureListener listener)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description EmpConnectoraddListener(String channel, org.cometd.bayeux.client.ClientSessionChannel.MessageListener messageListener)longgetLastReplayId(String topic)booleanisConnected()booleanisDisconnected()booleanisHandshook()voidsetBearerTokenProvider(Function<Boolean,String> bearerTokenProvider)Set a bearer token / session id provider function that takes a boolean as input and returns a valid token.Future<Boolean>start()Start the connector.voidstop()Stop the connector.voidstop(boolean terminateCompletely)Stop the connector.Future<TopicSubscription>subscribe(String topic, long replayFrom, Consumer<Map<String,Object>> consumer)Subscribe to a topic, receiving events after the replayFrom positionFuture<TopicSubscription>subscribeEarliest(String topic, Consumer<Map<String,Object>> consumer)Subscribe to a topic, receiving events from the earliest event position in the streamFuture<TopicSubscription>subscribeTip(String topic, Consumer<Map<String,Object>> consumer)Subscribe to a topic, receiving events from the latest event position in the stream
-
-
-
Constructor Detail
-
EmpConnector
public EmpConnector(BayeuxParameters parameters, ConnectionFailureListener listener)
-
-
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 toreplayFrom- - the replayFrom position in the event streamconsumer- - 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 toconsumer- - 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 toconsumer- - 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)
-
-