Camel Quarkus

Salesforce

JVM since0.2.0 Native since0.0.2

Communicate with Salesforce using Java DTOs.

What’s inside

Please refer to the above link for usage and configuration details.

Maven coordinates

Or add the coordinates to your existing project:

<dependency>
    <groupId>org.apache.camel.quarkus</groupId>
    <artifactId>camel-quarkus-salesforce</artifactId>
</dependency>

Check the User guide for more information about writing Camel Quarkus applications.

Usage

Generating Salesforce DTOs with the salesforce-maven-plugin

To generate Salesforce DTOs for your project, use the salesforce-maven-plugin. The example code snippet below creates a single DTO for the Account object.

<plugin>
    <groupId>org.apache.camel.maven</groupId>
    <artifactId>camel-salesforce-maven-plugin</artifactId>
    <version>4.22.1</version>
    <executions>
        <execution>
            <goals>
                <goal>generate</goal>
            </goals>
            <configuration>
                <clientId>${env.SALESFORCE_CLIENTID}</clientId>
                <clientSecret>${env.SALESFORCE_CLIENTSECRET}</clientSecret>
                <userName>${env.SALESFORCE_USERNAME}</userName>
                <password>${env.SALESFORCE_PASSWORD}</password>
                <loginUrl>https://login.salesforce.com</loginUrl>
                <packageName>org.apache.camel.quarkus.component.salesforce.generated</packageName>
                <outputDirectory>src/main/java</outputDirectory>
                <includes>
                    <include>Account</include>
                </includes>
            </configuration>
        </execution>
    </executions>
</plugin>

Trusting classes used with the Pub / Sub API

The Pub / Sub API exchanges events encoded with Avro. Since Avro 1.12.2, classes that events are mapped to must be explicitly trusted, otherwise the event is rejected with:

java.lang.SecurityException: Forbidden org.foo.TestEvent! This class is not trusted to be included in Avro schemas.

Whether anything needs to be trusted depends on the pubSubDeserializeType of the subscribing endpoint.

pubSubDeserializeType Classes to trust

AVRO (default), SPECIFIC_RECORD

The Avro SpecificRecord classes in the com.sforce.eventbus package that events are mapped to. Classes annotated with @org.apache.avro.specific.AvroGenerated are trusted automatically, which covers classes generated by the Avro compiler. Only classes without that annotation, such as those written by hand, need to be trusted explicitly.

POJO

The class configured on the pubSubPojoClass option. This is always required, as it is a plain class that Avro maps to reflectively.

GENERIC_RECORD, JSON

None.

For example, given the following route.

from("salesforce:pubSubSubscribe:/event/TestEvent__e?pubSubDeserializeType=POJO&pubSubPojoClass=org.foo.TestEvent")
    .log("Received Salesforce POJO topic message: ${body}");

Class org.foo.TestEvent would need to be trusted in application.properties.

quarkus.avro.trusted-classes=org.foo.TestEvent

Alternatively, trust every class in a package and its sub-packages. List only the packages holding your own event classes.

quarkus.avro.trusted-packages=org.foo

Publishing with pubSubPublish does not require the message body class to be trusted. However, if an Avro SpecificRecord class exists for the topic in the com.sforce.eventbus package, then publishing a POJO body requires that class to be trusted in the same way as for subscribing.

Refer to the Avro extension documentation for more information.

Native mode support for Pub / Sub API with POJO pubSubDeserializeType

When using the Camel Salesforce Pub / Sub API and pubSubDeserializeType is configured as POJO, you must register any classes configured on the pubSubPojoClass option for reflection.

For example, given the following route.

from("salesforce:pubSubSubscribe:/event/TestEvent__e?pubSubDeserializeType=POJO&pubSubPojoClass=org.foo.TestEvent")
    .log("Received Salesforce POJO topic message: ${body}");

Class org.foo.TestEvent would need to be registered for reflection.

package org.foo;

import io.quarkus.runtime.annotations.RegisterForReflection;

@RegisterForReflection
public class TestEvent {
    // Getters / setters etc
}

Refer to the Native mode user guide for more information.

SSL in native mode

This extension auto-enables SSL support in native mode. Hence you do not need to add quarkus.ssl.native=true to your application.properties yourself. See also Quarkus SSL guide.