Skip to content
This repository has been archived by the owner on May 17, 2021. It is now read-only.

A simplified cometd connector for Enterprise Messaging Platform

License

Notifications You must be signed in to change notification settings

local-ch/EMP-Connector

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

44 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

emp-connector example

A simplified connector example to the Enterprise Messaging Platform.

This example connector provides support for SSL, HTTP proxies and supports both the long polling and websocket streaming transports. Easy subscription management and full support for event replay is provided.


To use, add the maven dependency:

<dependency> 
    <groupId>com.salesforce.conduit</groupId>
    <artifactId>emp-connector</artifactId>
    <version>0.0.1-SNAPSHOT</version>
</dependency>

Disclaimer

Please note that this repository is example code and is not supported by Salesforce. This code has not been rigorously tested nor performance tested for throughput and scale.

This code is provided as an example only. The underlying CometD library is what provides the meat here, as the emp connector is a thin wrapper around this library.


Example usage:

// Replay from the start of the event window - may be any valid replayFrom position in the event stream
long replayFrom = EmpConnector.REPLAY_FROM_EARLIEST; 

// get parameters from login
BayeuxParameters params = login("foo@bar.com", "password");

// The event consumer
Consumer<Map<String, Object>> consumer = event -> System.out.println(String.format("Received:\n%s", event));

// The EMP connector
EmpConnector connector = new EmpConnector(params);

// Wait for handshake with Streaming API
connector.start().get(5, TimeUnit.SECONDS);

// Subscribe to a topic
// Block and wait for the subscription to succeed for 5 seconds
TopicSubscription subscription = connector.subscribe("/topic/myTopic", replayFrom, consumer).get(5, TimeUnit.SECONDS);

// Here's our subscription
System.out.println(String.format("Subscribed: %s", subscription));

// Cancel a subscription
subscription.cancel();

// Stop the connector
connector.stop();

See Login Example for full example.

About

A simplified cometd connector for Enterprise Messaging Platform

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Java 100.0%