Ready to get started?


Download Now

Integrate with Salesforce Marketing Data using Apache Camel

Create a simple Java app that uses Apache Camel routing and the CData JDBC Driver to copy Salesforce Marketing data to a JSON file on disk.

Apache Camel is an open source integration framework that allows you to integrate various systems consuming or producing data. When paired with the CData JDBC Driver for Salesforce Marketing, you can write Java apps that use Camel routes that integrate with live Salesforce Marketing data. This article walks through creating an app in NetBeans that connects, queries, and routes Salesforce Marketing data to a JSON file.

With built-in optimized data processing, the CData JDBC Driver offers unmatched performance for interacting with live Salesforce Marketing data. When you issue complex SQL queries to Salesforce Marketing, the driver pushes supported SQL operations, like filters and aggregations, directly to Salesforce Marketing and utilizes the embedded SQL engine to process unsupported operations client-side (often SQL functions and JOIN operations). Its built-in dynamic metadata querying allows you to work with and analyze Salesforce Marketing data using native data types.

Creating A New Maven/Java Project


  1. Open NetBeans and create a new project.

Adding Project Dependencies

With the project created, we can start adding the dependencies needed to work with live Salesforce Marketing data from our App. If you have not already done so, intall Maven in your environment, as it is required to add the JAR file for the CData JDBC Driver to your project.

Installing the CData JDBC Driver for Salesforce Marketing with Maven

  1. Download the CData JDBC Driver for Salesforce Marketing installer, unzip the package, and run the JAR file to install the driver.
    mvn install:install-file 
    	-Dfile="C:\Program Files\CData\CData JDBC Driver for Salesforce Marketing 2019\lib\cdata.jdbc.sfmarketingcloud.jar" 


Required Dependencies

DependencyGroup IDArtifact IDVersion

Accessing Salesforce Marketing Data in Java Apps with Camel

After adding the required dependencies, we can use the Java DSL (Domain Specific Language) to create routes with access to live Salesforce Marketing data. Code snippets follow. Download the sample project (zip file) to follow along (make note of the TODO comments).

Start by importing the necessary classes into our main class.

import org.apache.camel.CamelContext;
import org.apache.camel.builder.RouteBuilder;
import org.apache.camel.impl.DefaultCamelContext;
import org.apache.camel.support.SimpleRegistry;
import org.apache.commons.dbcp2.BasicDataSource;
import org.apache.log4j.BasicConfigurator;

Then in the main method, we configure logging, create a new BasicDataSource and add it to the registry, create a new CamelContext, and finally add a route to the context. In this sample, we route Salesforce Marketing data to a JSON file.

Configure Logging


Create a BasicDataSource


Authenticating to the Salesforce Marketing Cloud APIs


Connecting to the Salesforce Marketing Cloud APIs



BasicDataSource basic = new BasicDataSource();


Built-in Connection String Designer


java -jar cdata.jdbc.sfmarketingcloud.jar


Add the BasicDataSource to the Registry and Create a CamelContext

SimpleRegistry reg = new SimpleRegistry();
reg.bind("myDataSource", basic);

CamelContext context = new DefaultCamelContext(reg);

Add Routing to the CamelContext


context.addRoutes(new RouteBuilder() {
	public void configure() {

Managing the CamelContext Lifecycle



Free Trial, Sample Project & Technical Support

Now, you have a working Java application that uses Camel to route data from Salesforce Marketing to a JSON file. Download a free, 30-day trial of the CData JDBC Driver for Salesforce Marketing and the sample project (make note of the TODO comments) and start working with your live Salesforce Marketing data in Apache Camel. Reach out to our Support Team if you have any questions.