wesleysee/EMP-Connector


A simplified cometd connector for Enterprise Messaging Platform

Download


Step 1. Add the JitPack repository to your build file

Add it in your root settings.gradle at the end of repositories:

	dependencyResolutionManagement {
		repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)
		repositories {
			mavenCentral()
			maven { url 'https://jitpack.io' }
		}
	}

Add it in your settings.gradle.kts at the end of repositories:

	dependencyResolutionManagement {
		repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)
		repositories {
			mavenCentral()
			maven { url = uri("https://jitpack.io") }
		}
	}

Add to pom.xml

	<repositories>
		<repository>
		    <id>jitpack.io</id>
		    <url>https://jitpack.io</url>
		</repository>
	</repositories>

Add it in your build.sbt at the end of resolvers:

 
    resolvers += "jitpack" at "https://jitpack.io"
        
    

Add it in your project.clj at the end of repositories:

 
    :repositories [["jitpack" "https://jitpack.io"]]
        
    

Step 2. Add the dependency

	dependencies {
		implementation 'com.github.wesleysee:EMP-Connector:'
	}
	dependencies {
		implementation("com.github.wesleysee:EMP-Connector:")
	}
	<dependency>
	    <groupId>com.github.wesleysee</groupId>
	    <artifactId>EMP-Connector</artifactId>
	    <version></version>
	</dependency>

                            
    libraryDependencies += "com.github.wesleysee" % "EMP-Connector" % ""
        
        

                            
    :dependencies [[com.github.wesleysee/EMP-Connector ""]]
        
        

Readme


emp-connector

A simplified connector to the Enterprise Messaging Platform.

This 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>

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.