Skip to content
Open
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
18 changes: 10 additions & 8 deletions rest-openapi/README.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -25,20 +25,22 @@ You should see the following output when the application is launched:
[source,text]
----
...
[INFO] --- spring-boot-maven-plugin:1.5.10.RELEASE:run (default-cli) @ camel-example-spring-boot-rest-openapi ---
[INFO] --- spring-boot:4.1.1:run (default-cli) @ camel-example-spring-boot-rest-openapi ---
[...]
. ____ _ __ _ _
/\\ / ___'_ __ _ _(_)_ __ __ _ \ \ \ \
( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \
\\/ ___)| |_)| | | | | || (_| | ) ) ) )
' |____| .__|_| |_|_| |_\__, | / / / /
=========|_|==============|___/=/_/_/_/
:: Spring Boot :: (v2.0.0.RELEASE)
[...]
2017-03-05 14:55:44.032 INFO 15312 --- [ main] o.a.camel.spring.SpringCamelContext : Total 4 routes, of which 4 are started.
2017-03-05 14:55:44.034 INFO 15312 --- [ main] o.a.camel.spring.SpringCamelContext : Apache Camel 2.22.0-SNAPSHOT (CamelContext: camel-1) started in 0.614 seconds
2017-03-05 14:55:44.131 INFO 15312 --- [ main] s.b.c.e.t.TomcatEmbeddedServletContainer : Tomcat started on port(s): 8080 (http)
2017-03-05 14:55:44.140 INFO 15312 --- [ main] o.a.c.example.springboot.Application : Started Application in 6.265 seconds (JVM running for 21.092)

:: Spring Boot :: (v4.1.1)

2026-09-04T10:13:59.681+02:00 INFO 26229 --- [ main] o.s.boot.tomcat.TomcatWebServer : Tomcat started on port 8080 (http) with context path '/'
2026-09-04T10:13:59.872+02:00 INFO 26229 --- [ main] o.a.c.impl.engine.AbstractCamelContext : Apache Camel 4.23.0-SNAPSHOT (MyCamel) is starting
2026-09-04T10:13:59.913+02:00 INFO 26229 --- [ main] o.a.c.impl.engine.AbstractCamelContext : Routes startup (total:4 rest-dsl:4)
2026-09-04T10:13:59.913+02:00 INFO 26229 --- [ main] o.a.c.impl.engine.AbstractCamelContext : Apache Camel 4.23.0-SNAPSHOT (MyCamel) started in 41ms (build:0ms init:0ms start:41ms boot:586ms)
2026-09-04T10:13:59.915+02:00 INFO 26229 --- [ main] o.a.c.example.springboot.Application : Started Application in 1.476 seconds (process running for 1.63)
----

After the Spring Boot application is started, you can open the following URL in your web browser to access the REST endpoint and retrieve a list of users: http://localhost:8080/api/users
Expand Down Expand Up @@ -77,7 +79,7 @@ The Spring Boot application can be stopped pressing `[CTRL] + [C]` in the shell.

=== Actuator

The actuator is available at: `http://localhost:8080/actuator/` such as metrics for Prometheus: `http://localhost:8080/actuator/prometheus`.
The actuator is available at: `http://localhost:8080/actuator` such as metrics for Prometheus: `http://localhost:8080/actuator/prometheus`.

=== Help and contributions

Expand Down
38 changes: 28 additions & 10 deletions twitter-salesforce/README.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -8,20 +8,26 @@ as a contact in Salesforce.

=== Configuring Twitter

