Salesforce vert.x integration
Collection of verticles that enable interaction with the Salesforce API.
Artifacts on Maven Central
Eclipse vert.x is a lightweight Java framework for micro services architectures. It features an event bus that allows polyglot vert.x modules (called Verticles) to communicate with each other. This allows building well scaling modules for API driven application.
There is extensive documentation available at the Eclipse vert.x project page.
Change Log
List of changes in reverse order
Sample application
A sample application including the corresponding Salesforce artifacts is available here
Overview
Detail pages
Available Verticles
- Authentication Verticles
- Subscription to platform events Verticles
- Send result to console Verticle
- Send result to websocket Verticle
- Main/Setup Verticle
- Deduplication Verticles (including Redis)
Write your own
How does it work
One or more listener Verticles connect to a Salesforce instance. This can be development, sandbox or production. The listeners will register for the configured events and publish incoming data to the vert.x eventbus. To gain access a listener requests Authorization from an Auth Verticle.
The listener might initially publish the incoming data to a Deduplication service, to filter out events that are considered duplicates. This allows restarting listeners, cluster listeners or recover from failover. The core package contains a sample in-memory deduplication verticle - in a production environment you want to use something storage backed like the Redis Dedup service.
Zero or more consumers listen to the eventbus and do with the incoming data what they have to do.
As sample a consumer that forwards the payload to a websocket and one that just prints to the console is provided.
The flow is supported by one or more Authentication verticles. The main one of type SoapApi retrieves the session information from Salesforce.
A second one “Basic” is provided to allow Verticles to retrieve basic Auth. e.g. for use in a JSON POST in a listener.
Finally the ApplicationStarter Verticle loads the configuration file “SFDCOptions.json” and all verticles described in it.
Eventbus
The SFDC verticles make heavy use of the eventbus.
After loading all configured verticles, the main verticle sends a start signal on the bus. The SFDC verticles can be configured to start listening only after the start signal has been sent. This allows to spin up the consumers before the listeners start taking incoming events.
The authentication verticles listen to the eventbus to provide the HTTP header and destination server for listener or consumer verticles. Listener or consumer verticles are shielded from the details of authentication/authorization
The listeners publish their received data onto the eventbus. They either use the configured destination address or the address of a deduplication service, which prevents identical events from being forwarded to consumers twice.
Last not least: the main verticle uses the eventbus to signal the verticles to stop listening. This allows to shutdown the listeners and let the bus drain from messages before shutting down.
Setup
Add this dependencies to your pom.xml
:
<dependency>
<groupId>net.wissel.salesforce</groupId>
<artifactId>vertx-sfdc-core</artifactId>
<version>0.3.3</version>
</dependency>
<!-- Optional for deduplication service if Redis is your choice -->
<dependency>
<groupId>net.wissel.salesforce</groupId>
<artifactId>vertx-sfdc-redis</artifactId>
<version>0.3.3</version>
</dependency>
Then configure the sfdcoptions.json
file
Start
Start the verticle net.wissel.salesforce.vertx.ApplicationStarter
to launch the configured listener and consumers
Feedback
I would love to hear about your implementation or ideas or challenges, so open an issue on GitHub - even for sharing success. Don’t be shy!