Git Product home page Git Product logo

emp-connector's Introduction

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("[email protected]", "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.

emp-connector's People

Contributors

sfdc-hhildebrand avatar pbn-sfdc avatar mport avatar knobenheimer avatar sfdc-dxu avatar alintnersfdc avatar

Watchers

James Cloos avatar Damon Rousis avatar David Turet avatar Carnell Washington Jr avatar Matthew Leibowitz avatar Stuart VandenBrink avatar Colby Sites avatar Ashley Romualdo avatar

Forkers

knobenheimer

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.