This example is already configured using a testing purpose twitter
account named `cameltweet'. And therefore the example is ready to run
out of the box.
This example ships with the keys and tokens of a long-standing testing
Twitter/X account named `cameltweet`, used only to let the example show
a complete, working configuration; they are not a working credential you
can rely on. They predate Twitter/X's 2023 API overhaul and are very
likely no longer valid, and even if they were, they are for a shared
testing account, not something to build on.

This account is only for testing purpose, and should not be used in your
custom applications. For that you need to setup and use your own twitter
account.
You must self-provision your own Twitter/X developer app and use its
consumer key/secret and access token/secret in place of the values in
`+application.properties+` before this example will actually run.

=== Configuring Salesforce

This example uses Camels own test Salesforce developer account, you
would most likely want to sign up with your own Developer account at
https://developer.salesforce.com/. After you have done that, you’ll need
to create a Connected Application for your integration.
This example ships with `+clientId+`/`+clientSecret+` values for a Camel
test Salesforce developer account, included only to show what a filled-in
configuration looks like. As with the Twitter/X keys above, self-provision
your own Salesforce Developer account at
https://developer.salesforce.com/ for anything beyond reading this
example, and follow the steps below to create your own Connected
Application for your integration.

To do this after logging in to your Salesforce Developer account,
navigate to _Apps_ located under _Build_ and then _Create_, there you
Expand Down Expand Up @@ -89,6 +95,18 @@ to use the `+camel-salesforce-maven-plugin+` and specify the desired DTO in <con
To generate only DTOs needed for Contact, but the parameter value can be
specified using regular expressions.

Running that plugin needs a live login against a real org, so it only
runs under the `+generate-salesforce-dto+` profile (`+-Dgenerate.dto+`),
never during a plain `+mvn compile+`. This example itself only sets
`+LastName+` and `+TwitterScreenName__c+`, so it doesn't need a
generated DTO - it uses the minimal, hand-maintained
`+org.apache.camel.example.mention.dto.Contact+` bundled with the
example, which is enough to compile and run without any Salesforce
credentials at build time. The plugin and profile are kept around as a
starting point if you want to extend the route to read or write
additional fields on `+Contact+` (or other SObjects) - generate a DTO
for them and use it in place of the bundled one.

=== Build

You will need to compile this example first:
Expand Down
1 change: 1 addition & 0 deletions twitter-salesforce/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,7 @@
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>build-helper-maven-plugin</artifactId>
<version>3.0.0</version>
<executions>
<execution>
<id>add-source</id>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,8 @@
*/
package org.apache.camel.example.mention;

import java.lang.Class;
import java.lang.reflect.Method;
import org.apache.camel.salesforce.draftdto.Contact;
import org.apache.camel.builder.RouteBuilder;
import org.apache.camel.example.mention.dto.Contact;
import org.springframework.stereotype.Component;
import twitter4j.v1.Status;
import twitter4j.v1.User;
Expand All @@ -34,22 +32,11 @@ public void configure() throws Exception {
.process(exchange -> {
Status status = exchange.getIn().getBody(Status.class);
User user = status.getUser();
String name = user.getName();
String screenName = user.getScreenName();
Class contact = null;
if (Class.forName("org.apache.camel.salesforce.dto.Contact") != null) {
contact = Class.forName("org.apache.camel.salesforce.dto.Contact");
} else {
contact = Contact.class;
}

Object contactObject = contact.getDeclaredConstructor().newInstance();
Method setLastName = contact.getMethod("setLastName", String.class);
Method setTwitterScreenName__c = contact.getMethod("setTwitterScreenName__c", String.class);
setLastName.invoke(contactObject, name);
setTwitterScreenName__c.invoke(contactObject, screenName);
exchange.getIn().setBody(contactObject);

Contact contact = new Contact();
contact.setLastName(user.getName());
contact.setTwitterScreenName__c(user.getScreenName());
exchange.getIn().setBody(contact);
})
.to("salesforce:upsertSObject?sObjectIdName=TwitterScreenName__c")
.log("SObject ID: ${body?.id}");
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.apache.camel.example.mention.dto;

import com.fasterxml.jackson.annotation.JsonProperty;
import org.apache.camel.component.salesforce.api.dto.AbstractSObjectBase;

/**
* Minimal, hand-maintained stand-in for the Salesforce {@code Contact} DTO that
* {@code camel-salesforce-maven-plugin} would otherwise generate from a live org (see the
* {@code generate-salesforce-dto} Maven profile). It only carries the fields this example
* actually sets, so the module builds and runs without needing Salesforce credentials at
* build time.
*/
public class Contact extends AbstractSObjectBase {

private String lastName;
private String twitterScreenNameC;

public Contact() {
getAttributes().setType("Contact");
}

// Salesforce field API names are case-sensitive (LastName, TwitterScreenName__c); without
// @JsonProperty, Jackson would decapitalize the leading letter of the bean-derived property
// name and silently send the wrong field names to the Salesforce REST API.
@JsonProperty("LastName")
public String getLastName() {
return lastName;
}

@JsonProperty("LastName")
public void setLastName(String lastName) {
this.lastName = lastName;
}

@JsonProperty("TwitterScreenName__c")
public String getTwitterScreenName__c() {
return twitterScreenNameC;
}

@JsonProperty("TwitterScreenName__c")
public void setTwitterScreenName__c(String twitterScreenNameC) {
this.twitterScreenNameC = twitterScreenNameC;
}

}

This file was deleted.

Loading