Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for Salesforce pub / sub API #5503

Merged
merged 1 commit into from
Nov 13, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 29 additions & 0 deletions docs/modules/ROOT/pages/reference/extensions/salesforce.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,35 @@ To generate Salesforce DTOs for your project, use the `salesforce-maven-plugin`.
</plugin>
----

[id="extensions-salesforce-usage-native-mode-support-for-pub-sub-api-with-pojo-pubsubdeserializetype"]
=== 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.

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

aldettinger marked this conversation as resolved.
Show resolved Hide resolved
Class `org.foo.TestEvent` would need to be registered for reflection.

[source,java]
----
package org.foo;

import io.quarkus.runtime.annotations.RegisterForReflection;

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

Refer to the xref:user-guide/native-mode.adoc#reflection[Native mode] user guide for more information.


[id="extensions-salesforce-ssl-in-native-mode"]
== SSL in native mode
Expand Down
45 changes: 40 additions & 5 deletions extensions/salesforce/deployment/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,46 @@
<groupId>io.quarkus</groupId>
<artifactId>quarkus-jaxb-deployment</artifactId>
</dependency>
<dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-grpc-common</artifactId>
<exclusions>
<exclusion>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-vertx</artifactId>
</exclusion>
<exclusion>
<groupId>io.vertx</groupId>
<artifactId>vertx-grpc</artifactId>
</exclusion>
<exclusion>
<groupId>io.vertx</groupId>
<artifactId>vertx-grpc-client</artifactId>
</exclusion>
<exclusion>
<groupId>io.vertx</groupId>
<artifactId>vertx-grpc-server</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-grpc-common-deployment</artifactId>
<exclusions>
<exclusion>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-vertx-deployment</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-netty-deployment</artifactId>
</dependency>
<dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-avro-deployment</artifactId>
</dependency>
<dependency>
<groupId>org.apache.camel.quarkus</groupId>
<artifactId>camel-quarkus-core-deployment</artifactId>
Expand All @@ -49,11 +89,6 @@
<groupId>org.apache.camel.quarkus</groupId>
<artifactId>camel-quarkus-salesforce</artifactId>
</dependency>
<!-- Required for the native build of the simple app with this extension only -->
<dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-netty-deployment</artifactId>
</dependency>
</dependencies>

<build>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,9 @@
*/
package org.apache.camel.quarkus.component.salesforce.deployment;

import java.util.Set;
import java.util.stream.Collectors;

import io.quarkus.deployment.annotations.BuildProducer;
import io.quarkus.deployment.annotations.BuildStep;
import io.quarkus.deployment.builditem.CombinedIndexBuildItem;
Expand All @@ -31,6 +34,7 @@
class SalesforceProcessor {

private static final String SALESFORCE_DTO_PACKAGE = "org.apache.camel.component.salesforce.api.dto";
private static final String SALESFORCE_EVENTBUS_PACKAGE = "com.sforce.eventbus";
private static final String SALESFORCE_INTERNAL_DTO_PACKAGE = "org.apache.camel.component.salesforce.internal.dto";
private static final String FEATURE = "camel-salesforce";

Expand Down Expand Up @@ -79,4 +83,14 @@ void registerForReflection(
// Ensure package scanning for user DTO classes can work in native mode
packageScanClass.produce(new CamelPackageScanClassBuildItem(userDtoClasses));
}

@BuildStep
CamelPackageScanClassBuildItem registerEventBusPackageScanClasses(CombinedIndexBuildItem combinedIndexBuildItem) {
Set<String> eventBusDTOClasses = combinedIndexBuildItem.getIndex()
.getClassesInPackage(SALESFORCE_EVENTBUS_PACKAGE)
.stream()
.map(classInfo -> classInfo.name().toString())
.collect(Collectors.toUnmodifiableSet());
return new CamelPackageScanClassBuildItem(eventBusDTOClasses);
}
}
47 changes: 47 additions & 0 deletions extensions/salesforce/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -36,4 +36,51 @@
<module>runtime</module>
</modules>

<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-enforcer-plugin</artifactId>
<dependencies>
<dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-enforcer-rules</artifactId>
<version>${quarkus.version}</version>
</dependency>
<dependency>
<groupId>org.l2x6.cq</groupId>
<artifactId>cq-filtered-external-enforcer-rules</artifactId>
<version>${cq-plugin.version}</version>
</dependency>
</dependencies>
<executions>
<execution>
<id>camel-quarkus-enforcer-rules</id>
<goals>
<goal>enforce</goal>
</goals>
<configuration>
<rules>
<dependencyConvergence />
<filteredExternalRules>
<location>classpath:enforcer-rules/quarkus-require-maven-version.xml</location>
</filteredExternalRules>
<filteredExternalRules>
<location>classpath:enforcer-rules/quarkus-banned-dependencies.xml</location>
<xsltLocation>${maven.multiModuleProjectDirectory}/tooling/enforcer-rules/quarkus-banned-dependencies.xsl</xsltLocation>
</filteredExternalRules>
<filteredExternalRules>
<location>${maven.multiModuleProjectDirectory}/tooling/enforcer-rules/camel-quarkus-banned-dependencies.xml</location>
<xsltLocation>${maven.multiModuleProjectDirectory}/tooling/enforcer-rules/allow-findbugs.xsl</xsltLocation>
</filteredExternalRules>
<filteredExternalRules>
<location>${maven.multiModuleProjectDirectory}/tooling/enforcer-rules/camel-quarkus-banned-dependencies-spring.xml</location>
</filteredExternalRules>
</rules>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>
36 changes: 31 additions & 5 deletions extensions/salesforce/runtime/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,37 @@
<groupId>io.quarkus</groupId>
<artifactId>quarkus-jaxb</artifactId>
</dependency>
<dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-grpc-common</artifactId>
<exclusions>
<exclusion>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-vertx</artifactId>
</exclusion>
<exclusion>
<groupId>io.vertx</groupId>
<artifactId>vertx-grpc</artifactId>
</exclusion>
<exclusion>
<groupId>io.vertx</groupId>
<artifactId>vertx-grpc-client</artifactId>
</exclusion>
<exclusion>
<groupId>io.vertx</groupId>
<artifactId>vertx-grpc-server</artifactId>
</exclusion>
</exclusions>
</dependency>

<dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-netty</artifactId>
</dependency>
<dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-avro</artifactId>
</dependency>
<dependency>
<groupId>org.apache.camel.quarkus</groupId>
<artifactId>camel-quarkus-core</artifactId>
Expand All @@ -54,11 +85,6 @@
<groupId>org.apache.camel</groupId>
<artifactId>camel-salesforce</artifactId>
</dependency>
<!-- Required for the native build of the simple app with this extension only -->
<dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-netty</artifactId>
</dependency>
</dependencies>

<build>
Expand Down
28 changes: 28 additions & 0 deletions extensions/salesforce/runtime/src/main/doc/usage.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -33,3 +33,31 @@ To generate Salesforce DTOs for your project, use the `salesforce-maven-plugin`.
</executions>
</plugin>
----

=== 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.

[source,java]
----
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.

[source,java]
----
package org.foo;

import io.quarkus.runtime.annotations.RegisterForReflection;

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

Refer to the xref:user-guide/native-mode.adoc#reflection[Native mode] user guide for more information.
89 changes: 82 additions & 7 deletions integration-tests/salesforce/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,10 @@
<groupId>org.apache.camel.quarkus</groupId>
<artifactId>camel-quarkus-salesforce</artifactId>
</dependency>
<dependency>
<groupId>org.apache.camel.quarkus</groupId>
<artifactId>camel-quarkus-direct</artifactId>
</dependency>
<dependency>
<groupId>org.apache.camel.quarkus</groupId>
<artifactId>camel-quarkus-seda</artifactId>
Expand Down Expand Up @@ -73,6 +77,53 @@
</dependency>
</dependencies>

<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-enforcer-plugin</artifactId>
<dependencies>
<dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-enforcer-rules</artifactId>
<version>${quarkus.version}</version>
</dependency>
<dependency>
<groupId>org.l2x6.cq</groupId>
<artifactId>cq-filtered-external-enforcer-rules</artifactId>
<version>${cq-plugin.version}</version>
</dependency>
</dependencies>
<executions>
<execution>
<id>camel-quarkus-enforcer-rules</id>
<goals>
<goal>enforce</goal>
</goals>
<configuration>
<rules>
<dependencyConvergence />
<filteredExternalRules>
<location>classpath:enforcer-rules/quarkus-require-maven-version.xml</location>
</filteredExternalRules>
<filteredExternalRules>
<location>classpath:enforcer-rules/quarkus-banned-dependencies.xml</location>
<xsltLocation>${maven.multiModuleProjectDirectory}/tooling/enforcer-rules/quarkus-banned-dependencies.xsl</xsltLocation>
</filteredExternalRules>
<filteredExternalRules>
<location>${maven.multiModuleProjectDirectory}/tooling/enforcer-rules/camel-quarkus-banned-dependencies.xml</location>
<xsltLocation>${maven.multiModuleProjectDirectory}/tooling/enforcer-rules/allow-findbugs.xsl</xsltLocation>
</filteredExternalRules>
<filteredExternalRules>
<location>${maven.multiModuleProjectDirectory}/tooling/enforcer-rules/camel-quarkus-banned-dependencies-spring.xml</location>
</filteredExternalRules>
</rules>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>

<profiles>
<profile>
Expand Down Expand Up @@ -109,24 +160,37 @@
<plugin>
<groupId>org.apache.camel.maven</groupId>
<artifactId>camel-salesforce-maven-plugin</artifactId>
<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>
</configuration>
<executions>
<execution>
<id>generate-dto-classes</id>
<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>
<execution>
<id>generate-event-bus-classes</id>
<goals>
<goal>generatePubSub</goal>
</goals>
<configuration>
<topics>/event/TestEvent__e</topics>
<outputDirectory>src/main/java</outputDirectory>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
Expand All @@ -141,7 +205,19 @@
</activation>
<dependencies>
<!-- The following dependencies guarantee that this module is built after them. You can update them by running `mvn process-resources -Pformat -N` from the source tree root directory -->

<dependency>
<groupId>org.apache.camel.quarkus</groupId>
<artifactId>camel-quarkus-direct-deployment</artifactId>
<version>${project.version}</version>
<type>pom</type>
<scope>test</scope>
<exclusions>
<exclusion>
<groupId>*</groupId>
<artifactId>*</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.apache.camel.quarkus</groupId>
<artifactId>camel-quarkus-salesforce-deployment</artifactId>
Expand All @@ -155,7 +231,6 @@
</exclusion>
</exclusions>
</dependency>

<dependency>
<groupId>org.apache.camel.quarkus</groupId>
<artifactId>camel-quarkus-seda-deployment</artifactId>
Expand Down
Loading