You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by da...@apache.org on 2022/03/24 06:05:54 UTC
[camel-examples] branch main updated: CAMEL-17575: Update `Main` examples entry to use package scanning (#85)
This is an automated email from the ASF dual-hosted git repository.
davsclaus pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/camel-examples.git
The following commit(s) were added to refs/heads/main by this push:
new 7b8a332 CAMEL-17575: Update `Main` examples entry to use package scanning (#85)
7b8a332 is described below
commit 7b8a332d74140c8483dd5148d8440fd5c6d8cd6d
Author: Marouane Trabelsi <ma...@gmail.com>
AuthorDate: Thu Mar 24 07:05:47 2022 +0100
CAMEL-17575: Update `Main` examples entry to use package scanning (#85)
* CAMEL-17575: Update `Main` examples entry to use package scanning
- Updated all (straightforward `MyApplication` + `MyRouteBuilder`)
examples to use base package scanning
- Updated examples `application.properties` to link documentation
- Externalized configuration for `artemis` and `widget-gadget-java`
examples
- Split producer and consumer routes for `debezium-eventhubs-blob`
example
- Split `search` and `savedsearch` routes for `splunk` example
- Added annotation-based configuration for `netty-custom-correlation`
example
Refs CAMEL-17575
* CAMEL-17575: Add Licence to new source files
---
...{ArtemisMain.java => ArtemisConfiguration.java} | 34 ++-----
.../apache/camel/example/artemis/ArtemisMain.java | 25 +----
.../apache/camel/example/artemis/ArtemisTest.java | 13 +--
.../org/apache/camel/example/MyApplication.java | 4 +-
.../src/main/resources/application.properties | 4 +-
.../org/apache/camel/example/MyApplication.java | 4 +-
.../src/main/resources/application.properties | 4 +-
.../org/apache/camel/example/MyApplication.java | 4 +-
.../src/main/resources/application.properties | 4 +-
.../org/apache/camel/example/MyApplication.java | 4 +-
.../src/main/resources/application.properties | 4 +-
.../org/apache/camel/example/MyApplication.java | 4 +-
.../src/main/resources/application.properties | 4 +-
.../org/apache/camel/example/MyApplication.java | 4 +-
.../src/main/resources/application.properties | 4 +-
.../org/apache/camel/example/MyApplication.java | 4 +-
.../src/main/resources/application.properties | 4 +-
.../org/apache/camel/example/MyApplication.java | 4 +-
.../src/main/resources/application.properties | 4 +-
.../org/apache/camel/example/MyApplication.java | 4 +-
.../src/main/resources/application.properties | 4 +-
.../org/apache/camel/example/MyApplication.java | 4 +-
.../src/main/resources/application.properties | 4 +-
.../camel/example/console/CamelConsoleMain.java | 4 +-
.../org/apache/camel/example/MyApplication.java | 4 +-
.../src/main/resources/application.properties | 4 +-
.../org/apache/camel/example/MyApplication.java | 4 +-
.../src/main/resources/application.properties | 4 +-
.../org/apache/camel/example/MyApplication.java | 4 +-
.../src/main/resources/application.properties | 4 +-
.../org/apache/camel/example/cxf/proxy/MyMain.java | 3 +-
examples/cxf-tomcat/pom.xml | 1 +
examples/debezium-eventhubs-blob/pom.xml | 4 +-
.../blob/AzureEventHubsProducerToAzureBlob.java | 60 ------------
.../DebeziumMySqlConsumerToAzureEventHubs.java | 105 ---------------------
.../DebeziumMySqlConsumerToAzureEventHubs.java} | 18 ++--
...mMySqlConsumerToAzureEventHubsRouteBuilder.java | 81 ++++++++++++++++
.../AzureEventHubsProducerToAzureBlob.java} | 18 ++--
...eEventHubsProducerToAzureBlobRouteBuilder.java} | 26 ++---
.../org/apache/camel/example/MyApplication.java | 4 +-
.../src/main/resources/application.properties | 4 +-
.../apache/camel/example/FlightRecorderTest.java | 4 +-
.../org/apache/camel/example/ftp/MyFtpClient.java | 3 +-
.../org/apache/camel/example/ftp/MyFtpServer.java | 3 +-
.../apache/camel/example/java8/MyApplication.java | 4 +-
.../org/apache/camel/loanbroker/LoanBroker.java | 5 +-
.../org/apache/camel/example/MyApplication.java | 7 +-
.../org/apache/camel/example/MyConfiguration.java | 9 +-
.../src/main/resources/application.properties | 4 +-
.../org/apache/camel/example/MyApplication.java | 4 +-
.../src/main/resources/application.properties | 4 +-
.../org/apache/camel/example/MyApplication.java | 4 +-
.../src/main/resources/application.properties | 4 +-
.../org/apache/camel/example/MyApplication.java | 4 +-
.../src/main/resources/application.properties | 4 +-
.../org/apache/camel/example/MyApplication.java | 4 +-
.../src/main/resources/application.properties | 4 +-
.../org/apache/camel/example/MyApplication.java | 5 +-
.../org/apache/camel/example/MyConfiguration.java | 2 +
.../src/main/resources/application.properties | 4 +-
.../org/apache/camel/example/netty/MyClient.java | 32 +++++--
.../org/apache/camel/example/netty/MyServer.java | 25 ++++-
.../org/apache/camel/example/MyApplication.java | 33 +++++--
.../src/main/resources/application.properties | 5 +-
examples/splunk/pom.xml | 6 +-
.../splunk/{ => publish}/SplunkEventProcessor.java | 2 +-
.../{ => publish}/SplunkPublishEventClient.java | 2 +-
.../SplunkPublishEventRouteBuilder.java | 2 +-
.../{ => savedsearch}/SplunkSavedSearchClient.java | 5 +-
.../SplunkSavedSearchRouteBuilder.java | 2 +-
.../splunk/{ => search}/SplunkSearchClient.java | 5 +-
.../{ => search}/SplunkSearchRouteBuilder.java | 2 +-
.../websocket/CamelTwitterWebSocketMain.java | 5 +-
.../{WidgetMain.java => WidgetConfiguration.java} | 37 ++------
.../apache/camel/example/widget/WidgetMain.java | 31 +-----
75 files changed, 297 insertions(+), 483 deletions(-)
diff --git a/examples/artemis/src/main/java/org/apache/camel/example/artemis/ArtemisMain.java b/examples/artemis/src/main/java/org/apache/camel/example/artemis/ArtemisConfiguration.java
similarity index 61%
copy from examples/artemis/src/main/java/org/apache/camel/example/artemis/ArtemisMain.java
copy to examples/artemis/src/main/java/org/apache/camel/example/artemis/ArtemisConfiguration.java
index b3ee7e2..aa85e90 100644
--- a/examples/artemis/src/main/java/org/apache/camel/example/artemis/ArtemisMain.java
+++ b/examples/artemis/src/main/java/org/apache/camel/example/artemis/ArtemisConfiguration.java
@@ -17,37 +17,16 @@
package org.apache.camel.example.artemis;
import org.apache.activemq.artemis.jms.client.ActiveMQConnectionFactory;
+import org.apache.camel.BindToRegistry;
+import org.apache.camel.Configuration;
import org.apache.camel.component.jms.JmsComponent;
import org.apache.camel.component.jms.JmsConfiguration;
-import org.apache.camel.main.Main;
-/**
- * A plain Java Main to start the widget and gadget example using Apache Artemis.
- */
-public final class ArtemisMain {
-
- // use Camel Main to setup and run Camel
- private static Main main = new Main();
-
- private ArtemisMain() {
- // to comply with checkstyle
- }
-
- public static void main(String[] args) throws Exception {
- // create the ActiveMQ Artemis component
- main.bind("jms", createArtemisComponent());
+@Configuration
+public class ArtemisConfiguration {
- // add the widget/gadget route
- main.configure().addRoutesBuilder(new WidgetGadgetRoute());
-
- // add a 2nd route that routes files from src/data to the order queue
- main.configure().addRoutesBuilder(new CreateOrderRoute());
-
- // start and run Camel (block)
- main.run();
- }
-
- static JmsComponent createArtemisComponent() {
+ @BindToRegistry("jms")
+ public JmsComponent createArtemisComponent() {
// Sets up the Artemis core protocol connection factory
ActiveMQConnectionFactory connectionFactory = new ActiveMQConnectionFactory("tcp://localhost:61616");
@@ -56,5 +35,4 @@ public final class ArtemisMain {
return new JmsComponent(configuration);
}
-
}
diff --git a/examples/artemis/src/main/java/org/apache/camel/example/artemis/ArtemisMain.java b/examples/artemis/src/main/java/org/apache/camel/example/artemis/ArtemisMain.java
index b3ee7e2..ddf18a3 100644
--- a/examples/artemis/src/main/java/org/apache/camel/example/artemis/ArtemisMain.java
+++ b/examples/artemis/src/main/java/org/apache/camel/example/artemis/ArtemisMain.java
@@ -17,6 +17,7 @@
package org.apache.camel.example.artemis;
import org.apache.activemq.artemis.jms.client.ActiveMQConnectionFactory;
+import org.apache.camel.BindToRegistry;
import org.apache.camel.component.jms.JmsComponent;
import org.apache.camel.component.jms.JmsConfiguration;
import org.apache.camel.main.Main;
@@ -26,35 +27,15 @@ import org.apache.camel.main.Main;
*/
public final class ArtemisMain {
- // use Camel Main to setup and run Camel
- private static Main main = new Main();
-
private ArtemisMain() {
// to comply with checkstyle
}
public static void main(String[] args) throws Exception {
- // create the ActiveMQ Artemis component
- main.bind("jms", createArtemisComponent());
-
- // add the widget/gadget route
- main.configure().addRoutesBuilder(new WidgetGadgetRoute());
-
- // add a 2nd route that routes files from src/data to the order queue
- main.configure().addRoutesBuilder(new CreateOrderRoute());
-
+ // use Camels Main class
+ Main main = new Main(ArtemisMain.class);
// start and run Camel (block)
main.run();
}
- static JmsComponent createArtemisComponent() {
- // Sets up the Artemis core protocol connection factory
- ActiveMQConnectionFactory connectionFactory = new ActiveMQConnectionFactory("tcp://localhost:61616");
-
- JmsConfiguration configuration = new JmsConfiguration();
- configuration.setConnectionFactory(connectionFactory);
-
- return new JmsComponent(configuration);
- }
-
}
diff --git a/examples/artemis/src/test/java/org/apache/camel/example/artemis/ArtemisTest.java b/examples/artemis/src/test/java/org/apache/camel/example/artemis/ArtemisTest.java
index 926e3c0..ef0065a 100644
--- a/examples/artemis/src/test/java/org/apache/camel/example/artemis/ArtemisTest.java
+++ b/examples/artemis/src/test/java/org/apache/camel/example/artemis/ArtemisTest.java
@@ -21,7 +21,6 @@ import org.apache.activemq.artemis.core.server.ActiveMQServer;
import org.apache.activemq.artemis.core.server.impl.ActiveMQServerImpl;
import org.apache.camel.builder.NotifyBuilder;
import org.apache.camel.main.MainConfigurationProperties;
-import org.apache.camel.spi.Registry;
import org.apache.camel.test.main.junit5.CamelMainTestSupport;
import org.junit.jupiter.api.AfterAll;
import org.junit.jupiter.api.BeforeAll;
@@ -60,11 +59,6 @@ class ArtemisTest extends CamelMainTestSupport {
}
}
- @Override
- protected void bindToRegistry(Registry registry) throws Exception {
- registry.bind("jms", ArtemisMain.createArtemisComponent());
- }
-
@Test
void should_distribute_orders() {
@@ -81,10 +75,7 @@ class ArtemisTest extends CamelMainTestSupport {
@Override
protected void configure(MainConfigurationProperties configuration) {
- // add the widget/gadget route
- configuration.addRoutesBuilder(new WidgetGadgetRoute());
-
- // add a 2nd route that routes files from src/data to the order queue
- configuration.addRoutesBuilder(new CreateOrderRoute());
+ // CreateOrderRoute, WidgetGadgetRoute and configuration will be auto-discovered
+ configuration.setBasePackageScan(ArtemisMain.class.getPackageName());
}
}
diff --git a/examples/aws/aws-secrets-manager/src/main/java/org/apache/camel/example/MyApplication.java b/examples/aws/aws-secrets-manager/src/main/java/org/apache/camel/example/MyApplication.java
index 496b37d..31197dc 100644
--- a/examples/aws/aws-secrets-manager/src/main/java/org/apache/camel/example/MyApplication.java
+++ b/examples/aws/aws-secrets-manager/src/main/java/org/apache/camel/example/MyApplication.java
@@ -28,9 +28,7 @@ public final class MyApplication {
public static void main(String[] args) throws Exception {
// use Camels Main class
- Main main = new Main();
- // and add the routes (you can specify multiple classes)
- main.configure().addRoutesBuilder(MyRouteBuilder.class);
+ Main main = new Main(MyApplication.class);
// now keep the application running until the JVM is terminated (ctrl + c or sigterm)
main.run(args);
}
diff --git a/examples/aws/aws-secrets-manager/src/main/resources/application.properties b/examples/aws/aws-secrets-manager/src/main/resources/application.properties
index 172d896..cdf5cff 100644
--- a/examples/aws/aws-secrets-manager/src/main/resources/application.properties
+++ b/examples/aws/aws-secrets-manager/src/main/resources/application.properties
@@ -15,8 +15,8 @@
## limitations under the License.
## ---------------------------------------------------------------------------
-# to configure camel main
-# here you can configure options on camel main (see MainConfigurationProperties class)
+# here you can configure options on camel main
+# https://camel.apache.org/components/next/others/main.html
camel.main.name = AWS-secrets-manager
camel.main.jmx-enabled = false
diff --git a/examples/aws/main-endpointdsl-aws2-s3-kafka/src/main/java/org/apache/camel/example/MyApplication.java b/examples/aws/main-endpointdsl-aws2-s3-kafka/src/main/java/org/apache/camel/example/MyApplication.java
index 496b37d..31197dc 100644
--- a/examples/aws/main-endpointdsl-aws2-s3-kafka/src/main/java/org/apache/camel/example/MyApplication.java
+++ b/examples/aws/main-endpointdsl-aws2-s3-kafka/src/main/java/org/apache/camel/example/MyApplication.java
@@ -28,9 +28,7 @@ public final class MyApplication {
public static void main(String[] args) throws Exception {
// use Camels Main class
- Main main = new Main();
- // and add the routes (you can specify multiple classes)
- main.configure().addRoutesBuilder(MyRouteBuilder.class);
+ Main main = new Main(MyApplication.class);
// now keep the application running until the JVM is terminated (ctrl + c or sigterm)
main.run(args);
}
diff --git a/examples/aws/main-endpointdsl-aws2-s3-kafka/src/main/resources/application.properties b/examples/aws/main-endpointdsl-aws2-s3-kafka/src/main/resources/application.properties
index d813f79..a7abcd7 100644
--- a/examples/aws/main-endpointdsl-aws2-s3-kafka/src/main/resources/application.properties
+++ b/examples/aws/main-endpointdsl-aws2-s3-kafka/src/main/resources/application.properties
@@ -15,8 +15,8 @@
## limitations under the License.
## ---------------------------------------------------------------------------
-# to configure camel main
-# here you can configure options on camel main (see MainConfigurationProperties class)
+# here you can configure options on camel main
+# https://camel.apache.org/components/next/others/main.html
camel.main.name = AWS2-S3-Consumer-to-Kafka
# properties used in the route
diff --git a/examples/aws/main-endpointdsl-aws2-s3/src/main/java/org/apache/camel/example/MyApplication.java b/examples/aws/main-endpointdsl-aws2-s3/src/main/java/org/apache/camel/example/MyApplication.java
index 496b37d..31197dc 100644
--- a/examples/aws/main-endpointdsl-aws2-s3/src/main/java/org/apache/camel/example/MyApplication.java
+++ b/examples/aws/main-endpointdsl-aws2-s3/src/main/java/org/apache/camel/example/MyApplication.java
@@ -28,9 +28,7 @@ public final class MyApplication {
public static void main(String[] args) throws Exception {
// use Camels Main class
- Main main = new Main();
- // and add the routes (you can specify multiple classes)
- main.configure().addRoutesBuilder(MyRouteBuilder.class);
+ Main main = new Main(MyApplication.class);
// now keep the application running until the JVM is terminated (ctrl + c or sigterm)
main.run(args);
}
diff --git a/examples/aws/main-endpointdsl-aws2-s3/src/main/resources/application.properties b/examples/aws/main-endpointdsl-aws2-s3/src/main/resources/application.properties
index d1295d7..271186f 100644
--- a/examples/aws/main-endpointdsl-aws2-s3/src/main/resources/application.properties
+++ b/examples/aws/main-endpointdsl-aws2-s3/src/main/resources/application.properties
@@ -15,8 +15,8 @@
## limitations under the License.
## ---------------------------------------------------------------------------
-# to configure camel main
-# here you can configure options on camel main (see MainConfigurationProperties class)
+# here you can configure options on camel main
+# https://camel.apache.org/components/next/others/main.html
camel.main.name = AWS2-S3-Consumer
# properties used in the route
diff --git a/examples/aws/main-endpointdsl-aws2/aws2-eventbridge-creator/src/main/java/org/apache/camel/example/MyApplication.java b/examples/aws/main-endpointdsl-aws2/aws2-eventbridge-creator/src/main/java/org/apache/camel/example/MyApplication.java
index 496b37d..31197dc 100644
--- a/examples/aws/main-endpointdsl-aws2/aws2-eventbridge-creator/src/main/java/org/apache/camel/example/MyApplication.java
+++ b/examples/aws/main-endpointdsl-aws2/aws2-eventbridge-creator/src/main/java/org/apache/camel/example/MyApplication.java
@@ -28,9 +28,7 @@ public final class MyApplication {
public static void main(String[] args) throws Exception {
// use Camels Main class
- Main main = new Main();
- // and add the routes (you can specify multiple classes)
- main.configure().addRoutesBuilder(MyRouteBuilder.class);
+ Main main = new Main(MyApplication.class);
// now keep the application running until the JVM is terminated (ctrl + c or sigterm)
main.run(args);
}
diff --git a/examples/aws/main-endpointdsl-aws2/aws2-eventbridge-creator/src/main/resources/application.properties b/examples/aws/main-endpointdsl-aws2/aws2-eventbridge-creator/src/main/resources/application.properties
index 085166c..0bf77ee 100644
--- a/examples/aws/main-endpointdsl-aws2/aws2-eventbridge-creator/src/main/resources/application.properties
+++ b/examples/aws/main-endpointdsl-aws2/aws2-eventbridge-creator/src/main/resources/application.properties
@@ -15,8 +15,8 @@
## limitations under the License.
## ---------------------------------------------------------------------------
-# to configure camel main
-# here you can configure options on camel main (see MainConfigurationProperties class)
+# here you can configure options on camel main
+# https://camel.apache.org/components/next/others/main.html
camel.main.name = AWS2-Eventbridge-rule-creator
# properties used in the route
diff --git a/examples/aws/main-endpointdsl-aws2/aws2-s3-events-inject/src/main/java/org/apache/camel/example/MyApplication.java b/examples/aws/main-endpointdsl-aws2/aws2-s3-events-inject/src/main/java/org/apache/camel/example/MyApplication.java
index 496b37d..31197dc 100644
--- a/examples/aws/main-endpointdsl-aws2/aws2-s3-events-inject/src/main/java/org/apache/camel/example/MyApplication.java
+++ b/examples/aws/main-endpointdsl-aws2/aws2-s3-events-inject/src/main/java/org/apache/camel/example/MyApplication.java
@@ -28,9 +28,7 @@ public final class MyApplication {
public static void main(String[] args) throws Exception {
// use Camels Main class
- Main main = new Main();
- // and add the routes (you can specify multiple classes)
- main.configure().addRoutesBuilder(MyRouteBuilder.class);
+ Main main = new Main(MyApplication.class);
// now keep the application running until the JVM is terminated (ctrl + c or sigterm)
main.run(args);
}
diff --git a/examples/aws/main-endpointdsl-aws2/aws2-s3-events-inject/src/main/resources/application.properties b/examples/aws/main-endpointdsl-aws2/aws2-s3-events-inject/src/main/resources/application.properties
index 2317b2f..01f5aa6 100644
--- a/examples/aws/main-endpointdsl-aws2/aws2-s3-events-inject/src/main/resources/application.properties
+++ b/examples/aws/main-endpointdsl-aws2/aws2-s3-events-inject/src/main/resources/application.properties
@@ -15,8 +15,8 @@
## limitations under the License.
## ---------------------------------------------------------------------------
-# to configure camel main
-# here you can configure options on camel main (see MainConfigurationProperties class)
+# here you can configure options on camel main
+# https://camel.apache.org/components/next/others/main.html
camel.main.name = AWS2-S3-Events-Inject
# properties used in the route
diff --git a/examples/aws/main-endpointdsl-aws2/aws2-sqs-consumer/src/main/java/org/apache/camel/example/MyApplication.java b/examples/aws/main-endpointdsl-aws2/aws2-sqs-consumer/src/main/java/org/apache/camel/example/MyApplication.java
index 496b37d..31197dc 100644
--- a/examples/aws/main-endpointdsl-aws2/aws2-sqs-consumer/src/main/java/org/apache/camel/example/MyApplication.java
+++ b/examples/aws/main-endpointdsl-aws2/aws2-sqs-consumer/src/main/java/org/apache/camel/example/MyApplication.java
@@ -28,9 +28,7 @@ public final class MyApplication {
public static void main(String[] args) throws Exception {
// use Camels Main class
- Main main = new Main();
- // and add the routes (you can specify multiple classes)
- main.configure().addRoutesBuilder(MyRouteBuilder.class);
+ Main main = new Main(MyApplication.class);
// now keep the application running until the JVM is terminated (ctrl + c or sigterm)
main.run(args);
}
diff --git a/examples/aws/main-endpointdsl-aws2/aws2-sqs-consumer/src/main/resources/application.properties b/examples/aws/main-endpointdsl-aws2/aws2-sqs-consumer/src/main/resources/application.properties
index 055bb1e..ac1b2fd 100644
--- a/examples/aws/main-endpointdsl-aws2/aws2-sqs-consumer/src/main/resources/application.properties
+++ b/examples/aws/main-endpointdsl-aws2/aws2-sqs-consumer/src/main/resources/application.properties
@@ -15,8 +15,8 @@
## limitations under the License.
## ---------------------------------------------------------------------------
-# to configure camel main
-# here you can configure options on camel main (see MainConfigurationProperties class)
+# here you can configure options on camel main
+# https://camel.apache.org/components/next/others/main.html
camel.main.name = AWS2-SQS-Consumer
# properties used in the route
diff --git a/examples/aws/main-endpointdsl-kafka-aws2-s3-restarting-policy/src/main/java/org/apache/camel/example/MyApplication.java b/examples/aws/main-endpointdsl-kafka-aws2-s3-restarting-policy/src/main/java/org/apache/camel/example/MyApplication.java
index 496b37d..31197dc 100644
--- a/examples/aws/main-endpointdsl-kafka-aws2-s3-restarting-policy/src/main/java/org/apache/camel/example/MyApplication.java
+++ b/examples/aws/main-endpointdsl-kafka-aws2-s3-restarting-policy/src/main/java/org/apache/camel/example/MyApplication.java
@@ -28,9 +28,7 @@ public final class MyApplication {
public static void main(String[] args) throws Exception {
// use Camels Main class
- Main main = new Main();
- // and add the routes (you can specify multiple classes)
- main.configure().addRoutesBuilder(MyRouteBuilder.class);
+ Main main = new Main(MyApplication.class);
// now keep the application running until the JVM is terminated (ctrl + c or sigterm)
main.run(args);
}
diff --git a/examples/aws/main-endpointdsl-kafka-aws2-s3-restarting-policy/src/main/resources/application.properties b/examples/aws/main-endpointdsl-kafka-aws2-s3-restarting-policy/src/main/resources/application.properties
index 49349b2..d1c4ebb 100644
--- a/examples/aws/main-endpointdsl-kafka-aws2-s3-restarting-policy/src/main/resources/application.properties
+++ b/examples/aws/main-endpointdsl-kafka-aws2-s3-restarting-policy/src/main/resources/application.properties
@@ -15,8 +15,8 @@
## limitations under the License.
## ---------------------------------------------------------------------------
-# to configure camel main
-# here you can configure options on camel main (see MainConfigurationProperties class)
+# here you can configure options on camel main
+# https://camel.apache.org/components/next/others/main.html
camel.main.name = Kafka-to-AWS2-S3-Stream
# properties used in the route
diff --git a/examples/aws/main-endpointdsl-kafka-aws2-s3/src/main/java/org/apache/camel/example/MyApplication.java b/examples/aws/main-endpointdsl-kafka-aws2-s3/src/main/java/org/apache/camel/example/MyApplication.java
index 496b37d..31197dc 100644
--- a/examples/aws/main-endpointdsl-kafka-aws2-s3/src/main/java/org/apache/camel/example/MyApplication.java
+++ b/examples/aws/main-endpointdsl-kafka-aws2-s3/src/main/java/org/apache/camel/example/MyApplication.java
@@ -28,9 +28,7 @@ public final class MyApplication {
public static void main(String[] args) throws Exception {
// use Camels Main class
- Main main = new Main();
- // and add the routes (you can specify multiple classes)
- main.configure().addRoutesBuilder(MyRouteBuilder.class);
+ Main main = new Main(MyApplication.class);
// now keep the application running until the JVM is terminated (ctrl + c or sigterm)
main.run(args);
}
diff --git a/examples/aws/main-endpointdsl-kafka-aws2-s3/src/main/resources/application.properties b/examples/aws/main-endpointdsl-kafka-aws2-s3/src/main/resources/application.properties
index 57323ea..6e84d80 100644
--- a/examples/aws/main-endpointdsl-kafka-aws2-s3/src/main/resources/application.properties
+++ b/examples/aws/main-endpointdsl-kafka-aws2-s3/src/main/resources/application.properties
@@ -15,8 +15,8 @@
## limitations under the License.
## ---------------------------------------------------------------------------
-# to configure camel main
-# here you can configure options on camel main (see MainConfigurationProperties class)
+# here you can configure options on camel main
+# https://camel.apache.org/components/next/others/main.html
camel.main.name = Kafka-to-AWS2-S3-Stream
# properties used in the route
diff --git a/examples/azure/azure-eventhubs/src/main/java/org/apache/camel/example/MyApplication.java b/examples/azure/azure-eventhubs/src/main/java/org/apache/camel/example/MyApplication.java
index 496b37d..31197dc 100644
--- a/examples/azure/azure-eventhubs/src/main/java/org/apache/camel/example/MyApplication.java
+++ b/examples/azure/azure-eventhubs/src/main/java/org/apache/camel/example/MyApplication.java
@@ -28,9 +28,7 @@ public final class MyApplication {
public static void main(String[] args) throws Exception {
// use Camels Main class
- Main main = new Main();
- // and add the routes (you can specify multiple classes)
- main.configure().addRoutesBuilder(MyRouteBuilder.class);
+ Main main = new Main(MyApplication.class);
// now keep the application running until the JVM is terminated (ctrl + c or sigterm)
main.run(args);
}
diff --git a/examples/azure/azure-eventhubs/src/main/resources/application.properties b/examples/azure/azure-eventhubs/src/main/resources/application.properties
index 6a81e83..ec8d3e8 100644
--- a/examples/azure/azure-eventhubs/src/main/resources/application.properties
+++ b/examples/azure/azure-eventhubs/src/main/resources/application.properties
@@ -15,8 +15,8 @@
## limitations under the License.
## ---------------------------------------------------------------------------
-# to configure camel main
-# here you can configure options on camel main (see MainConfigurationProperties class)
+# here you can configure options on camel main
+# https://camel.apache.org/components/next/others/main.html
camel.main.name = Azure-Eventhubs
# properties used in the route
diff --git a/examples/azure/kafka-azure/src/main/java/org/apache/camel/example/MyApplication.java b/examples/azure/kafka-azure/src/main/java/org/apache/camel/example/MyApplication.java
index 496b37d..31197dc 100644
--- a/examples/azure/kafka-azure/src/main/java/org/apache/camel/example/MyApplication.java
+++ b/examples/azure/kafka-azure/src/main/java/org/apache/camel/example/MyApplication.java
@@ -28,9 +28,7 @@ public final class MyApplication {
public static void main(String[] args) throws Exception {
// use Camels Main class
- Main main = new Main();
- // and add the routes (you can specify multiple classes)
- main.configure().addRoutesBuilder(MyRouteBuilder.class);
+ Main main = new Main(MyApplication.class);
// now keep the application running until the JVM is terminated (ctrl + c or sigterm)
main.run(args);
}
diff --git a/examples/azure/kafka-azure/src/main/resources/application.properties b/examples/azure/kafka-azure/src/main/resources/application.properties
index e1580c2..fd65282 100644
--- a/examples/azure/kafka-azure/src/main/resources/application.properties
+++ b/examples/azure/kafka-azure/src/main/resources/application.properties
@@ -15,8 +15,8 @@
## limitations under the License.
## ---------------------------------------------------------------------------
-# to configure camel main
-# here you can configure options on camel main (see MainConfigurationProperties class)
+# here you can configure options on camel main
+# https://camel.apache.org/components/next/others/main.html
camel.main.name = Kafka-to-Azure-Storage-Blob
# properties used in the route
diff --git a/examples/console/src/main/java/org/apache/camel/example/console/CamelConsoleMain.java b/examples/console/src/main/java/org/apache/camel/example/console/CamelConsoleMain.java
index b5dd958..5918bb7 100644
--- a/examples/console/src/main/java/org/apache/camel/example/console/CamelConsoleMain.java
+++ b/examples/console/src/main/java/org/apache/camel/example/console/CamelConsoleMain.java
@@ -27,10 +27,8 @@ public final class CamelConsoleMain {
}
public static void main(String[] args) throws Exception {
- // Main makes it easier to run a Spring application
+ // Main makes it easier to run a Spring application (default context 'META-INF/spring/*.xml' will be scanned)
Main main = new Main();
- // configure the location of the Spring XML file
- main.setApplicationContextUri("META-INF/spring/camel-context.xml");
// run and block until Camel is stopped (or JVM terminated)
main.run();
}
diff --git a/examples/couchbase-log/src/main/java/org/apache/camel/example/MyApplication.java b/examples/couchbase-log/src/main/java/org/apache/camel/example/MyApplication.java
index 496b37d..31197dc 100644
--- a/examples/couchbase-log/src/main/java/org/apache/camel/example/MyApplication.java
+++ b/examples/couchbase-log/src/main/java/org/apache/camel/example/MyApplication.java
@@ -28,9 +28,7 @@ public final class MyApplication {
public static void main(String[] args) throws Exception {
// use Camels Main class
- Main main = new Main();
- // and add the routes (you can specify multiple classes)
- main.configure().addRoutesBuilder(MyRouteBuilder.class);
+ Main main = new Main(MyApplication.class);
// now keep the application running until the JVM is terminated (ctrl + c or sigterm)
main.run(args);
}
diff --git a/examples/couchbase-log/src/main/resources/application.properties b/examples/couchbase-log/src/main/resources/application.properties
index a3e3914..d9fbad3 100644
--- a/examples/couchbase-log/src/main/resources/application.properties
+++ b/examples/couchbase-log/src/main/resources/application.properties
@@ -15,8 +15,8 @@
## limitations under the License.
## ---------------------------------------------------------------------------
-# to configure camel main
-# here you can configure options on camel main (see MainConfigurationProperties class)
+# here you can configure options on camel main
+# https://camel.apache.org/components/next/others/main.html
camel.main.name = LogCouchbase
couchbase.host=localhost
diff --git a/examples/csimple-joor/src/main/java/org/apache/camel/example/MyApplication.java b/examples/csimple-joor/src/main/java/org/apache/camel/example/MyApplication.java
index 496b37d..31197dc 100644
--- a/examples/csimple-joor/src/main/java/org/apache/camel/example/MyApplication.java
+++ b/examples/csimple-joor/src/main/java/org/apache/camel/example/MyApplication.java
@@ -28,9 +28,7 @@ public final class MyApplication {
public static void main(String[] args) throws Exception {
// use Camels Main class
- Main main = new Main();
- // and add the routes (you can specify multiple classes)
- main.configure().addRoutesBuilder(MyRouteBuilder.class);
+ Main main = new Main(MyApplication.class);
// now keep the application running until the JVM is terminated (ctrl + c or sigterm)
main.run(args);
}
diff --git a/examples/csimple-joor/src/main/resources/application.properties b/examples/csimple-joor/src/main/resources/application.properties
index bc205f4..95d1c70 100644
--- a/examples/csimple-joor/src/main/resources/application.properties
+++ b/examples/csimple-joor/src/main/resources/application.properties
@@ -15,8 +15,8 @@
## limitations under the License.
## ---------------------------------------------------------------------------
-# to configure camel main
-# here you can configure options on camel main (see MainConfigurationProperties class)
+# here you can configure options on camel main
+# https://camel.apache.org/components/next/others/main.html
camel.main.name = MyCSimpleJOORCamel
# enable tracing
diff --git a/examples/csimple/src/main/java/org/apache/camel/example/MyApplication.java b/examples/csimple/src/main/java/org/apache/camel/example/MyApplication.java
index 496b37d..31197dc 100644
--- a/examples/csimple/src/main/java/org/apache/camel/example/MyApplication.java
+++ b/examples/csimple/src/main/java/org/apache/camel/example/MyApplication.java
@@ -28,9 +28,7 @@ public final class MyApplication {
public static void main(String[] args) throws Exception {
// use Camels Main class
- Main main = new Main();
- // and add the routes (you can specify multiple classes)
- main.configure().addRoutesBuilder(MyRouteBuilder.class);
+ Main main = new Main(MyApplication.class);
// now keep the application running until the JVM is terminated (ctrl + c or sigterm)
main.run(args);
}
diff --git a/examples/csimple/src/main/resources/application.properties b/examples/csimple/src/main/resources/application.properties
index 87f73cf..d20bd4c 100644
--- a/examples/csimple/src/main/resources/application.properties
+++ b/examples/csimple/src/main/resources/application.properties
@@ -15,8 +15,8 @@
## limitations under the License.
## ---------------------------------------------------------------------------
-# to configure camel main
-# here you can configure options on camel main (see MainConfigurationProperties class)
+# here you can configure options on camel main
+# https://camel.apache.org/components/next/others/main.html
camel.main.name = MyCSimpleCamel
# enable tracing
diff --git a/examples/cxf-proxy/src/main/java/org/apache/camel/example/cxf/proxy/MyMain.java b/examples/cxf-proxy/src/main/java/org/apache/camel/example/cxf/proxy/MyMain.java
index 978b485..6842e84 100644
--- a/examples/cxf-proxy/src/main/java/org/apache/camel/example/cxf/proxy/MyMain.java
+++ b/examples/cxf-proxy/src/main/java/org/apache/camel/example/cxf/proxy/MyMain.java
@@ -29,8 +29,9 @@ public final class MyMain {
}
public static void main(String[] args) throws Exception {
+ // Main makes it easier to run a Spring application (default context 'META-INF/spring/*.xml' will be scanned)
Main main = new Main();
- main.setApplicationContextUri("META-INF/spring/camel-config.xml");
+ // start the application
main.start();
}
}
diff --git a/examples/cxf-tomcat/pom.xml b/examples/cxf-tomcat/pom.xml
index 216e2b9..30a724f 100644
--- a/examples/cxf-tomcat/pom.xml
+++ b/examples/cxf-tomcat/pom.xml
@@ -55,6 +55,7 @@
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>tomcat-maven-plugin</artifactId>
+ <version>1.1</version>
<configuration>
<server>myTomcat</server>
<url>${tomcat.url}</url>
diff --git a/examples/debezium-eventhubs-blob/pom.xml b/examples/debezium-eventhubs-blob/pom.xml
index 84ebe5f..50e3ce3 100644
--- a/examples/debezium-eventhubs-blob/pom.xml
+++ b/examples/debezium-eventhubs-blob/pom.xml
@@ -99,14 +99,14 @@
<profile>
<id>eventhubs-producer</id>
<properties>
- <target.main.class>org.apache.camel.example.debezium.eventhubs.blob.AzureEventHubsProducerToAzureBlob</target.main.class>
+ <target.main.class>org.apache.camel.example.debezium.eventhubs.blob.producer.AzureEventHubsProducerToAzureBlob</target.main.class>
</properties>
</profile>
<profile>
<id>debezium-consumer</id>
<properties>
- <target.main.class>org.apache.camel.example.debezium.eventhubs.blob.DebeziumMySqlConsumerToAzureEventHubs</target.main.class>
+ <target.main.class>org.apache.camel.example.debezium.eventhubs.blob.consumer.DebeziumMySqlConsumerToAzureEventHubs</target.main.class>
</properties>
</profile>
diff --git a/examples/debezium-eventhubs-blob/src/main/java/org/apache/camel/example/debezium/eventhubs/blob/AzureEventHubsProducerToAzureBlob.java b/examples/debezium-eventhubs-blob/src/main/java/org/apache/camel/example/debezium/eventhubs/blob/AzureEventHubsProducerToAzureBlob.java
deleted file mode 100644
index 456673e..0000000
--- a/examples/debezium-eventhubs-blob/src/main/java/org/apache/camel/example/debezium/eventhubs/blob/AzureEventHubsProducerToAzureBlob.java
+++ /dev/null
@@ -1,60 +0,0 @@
-/*
- * 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.debezium.eventhubs.blob;
-
-import org.apache.camel.builder.RouteBuilder;
-import org.apache.camel.main.Main;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-/**
- * A simple example to sink data from Azure Event Hubs that produced by Debezium into Azure Storage Blob
- */
-public final class AzureEventHubsProducerToAzureBlob {
-
- private static final Logger LOG = LoggerFactory.getLogger(AzureEventHubsProducerToAzureBlob.class);
-
- // use Camel Main to setup and run Camel
- private static Main main = new Main();
-
- private AzureEventHubsProducerToAzureBlob() {
- }
-
- public static void main(String[] args) throws Exception {
-
- LOG.debug("About to run Event Hubs to Storage Blob integration..");
-
- // add route
- main.configure().addRoutesBuilder(new RouteBuilder() {
- public void configure() {
- from("azure-eventhubs:?connectionString=RAW({{eventhubs.connectionString}})"
- + "&blobContainerName={{blob.containerName}}"
- + "&blobAccountName={{blob.accountName}}"
- + "&blobAccessKey=RAW({{blob.accessKey}})")
- // write our data to Azure Blob Storage but committing to an existing append blob
- .to("azure-storage-blob://{{blob.accountName}}/{{blob.containerName}}?operation=commitAppendBlob"
- + "&accessKey=RAW({{blob.accessKey}})"
- + "&blobName={{blob.blobName}}")
- .end();
- }
- });
-
- // start and run Camel (block)
- main.run();
- }
-
-}
diff --git a/examples/debezium-eventhubs-blob/src/main/java/org/apache/camel/example/debezium/eventhubs/blob/DebeziumMySqlConsumerToAzureEventHubs.java b/examples/debezium-eventhubs-blob/src/main/java/org/apache/camel/example/debezium/eventhubs/blob/DebeziumMySqlConsumerToAzureEventHubs.java
deleted file mode 100644
index 5c537f3..0000000
--- a/examples/debezium-eventhubs-blob/src/main/java/org/apache/camel/example/debezium/eventhubs/blob/DebeziumMySqlConsumerToAzureEventHubs.java
+++ /dev/null
@@ -1,105 +0,0 @@
-/*
- * 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.debezium.eventhubs.blob;
-
-import java.util.HashMap;
-import java.util.Map;
-
-import org.apache.camel.builder.RouteBuilder;
-import org.apache.camel.component.azure.eventhubs.EventHubsConstants;
-import org.apache.camel.component.debezium.DebeziumConstants;
-import org.apache.camel.main.Main;
-import org.apache.camel.model.dataformat.JsonLibrary;
-import org.apache.kafka.connect.data.Struct;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-/**
- * A simple example to consume data from Debezium and send it to Azure EventHubs
- */
-public final class DebeziumMySqlConsumerToAzureEventHubs {
-
- private static final Logger LOG = LoggerFactory.getLogger(DebeziumMySqlConsumerToAzureEventHubs.class);
-
- // use Camel Main to setup and run Camel
- private static Main main = new Main();
-
- private DebeziumMySqlConsumerToAzureEventHubs() {
- }
-
- public static void main(String[] args) throws Exception {
-
- LOG.debug("About to run Debezium integration...");
-
- // add route
- main.configure().addRoutesBuilder(new RouteBuilder() {
- public void configure() {
- // Initial Debezium route that will run and listens to the changes,
- // first it will perform an initial snapshot using (select * from) in case there are no offsets
- // exists for the connector, and then it will listen to MySQL binlogs for any DB events such as (UPDATE, INSERT and DELETE)
- from("debezium-mysql:{{debezium.mysql.name}}?"
- + "databaseServerId={{debezium.mysql.databaseServerId}}"
- + "&databaseHostname={{debezium.mysql.databaseHostName}}"
- + "&databasePort={{debezium.mysql.databasePort}}"
- + "&databaseUser={{debezium.mysql.databaseUser}}"
- + "&databasePassword={{debezium.mysql.databasePassword}}"
- + "&databaseServerName={{debezium.mysql.databaseServerName}}"
- + "&databaseHistoryFileFilename={{debezium.mysql.databaseHistoryFileName}}"
- + "&databaseIncludeList={{debezium.mysql.databaseIncludeList}}"
- + "&tableIncludeList={{debezium.mysql.tableIncludeList}}"
- + "&offsetStorageFileName={{debezium.mysql.offsetStorageFileName}}")
- .routeId("FromDebeziumMySql")
- // We will need to prepare the data for Azure EventHubs Therefore, we will hash the key to make sure our record land on the same partition
- // and convert it to string, but that means we need to preserve the key information into the message body in order not to lose this information downstream.
- // Note: If you'd use Kafka, most probably you will not need these transformations as you can send the key as an object and Kafka will do
- // the rest to hash it in the broker in order to place it in the correct topic's partition.
- .setBody(exchange -> {
- // Using Camel Data Format, we can retrieve our data in Map since Debezium component has a Type Converter from Struct to Map, you need to specify the Map.class
- // in order to convert the data from Struct to Map
- final Map key = exchange.getMessage().getHeader(DebeziumConstants.HEADER_KEY, Map.class);
- final Map value = exchange.getMessage().getBody(Map.class);
- // Also, we need the operation in order to determine when an INSERT, UPDATE or DELETE happens
- final String operation = (String) exchange.getMessage().getHeader(DebeziumConstants.HEADER_OPERATION);
- // We we will put everything as nested Map in order to utilize Camel's Type Format
- final Map<String, Object> eventHubBody = new HashMap<>();
-
- eventHubBody.put("key", key);
- eventHubBody.put("value", value);
- eventHubBody.put("operation", operation);
-
- return eventHubBody;
- })
- // As we mentioned above, we will need to hash the key partition and set it into the headers
- .process(exchange -> {
- final Struct key = (Struct) exchange.getMessage().getHeader(DebeziumConstants.HEADER_KEY);
- final String hash = String.valueOf(key.hashCode());
-
- exchange.getMessage().setHeader(EventHubsConstants.PARTITION_KEY, hash);
- })
- // Marshal everything to JSON, you can use any other data format such as Avro, Protobuf..etc, but in this example we will keep it to JSON for simplicity
- .marshal().json(JsonLibrary.Jackson)
- // Send our data to Azure Event Hubs
- .to("azure-eventhubs:?connectionString=RAW({{eventhubs.connectionString}})")
- .end();
- }
- });
-
- // start and run Camel (block)
- main.run();
- }
-
-}
diff --git a/examples/splunk/src/main/java/org/apache/camel/example/splunk/SplunkSearchClient.java b/examples/debezium-eventhubs-blob/src/main/java/org/apache/camel/example/debezium/eventhubs/blob/consumer/DebeziumMySqlConsumerToAzureEventHubs.java
similarity index 63%
copy from examples/splunk/src/main/java/org/apache/camel/example/splunk/SplunkSearchClient.java
copy to examples/debezium-eventhubs-blob/src/main/java/org/apache/camel/example/debezium/eventhubs/blob/consumer/DebeziumMySqlConsumerToAzureEventHubs.java
index ad0961a..ad0012b 100644
--- a/examples/splunk/src/main/java/org/apache/camel/example/splunk/SplunkSearchClient.java
+++ b/examples/debezium-eventhubs-blob/src/main/java/org/apache/camel/example/debezium/eventhubs/blob/consumer/DebeziumMySqlConsumerToAzureEventHubs.java
@@ -14,23 +14,27 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package org.apache.camel.example.splunk;
+package org.apache.camel.example.debezium.eventhubs.blob.consumer;
import org.apache.camel.main.Main;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-public final class SplunkSearchClient {
+/**
+ * A simple example to consume data from Debezium and send it to Azure EventHubs
+ */
+public final class DebeziumMySqlConsumerToAzureEventHubs {
- private static final Logger LOG = LoggerFactory.getLogger(SplunkSearchClient.class);
+ private static final Logger LOG = LoggerFactory.getLogger(DebeziumMySqlConsumerToAzureEventHubs.class);
- private SplunkSearchClient() {
+ private DebeziumMySqlConsumerToAzureEventHubs() {
}
public static void main(String[] args) throws Exception {
- LOG.info("About to run splunk-camel integration...");
- Main main = new Main();
- main.configure().addRoutesBuilder(new SplunkSearchRouteBuilder());
+ LOG.debug("About to run Debezium integration...");
+ // use Camels Main class
+ Main main = new Main(DebeziumMySqlConsumerToAzureEventHubs.class);
+ // start and run Camel (block)
main.run();
}
diff --git a/examples/debezium-eventhubs-blob/src/main/java/org/apache/camel/example/debezium/eventhubs/blob/consumer/DebeziumMySqlConsumerToAzureEventHubsRouteBuilder.java b/examples/debezium-eventhubs-blob/src/main/java/org/apache/camel/example/debezium/eventhubs/blob/consumer/DebeziumMySqlConsumerToAzureEventHubsRouteBuilder.java
new file mode 100644
index 0000000..c917c54
--- /dev/null
+++ b/examples/debezium-eventhubs-blob/src/main/java/org/apache/camel/example/debezium/eventhubs/blob/consumer/DebeziumMySqlConsumerToAzureEventHubsRouteBuilder.java
@@ -0,0 +1,81 @@
+/*
+ * 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.debezium.eventhubs.blob.consumer;
+
+import org.apache.camel.builder.RouteBuilder;
+import org.apache.camel.component.azure.eventhubs.EventHubsConstants;
+import org.apache.camel.component.debezium.DebeziumConstants;
+import org.apache.camel.model.dataformat.JsonLibrary;
+import org.apache.kafka.connect.data.Struct;
+
+import java.util.HashMap;
+import java.util.Map;
+
+public class DebeziumMySqlConsumerToAzureEventHubsRouteBuilder extends RouteBuilder {
+
+ @Override
+ public void configure() throws Exception {
+ // Initial Debezium route that will run and listens to the changes,
+ // first it will perform an initial snapshot using (select * from) in case there are no offsets
+ // exists for the connector, and then it will listen to MySQL binlogs for any DB events such as (UPDATE, INSERT and DELETE)
+ from("debezium-mysql:{{debezium.mysql.name}}?"
+ + "databaseServerId={{debezium.mysql.databaseServerId}}"
+ + "&databaseHostname={{debezium.mysql.databaseHostName}}"
+ + "&databasePort={{debezium.mysql.databasePort}}"
+ + "&databaseUser={{debezium.mysql.databaseUser}}"
+ + "&databasePassword={{debezium.mysql.databasePassword}}"
+ + "&databaseServerName={{debezium.mysql.databaseServerName}}"
+ + "&databaseHistoryFileFilename={{debezium.mysql.databaseHistoryFileName}}"
+ + "&databaseIncludeList={{debezium.mysql.databaseIncludeList}}"
+ + "&tableIncludeList={{debezium.mysql.tableIncludeList}}"
+ + "&offsetStorageFileName={{debezium.mysql.offsetStorageFileName}}")
+ .routeId("FromDebeziumMySql")
+ // We will need to prepare the data for Azure EventHubs Therefore, we will hash the key to make sure our record land on the same partition
+ // and convert it to string, but that means we need to preserve the key information into the message body in order not to lose this information downstream.
+ // Note: If you'd use Kafka, most probably you will not need these transformations as you can send the key as an object and Kafka will do
+ // the rest to hash it in the broker in order to place it in the correct topic's partition.
+ .setBody(exchange -> {
+ // Using Camel Data Format, we can retrieve our data in Map since Debezium component has a Type Converter from Struct to Map, you need to specify the Map.class
+ // in order to convert the data from Struct to Map
+ final Map key = exchange.getMessage().getHeader(DebeziumConstants.HEADER_KEY, Map.class);
+ final Map value = exchange.getMessage().getBody(Map.class);
+ // Also, we need the operation in order to determine when an INSERT, UPDATE or DELETE happens
+ final String operation = (String) exchange.getMessage().getHeader(DebeziumConstants.HEADER_OPERATION);
+ // We we will put everything as nested Map in order to utilize Camel's Type Format
+ final Map<String, Object> eventHubBody = new HashMap<>();
+
+ eventHubBody.put("key", key);
+ eventHubBody.put("value", value);
+ eventHubBody.put("operation", operation);
+
+ return eventHubBody;
+ })
+ // As we mentioned above, we will need to hash the key partition and set it into the headers
+ .process(exchange -> {
+ final Struct key = (Struct) exchange.getMessage().getHeader(DebeziumConstants.HEADER_KEY);
+ final String hash = String.valueOf(key.hashCode());
+
+ exchange.getMessage().setHeader(EventHubsConstants.PARTITION_KEY, hash);
+ })
+ // Marshal everything to JSON, you can use any other data format such as Avro, Protobuf..etc, but in this example we will keep it to JSON for simplicity
+ .marshal().json(JsonLibrary.Jackson)
+ // Send our data to Azure Event Hubs
+ .to("azure-eventhubs:?connectionString=RAW({{eventhubs.connectionString}})")
+ .end();
+ }
+}
diff --git a/examples/splunk/src/main/java/org/apache/camel/example/splunk/SplunkSearchClient.java b/examples/debezium-eventhubs-blob/src/main/java/org/apache/camel/example/debezium/eventhubs/blob/producer/AzureEventHubsProducerToAzureBlob.java
similarity index 62%
copy from examples/splunk/src/main/java/org/apache/camel/example/splunk/SplunkSearchClient.java
copy to examples/debezium-eventhubs-blob/src/main/java/org/apache/camel/example/debezium/eventhubs/blob/producer/AzureEventHubsProducerToAzureBlob.java
index ad0961a..dbb0a5e 100644
--- a/examples/splunk/src/main/java/org/apache/camel/example/splunk/SplunkSearchClient.java
+++ b/examples/debezium-eventhubs-blob/src/main/java/org/apache/camel/example/debezium/eventhubs/blob/producer/AzureEventHubsProducerToAzureBlob.java
@@ -14,23 +14,27 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package org.apache.camel.example.splunk;
+package org.apache.camel.example.debezium.eventhubs.blob.producer;
import org.apache.camel.main.Main;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-public final class SplunkSearchClient {
+/**
+ * A simple example to sink data from Azure Event Hubs that produced by Debezium into Azure Storage Blob
+ */
+public final class AzureEventHubsProducerToAzureBlob {
- private static final Logger LOG = LoggerFactory.getLogger(SplunkSearchClient.class);
+ private static final Logger LOG = LoggerFactory.getLogger(AzureEventHubsProducerToAzureBlob.class);
- private SplunkSearchClient() {
+ private AzureEventHubsProducerToAzureBlob() {
}
public static void main(String[] args) throws Exception {
- LOG.info("About to run splunk-camel integration...");
- Main main = new Main();
- main.configure().addRoutesBuilder(new SplunkSearchRouteBuilder());
+ LOG.debug("About to run Event Hubs to Storage Blob integration..");
+ // use Camels Main class
+ Main main = new Main(AzureEventHubsProducerToAzureBlob.class);
+ // start and run Camel (block)
main.run();
}
diff --git a/examples/splunk/src/main/java/org/apache/camel/example/splunk/SplunkSearchRouteBuilder.java b/examples/debezium-eventhubs-blob/src/main/java/org/apache/camel/example/debezium/eventhubs/blob/producer/AzureEventHubsProducerToAzureBlobRouteBuilder.java
similarity index 52%
copy from examples/splunk/src/main/java/org/apache/camel/example/splunk/SplunkSearchRouteBuilder.java
copy to examples/debezium-eventhubs-blob/src/main/java/org/apache/camel/example/debezium/eventhubs/blob/producer/AzureEventHubsProducerToAzureBlobRouteBuilder.java
index 00ef93b..d580d76 100644
--- a/examples/splunk/src/main/java/org/apache/camel/example/splunk/SplunkSearchRouteBuilder.java
+++ b/examples/debezium-eventhubs-blob/src/main/java/org/apache/camel/example/debezium/eventhubs/blob/producer/AzureEventHubsProducerToAzureBlobRouteBuilder.java
@@ -13,24 +13,24 @@
* 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.splunk;
+package org.apache.camel.example.debezium.eventhubs.blob.producer;
import org.apache.camel.builder.RouteBuilder;
-public class SplunkSearchRouteBuilder extends RouteBuilder {
+public class AzureEventHubsProducerToAzureBlobRouteBuilder extends RouteBuilder {
@Override
- public void configure() throws Exception {
-
- log.info("About to setup Splunk search route: Splunk Server --> log{results}");
-
- // configure properties component
- getContext().getPropertiesComponent().setLocation("classpath:application.properties");
-
- from("splunk://normal?host={{splunk.host}}&port={{splunk.port}}&delay=10000"
- + "&username={{splunk.username}}&password={{splunk.password}}&initEarliestTime=08/17/13 08:35:46:456"
- + "&sourceType=access_combined_wcookie&search=search Code=D | head 5")
- .log("${body}");
+ public void configure() {
+ from("azure-eventhubs:?connectionString=RAW({{eventhubs.connectionString}})"
+ + "&blobContainerName={{blob.containerName}}"
+ + "&blobAccountName={{blob.accountName}}"
+ + "&blobAccessKey=RAW({{blob.accessKey}})")
+ // write our data to Azure Blob Storage but committing to an existing append blob
+ .to("azure-storage-blob://{{blob.accountName}}/{{blob.containerName}}?operation=commitAppendBlob"
+ + "&accessKey=RAW({{blob.accessKey}})"
+ + "&blobName={{blob.blobName}}")
+ .end();
}
}
diff --git a/examples/flight-recorder/src/main/java/org/apache/camel/example/MyApplication.java b/examples/flight-recorder/src/main/java/org/apache/camel/example/MyApplication.java
index 496b37d..31197dc 100644
--- a/examples/flight-recorder/src/main/java/org/apache/camel/example/MyApplication.java
+++ b/examples/flight-recorder/src/main/java/org/apache/camel/example/MyApplication.java
@@ -28,9 +28,7 @@ public final class MyApplication {
public static void main(String[] args) throws Exception {
// use Camels Main class
- Main main = new Main();
- // and add the routes (you can specify multiple classes)
- main.configure().addRoutesBuilder(MyRouteBuilder.class);
+ Main main = new Main(MyApplication.class);
// now keep the application running until the JVM is terminated (ctrl + c or sigterm)
main.run(args);
}
diff --git a/examples/flight-recorder/src/main/resources/application.properties b/examples/flight-recorder/src/main/resources/application.properties
index 95e3fee..cbdd86c 100644
--- a/examples/flight-recorder/src/main/resources/application.properties
+++ b/examples/flight-recorder/src/main/resources/application.properties
@@ -15,8 +15,8 @@
## limitations under the License.
## ---------------------------------------------------------------------------
-# to configure camel main
-# here you can configure options on camel main (see MainConfigurationProperties class)
+# here you can configure options on camel main
+# https://camel.apache.org/components/next/others/main.html
camel.main.name = MySlowCamel
# enable startup recorder which can be logging or java-flight-recorder
diff --git a/examples/flight-recorder/src/test/java/org/apache/camel/example/FlightRecorderTest.java b/examples/flight-recorder/src/test/java/org/apache/camel/example/FlightRecorderTest.java
index 6dd26b8..5eedccb 100644
--- a/examples/flight-recorder/src/test/java/org/apache/camel/example/FlightRecorderTest.java
+++ b/examples/flight-recorder/src/test/java/org/apache/camel/example/FlightRecorderTest.java
@@ -33,9 +33,7 @@ class FlightRecorderTest {
void should_launch_flight_recorder() throws Exception {
long before = Files.list(Paths.get(".")).filter(p -> p.toString().endsWith(".jfr")).count();
// use Camels Main class
- Main main = new Main();
- // and add the routes (you can specify multiple classes)
- main.configure().addRoutesBuilder(MyRouteBuilder.class);
+ Main main = new Main(FlightRecorderTest.class);
try {
main.start();
} finally {
diff --git a/examples/ftp/src/main/java/org/apache/camel/example/ftp/MyFtpClient.java b/examples/ftp/src/main/java/org/apache/camel/example/ftp/MyFtpClient.java
index 3dc3eca..b7b9cec 100644
--- a/examples/ftp/src/main/java/org/apache/camel/example/ftp/MyFtpClient.java
+++ b/examples/ftp/src/main/java/org/apache/camel/example/ftp/MyFtpClient.java
@@ -27,8 +27,7 @@ public final class MyFtpClient {
}
public static void main(String[] args) throws Exception {
- Main main = new Main();
- main.configure().addRoutesBuilder(new MyFtpClientRouteBuilder());
+ Main main = new Main(MyFtpClient.class);
main.run();
}
diff --git a/examples/ftp/src/main/java/org/apache/camel/example/ftp/MyFtpServer.java b/examples/ftp/src/main/java/org/apache/camel/example/ftp/MyFtpServer.java
index dd9600c..a974a44 100644
--- a/examples/ftp/src/main/java/org/apache/camel/example/ftp/MyFtpServer.java
+++ b/examples/ftp/src/main/java/org/apache/camel/example/ftp/MyFtpServer.java
@@ -27,8 +27,7 @@ public final class MyFtpServer {
}
public static void main(String[] args) throws Exception {
- Main main = new Main();
- main.configure().addRoutesBuilder(new MyFtpServerRouteBuilder());
+ Main main = new Main(MyFtpServer.class);
main.run();
}
diff --git a/examples/java8/src/main/java/org/apache/camel/example/java8/MyApplication.java b/examples/java8/src/main/java/org/apache/camel/example/java8/MyApplication.java
index da1f64b..32ec7be 100644
--- a/examples/java8/src/main/java/org/apache/camel/example/java8/MyApplication.java
+++ b/examples/java8/src/main/java/org/apache/camel/example/java8/MyApplication.java
@@ -33,12 +33,12 @@ public final class MyApplication {
}
public static void main(String[] args) throws Exception {
- Main main = new Main();
- main.configure().addRoutesBuilder(new MyRouteBuilder());
+ Main main = new Main(MyApplication.class);
main.run(args);
}
static class MyRouteBuilder extends RouteBuilder {
+
@Override
public void configure() throws Exception {
from("timer:simple?period=503")
diff --git a/examples/loan-broker-cxf/src/main/java/org/apache/camel/loanbroker/LoanBroker.java b/examples/loan-broker-cxf/src/main/java/org/apache/camel/loanbroker/LoanBroker.java
index 25f2353..3a34a78 100644
--- a/examples/loan-broker-cxf/src/main/java/org/apache/camel/loanbroker/LoanBroker.java
+++ b/examples/loan-broker-cxf/src/main/java/org/apache/camel/loanbroker/LoanBroker.java
@@ -28,10 +28,9 @@ public final class LoanBroker {
}
public static void main(String... args) throws Exception {
- // create a new main which will boot the Spring XML file
+ // create a main which will boot the Spring XML file (default context 'META-INF/spring/*.xml' will be scanned)
Main main = new Main();
- main.setApplicationContext(new ClassPathXmlApplicationContext("META-INF/spring/webServiceCamelContext.xml"));
+ // run and block until Camel is stopped (or JVM terminated)
main.run();
}
-
}
diff --git a/examples/main-artemis/src/main/java/org/apache/camel/example/MyApplication.java b/examples/main-artemis/src/main/java/org/apache/camel/example/MyApplication.java
index 23ac6cd..31197dc 100644
--- a/examples/main-artemis/src/main/java/org/apache/camel/example/MyApplication.java
+++ b/examples/main-artemis/src/main/java/org/apache/camel/example/MyApplication.java
@@ -28,12 +28,7 @@ public final class MyApplication {
public static void main(String[] args) throws Exception {
// use Camels Main class
- Main main = new Main();
- // lets use a configuration class (you can specify multiple classes)
- // (properties are automatic loaded from application.properties)
- main.configure().addConfiguration(MyConfiguration.class);
- // and add the routes (you can specify multiple classes)
- main.configure().addRoutesBuilder(MyRouteBuilder.class);
+ Main main = new Main(MyApplication.class);
// now keep the application running until the JVM is terminated (ctrl + c or sigterm)
main.run(args);
}
diff --git a/examples/main-artemis/src/main/java/org/apache/camel/example/MyConfiguration.java b/examples/main-artemis/src/main/java/org/apache/camel/example/MyConfiguration.java
index dfd648c..10dad68 100644
--- a/examples/main-artemis/src/main/java/org/apache/camel/example/MyConfiguration.java
+++ b/examples/main-artemis/src/main/java/org/apache/camel/example/MyConfiguration.java
@@ -17,11 +17,12 @@
package org.apache.camel.example;
import org.apache.camel.CamelConfiguration;
-import org.apache.camel.CamelContext;
+import org.apache.camel.Configuration;
/**
* Class to configure the Camel application.
*/
+@Configuration
public class MyConfiguration implements CamelConfiguration {
/**
@@ -36,10 +37,4 @@ public class MyConfiguration implements CamelConfiguration {
// cf.setPassword("admin");
// return cf;
// }
-
- @Override
- public void configure(CamelContext camelContext) {
- // this method is optional and can be removed if no additional configuration is needed.
- }
-
}
diff --git a/examples/main-artemis/src/main/resources/application.properties b/examples/main-artemis/src/main/resources/application.properties
index 67e8dae..a3afdee 100644
--- a/examples/main-artemis/src/main/resources/application.properties
+++ b/examples/main-artemis/src/main/resources/application.properties
@@ -15,8 +15,8 @@
## limitations under the License.
## ---------------------------------------------------------------------------
-# to configure camel main
-# here you can configure options on camel main (see MainConfigurationProperties class)
+# here you can configure options on camel main
+# https://camel.apache.org/components/next/others/main.html
camel.main.name = MyCamelJmsClient
camel.main.jmx-enabled = false
diff --git a/examples/main-endpointdsl/src/main/java/org/apache/camel/example/MyApplication.java b/examples/main-endpointdsl/src/main/java/org/apache/camel/example/MyApplication.java
index 496b37d..31197dc 100644
--- a/examples/main-endpointdsl/src/main/java/org/apache/camel/example/MyApplication.java
+++ b/examples/main-endpointdsl/src/main/java/org/apache/camel/example/MyApplication.java
@@ -28,9 +28,7 @@ public final class MyApplication {
public static void main(String[] args) throws Exception {
// use Camels Main class
- Main main = new Main();
- // and add the routes (you can specify multiple classes)
- main.configure().addRoutesBuilder(MyRouteBuilder.class);
+ Main main = new Main(MyApplication.class);
// now keep the application running until the JVM is terminated (ctrl + c or sigterm)
main.run(args);
}
diff --git a/examples/main-endpointdsl/src/main/resources/application.properties b/examples/main-endpointdsl/src/main/resources/application.properties
index 5d62b5d..4b79f4a 100644
--- a/examples/main-endpointdsl/src/main/resources/application.properties
+++ b/examples/main-endpointdsl/src/main/resources/application.properties
@@ -15,8 +15,8 @@
## limitations under the License.
## ---------------------------------------------------------------------------
-# to configure camel main
-# here you can configure options on camel main (see MainConfigurationProperties class)
+# here you can configure options on camel main
+# https://camel.apache.org/components/next/others/main.html
camel.main.name = MyCoolCamel
# enable tracing
diff --git a/examples/main-health/src/main/java/org/apache/camel/example/MyApplication.java b/examples/main-health/src/main/java/org/apache/camel/example/MyApplication.java
index 496b37d..31197dc 100644
--- a/examples/main-health/src/main/java/org/apache/camel/example/MyApplication.java
+++ b/examples/main-health/src/main/java/org/apache/camel/example/MyApplication.java
@@ -28,9 +28,7 @@ public final class MyApplication {
public static void main(String[] args) throws Exception {
// use Camels Main class
- Main main = new Main();
- // and add the routes (you can specify multiple classes)
- main.configure().addRoutesBuilder(MyRouteBuilder.class);
+ Main main = new Main(MyApplication.class);
// now keep the application running until the JVM is terminated (ctrl + c or sigterm)
main.run(args);
}
diff --git a/examples/main-health/src/main/resources/application.properties b/examples/main-health/src/main/resources/application.properties
index df48845..2ea005d 100644
--- a/examples/main-health/src/main/resources/application.properties
+++ b/examples/main-health/src/main/resources/application.properties
@@ -15,8 +15,8 @@
## limitations under the License.
## ---------------------------------------------------------------------------
-# to configure camel main
-# here you can configure options on camel main (see MainConfigurationProperties class)
+# here you can configure options on camel main
+# https://camel.apache.org/components/next/others/main.html
camel.main.name = MyHealthyCamel
# turn on loading custom health-checks via classpath scanning
diff --git a/examples/main-joor/src/main/java/org/apache/camel/example/MyApplication.java b/examples/main-joor/src/main/java/org/apache/camel/example/MyApplication.java
index 496b37d..31197dc 100644
--- a/examples/main-joor/src/main/java/org/apache/camel/example/MyApplication.java
+++ b/examples/main-joor/src/main/java/org/apache/camel/example/MyApplication.java
@@ -28,9 +28,7 @@ public final class MyApplication {
public static void main(String[] args) throws Exception {
// use Camels Main class
- Main main = new Main();
- // and add the routes (you can specify multiple classes)
- main.configure().addRoutesBuilder(MyRouteBuilder.class);
+ Main main = new Main(MyApplication.class);
// now keep the application running until the JVM is terminated (ctrl + c or sigterm)
main.run(args);
}
diff --git a/examples/main-joor/src/main/resources/application.properties b/examples/main-joor/src/main/resources/application.properties
index 1915ce7..d6c2df3 100644
--- a/examples/main-joor/src/main/resources/application.properties
+++ b/examples/main-joor/src/main/resources/application.properties
@@ -15,8 +15,8 @@
## limitations under the License.
## ---------------------------------------------------------------------------
-# to configure camel main
-# here you can configure options on camel main (see MainConfigurationProperties class)
+# here you can configure options on camel main
+# https://camel.apache.org/components/next/others/main.html
camel.main.name = MyCamel
# properties used in the route
diff --git a/examples/main-tiny/src/main/java/org/apache/camel/example/MyApplication.java b/examples/main-tiny/src/main/java/org/apache/camel/example/MyApplication.java
index 496b37d..31197dc 100644
--- a/examples/main-tiny/src/main/java/org/apache/camel/example/MyApplication.java
+++ b/examples/main-tiny/src/main/java/org/apache/camel/example/MyApplication.java
@@ -28,9 +28,7 @@ public final class MyApplication {
public static void main(String[] args) throws Exception {
// use Camels Main class
- Main main = new Main();
- // and add the routes (you can specify multiple classes)
- main.configure().addRoutesBuilder(MyRouteBuilder.class);
+ Main main = new Main(MyApplication.class);
// now keep the application running until the JVM is terminated (ctrl + c or sigterm)
main.run(args);
}
diff --git a/examples/main-tiny/src/main/resources/application.properties b/examples/main-tiny/src/main/resources/application.properties
index 068ebd9..a868186 100644
--- a/examples/main-tiny/src/main/resources/application.properties
+++ b/examples/main-tiny/src/main/resources/application.properties
@@ -15,8 +15,8 @@
## limitations under the License.
## ---------------------------------------------------------------------------
-# to configure camel main
-# here you can configure options on camel main (see MainConfigurationProperties class)
+# here you can configure options on camel main
+# https://camel.apache.org/components/next/others/main.html
camel.main.name = MyTinyCamel
# enable tracing
diff --git a/examples/main-xml/src/main/java/org/apache/camel/example/MyApplication.java b/examples/main-xml/src/main/java/org/apache/camel/example/MyApplication.java
index 0e1b14d..66ae30d 100644
--- a/examples/main-xml/src/main/java/org/apache/camel/example/MyApplication.java
+++ b/examples/main-xml/src/main/java/org/apache/camel/example/MyApplication.java
@@ -28,10 +28,7 @@ public final class MyApplication {
public static void main(String[] args) throws Exception {
// use Camels Main class
- Main main = new Main();
- // lets use a configuration class (you can specify multiple classes)
- // (properties are automatic loaded from application.properties)
- main.configure().addConfiguration(MyConfiguration.class);
+ Main main = new Main(MyApplication.class);
// and add all the XML routes
main.configure().withRoutesIncludePattern("routes/*.xml");
// turn on reloading routes on code-changes
diff --git a/examples/main-xml/src/main/java/org/apache/camel/example/MyConfiguration.java b/examples/main-xml/src/main/java/org/apache/camel/example/MyConfiguration.java
index 87418ed..20af68a 100644
--- a/examples/main-xml/src/main/java/org/apache/camel/example/MyConfiguration.java
+++ b/examples/main-xml/src/main/java/org/apache/camel/example/MyConfiguration.java
@@ -18,12 +18,14 @@ package org.apache.camel.example;
import org.apache.camel.BindToRegistry;
import org.apache.camel.CamelContext;
+import org.apache.camel.Configuration;
import org.apache.camel.PropertyInject;
import org.apache.camel.CamelConfiguration;
/**
* Class to configure the Camel application.
*/
+@Configuration
public class MyConfiguration implements CamelConfiguration {
@BindToRegistry
diff --git a/examples/main-xml/src/main/resources/application.properties b/examples/main-xml/src/main/resources/application.properties
index 88cffd1..725b253 100644
--- a/examples/main-xml/src/main/resources/application.properties
+++ b/examples/main-xml/src/main/resources/application.properties
@@ -15,8 +15,8 @@
## limitations under the License.
## ---------------------------------------------------------------------------
-# to configure camel main
-# here you can configure options on camel main (see MainConfigurationProperties class)
+# here you can configure options on camel main
+# https://camel.apache.org/components/next/others/main.html
camel.main.name = MyXmlCamel
# load XML routes
diff --git a/examples/netty-custom-correlation/src/main/java/org/apache/camel/example/netty/MyClient.java b/examples/netty-custom-correlation/src/main/java/org/apache/camel/example/netty/MyClient.java
index d4a11a5..527e460 100644
--- a/examples/netty-custom-correlation/src/main/java/org/apache/camel/example/netty/MyClient.java
+++ b/examples/netty-custom-correlation/src/main/java/org/apache/camel/example/netty/MyClient.java
@@ -18,9 +18,12 @@ package org.apache.camel.example.netty;
import java.util.Random;
+import org.apache.camel.BindToRegistry;
+import org.apache.camel.Configuration;
import org.apache.camel.ExchangeTimedOutException;
import org.apache.camel.LoggingLevel;
import org.apache.camel.builder.RouteBuilder;
+import org.apache.camel.component.netty.DefaultChannelHandlerFactory;
import org.apache.camel.main.Main;
/**
@@ -32,17 +35,30 @@ public final class MyClient {
}
public static void main(String[] args) throws Exception {
- Main main = new Main();
- main.configure().addRoutesBuilder(new MyRouteBuilder());
+ Main main = new Main(MyClient.class);
- MyCorrelationManager manager = createCorrelationManager();
-
- main.bind("myEncoder", new MyCodecEncoderFactory());
- main.bind("myDecoder", new MyCodecDecoderFactory());
- main.bind("myManager", manager);
main.run(args);
}
+ @Configuration
+ public static class MyClientConfiguration {
+
+ @BindToRegistry("myEncoder")
+ public DefaultChannelHandlerFactory myCodecEncoderFactory() {
+ return new MyCodecEncoderFactory();
+ }
+
+ @BindToRegistry("myDecoder")
+ public DefaultChannelHandlerFactory myCodecDecoderFactory() {
+ return new MyCodecDecoderFactory();
+ }
+
+ @BindToRegistry("myManager")
+ public MyCorrelationManager myCorrelationManager() {
+ return createCorrelationManager();
+ }
+ }
+
static MyCorrelationManager createCorrelationManager() {
// setup correlation manager and its timeout (when a request has not received a response within the given time millis)
MyCorrelationManager manager = new MyCorrelationManager();
@@ -53,7 +69,7 @@ public final class MyClient {
return manager;
}
- static class MyRouteBuilder extends RouteBuilder {
+ public static class MyRouteBuilder extends RouteBuilder {
private static final String[] WORDS = new String[]{"foo", "bar", "baz", "beer", "wine", "cheese"};
private int counter;
diff --git a/examples/netty-custom-correlation/src/main/java/org/apache/camel/example/netty/MyServer.java b/examples/netty-custom-correlation/src/main/java/org/apache/camel/example/netty/MyServer.java
index 3a2679b..e2e2c60 100644
--- a/examples/netty-custom-correlation/src/main/java/org/apache/camel/example/netty/MyServer.java
+++ b/examples/netty-custom-correlation/src/main/java/org/apache/camel/example/netty/MyServer.java
@@ -16,7 +16,11 @@
*/
package org.apache.camel.example.netty;
+import org.apache.camel.BindToRegistry;
+import org.apache.camel.Configuration;
+import org.apache.camel.LoggingLevel;
import org.apache.camel.builder.RouteBuilder;
+import org.apache.camel.component.netty.DefaultChannelHandlerFactory;
import org.apache.camel.main.Main;
/**
@@ -28,14 +32,25 @@ public final class MyServer {
}
public static void main(String[] args) throws Exception {
- Main main = new Main();
- main.configure().addRoutesBuilder(new MyRouteBuilder());
- main.bind("myEncoder", new MyCodecEncoderFactory());
- main.bind("myDecoder", new MyCodecDecoderFactory());
+ Main main = new Main(MyServer.class);
main.run(args);
}
- static class MyRouteBuilder extends RouteBuilder {
+ @Configuration
+ public static class MyServerConfiguration {
+
+ @BindToRegistry("myEncoder")
+ public DefaultChannelHandlerFactory myCodecEncoderFactory() {
+ return new MyCodecEncoderFactory();
+ }
+
+ @BindToRegistry("myDecoder")
+ public DefaultChannelHandlerFactory myCodecDecoderFactory() {
+ return new MyCodecDecoderFactory();
+ }
+ }
+
+ public static class MyRouteBuilder extends RouteBuilder {
@Override
public void configure() throws Exception {
diff --git a/examples/reactive-executor-vertx/src/main/java/org/apache/camel/example/MyApplication.java b/examples/reactive-executor-vertx/src/main/java/org/apache/camel/example/MyApplication.java
index 51190af..4a564fc 100644
--- a/examples/reactive-executor-vertx/src/main/java/org/apache/camel/example/MyApplication.java
+++ b/examples/reactive-executor-vertx/src/main/java/org/apache/camel/example/MyApplication.java
@@ -17,7 +17,11 @@
package org.apache.camel.example;
import io.vertx.core.Vertx;
+import org.apache.camel.BindToRegistry;
+import org.apache.camel.CamelContext;
+import org.apache.camel.Configuration;
import org.apache.camel.main.Main;
+import org.apache.camel.support.LifecycleStrategySupport;
/**
* Main class that boot the Camel application
@@ -28,19 +32,30 @@ public final class MyApplication {
}
public static void main(String[] args) throws Exception {
- Vertx vertx = Vertx.vertx();
-
// use Camels Main class
- Main main = new Main();
- // register existing vertx which should be used by Camel
- main.bind("vertx", vertx);
- // and add the routes (you can specify multiple classes)
- main.configure().addRoutesBuilder(MyRouteBuilder.class);
+ Main main = new Main(MyApplication.class);
// now keep the application running until the JVM is terminated (ctrl + c or sigterm)
main.run(args);
+ }
+
+ @Configuration
+ static class MyConfiguration {
- // stop vertx
- vertx.close();
+ @BindToRegistry(value = "vertx", beanPostProcess = true)
+ public Vertx vertx(CamelContext camelContext) {
+ // register existing vertx which should be used by Camel
+ final Vertx vertx = Vertx.vertx();
+ // register 'vertx' bean stop lifecycle hook
+ camelContext.addLifecycleStrategy(new LifecycleStrategySupport() {
+ @Override
+ public void onContextStopped(CamelContext context) {
+ super.onContextStopped(context);
+ // stop vertx
+ vertx.close();
+ }
+ });
+ return vertx;
+ }
}
}
diff --git a/examples/reactive-executor-vertx/src/main/resources/application.properties b/examples/reactive-executor-vertx/src/main/resources/application.properties
index 0afb55c..1d6d98b 100644
--- a/examples/reactive-executor-vertx/src/main/resources/application.properties
+++ b/examples/reactive-executor-vertx/src/main/resources/application.properties
@@ -15,10 +15,9 @@
## limitations under the License.
## ---------------------------------------------------------------------------
-# to configure camel main
-# here you can configure options on camel main (see MainConfigurationProperties class)
+# here you can configure options on camel main
+# https://camel.apache.org/components/next/others/main.html
camel.main.name = MyVertXCamel
-camel.main.jmx-enabled = false
# you can also configure camel context directly
# camel.context.shutdown-strategy.shutdown-now-on-timeout = false
diff --git a/examples/splunk/pom.xml b/examples/splunk/pom.xml
index 77ddbed..95f9126 100644
--- a/examples/splunk/pom.xml
+++ b/examples/splunk/pom.xml
@@ -95,7 +95,7 @@
<groupId>org.codehaus.mojo</groupId>
<artifactId>exec-maven-plugin</artifactId>
<configuration>
- <mainClass>org.apache.camel.example.splunk.SplunkSearchClient</mainClass>
+ <mainClass>org.apache.camel.example.splunk.search.SplunkSearchClient</mainClass>
<includePluginDependencies>false</includePluginDependencies>
</configuration>
</plugin>
@@ -112,7 +112,7 @@
<groupId>org.codehaus.mojo</groupId>
<artifactId>exec-maven-plugin</artifactId>
<configuration>
- <mainClass>org.apache.camel.example.splunk.SplunkSavedSearchClient</mainClass>
+ <mainClass>org.apache.camel.example.splunk.savedsearch.SplunkSavedSearchClient</mainClass>
<includePluginDependencies>false</includePluginDependencies>
</configuration>
</plugin>
@@ -129,7 +129,7 @@
<groupId>org.codehaus.mojo</groupId>
<artifactId>exec-maven-plugin</artifactId>
<configuration>
- <mainClass>org.apache.camel.example.splunk.SplunkPublishEventClient</mainClass>
+ <mainClass>org.apache.camel.example.splunk.publish.SplunkPublishEventClient</mainClass>
<includePluginDependencies>false</includePluginDependencies>
</configuration>
</plugin>
diff --git a/examples/splunk/src/main/java/org/apache/camel/example/splunk/SplunkEventProcessor.java b/examples/splunk/src/main/java/org/apache/camel/example/splunk/publish/SplunkEventProcessor.java
similarity index 96%
rename from examples/splunk/src/main/java/org/apache/camel/example/splunk/SplunkEventProcessor.java
rename to examples/splunk/src/main/java/org/apache/camel/example/splunk/publish/SplunkEventProcessor.java
index 2c2d574..52a5dce 100644
--- a/examples/splunk/src/main/java/org/apache/camel/example/splunk/SplunkEventProcessor.java
+++ b/examples/splunk/src/main/java/org/apache/camel/example/splunk/publish/SplunkEventProcessor.java
@@ -14,7 +14,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package org.apache.camel.example.splunk;
+package org.apache.camel.example.splunk.publish;
import org.apache.camel.Exchange;
import org.apache.camel.Processor;
diff --git a/examples/splunk/src/main/java/org/apache/camel/example/splunk/SplunkPublishEventClient.java b/examples/splunk/src/main/java/org/apache/camel/example/splunk/publish/SplunkPublishEventClient.java
similarity index 97%
rename from examples/splunk/src/main/java/org/apache/camel/example/splunk/SplunkPublishEventClient.java
rename to examples/splunk/src/main/java/org/apache/camel/example/splunk/publish/SplunkPublishEventClient.java
index b6e3655..eb70326 100644
--- a/examples/splunk/src/main/java/org/apache/camel/example/splunk/SplunkPublishEventClient.java
+++ b/examples/splunk/src/main/java/org/apache/camel/example/splunk/publish/SplunkPublishEventClient.java
@@ -14,7 +14,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package org.apache.camel.example.splunk;
+package org.apache.camel.example.splunk.publish;
import org.apache.camel.CamelContext;
import org.apache.camel.ProducerTemplate;
diff --git a/examples/splunk/src/main/java/org/apache/camel/example/splunk/SplunkPublishEventRouteBuilder.java b/examples/splunk/src/main/java/org/apache/camel/example/splunk/publish/SplunkPublishEventRouteBuilder.java
similarity index 96%
rename from examples/splunk/src/main/java/org/apache/camel/example/splunk/SplunkPublishEventRouteBuilder.java
rename to examples/splunk/src/main/java/org/apache/camel/example/splunk/publish/SplunkPublishEventRouteBuilder.java
index ebf0d33..c1a7d95 100644
--- a/examples/splunk/src/main/java/org/apache/camel/example/splunk/SplunkPublishEventRouteBuilder.java
+++ b/examples/splunk/src/main/java/org/apache/camel/example/splunk/publish/SplunkPublishEventRouteBuilder.java
@@ -14,7 +14,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package org.apache.camel.example.splunk;
+package org.apache.camel.example.splunk.publish;
import org.apache.camel.builder.RouteBuilder;
import org.apache.camel.component.splunk.event.SplunkEvent;
diff --git a/examples/splunk/src/main/java/org/apache/camel/example/splunk/SplunkSavedSearchClient.java b/examples/splunk/src/main/java/org/apache/camel/example/splunk/savedsearch/SplunkSavedSearchClient.java
similarity index 88%
rename from examples/splunk/src/main/java/org/apache/camel/example/splunk/SplunkSavedSearchClient.java
rename to examples/splunk/src/main/java/org/apache/camel/example/splunk/savedsearch/SplunkSavedSearchClient.java
index a89f649..425c6f0 100644
--- a/examples/splunk/src/main/java/org/apache/camel/example/splunk/SplunkSavedSearchClient.java
+++ b/examples/splunk/src/main/java/org/apache/camel/example/splunk/savedsearch/SplunkSavedSearchClient.java
@@ -14,7 +14,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package org.apache.camel.example.splunk;
+package org.apache.camel.example.splunk.savedsearch;
import org.apache.camel.main.Main;
import org.slf4j.Logger;
@@ -29,8 +29,7 @@ public final class SplunkSavedSearchClient {
public static void main(String[] args) throws Exception {
LOG.info("About to run splunk-camel integration...");
- Main main = new Main();
- main.configure().addRoutesBuilder(new SplunkSavedSearchRouteBuilder());
+ Main main = new Main(SplunkSavedSearchClient.class);
main.run();
}
}
diff --git a/examples/splunk/src/main/java/org/apache/camel/example/splunk/SplunkSavedSearchRouteBuilder.java b/examples/splunk/src/main/java/org/apache/camel/example/splunk/savedsearch/SplunkSavedSearchRouteBuilder.java
similarity index 96%
rename from examples/splunk/src/main/java/org/apache/camel/example/splunk/SplunkSavedSearchRouteBuilder.java
rename to examples/splunk/src/main/java/org/apache/camel/example/splunk/savedsearch/SplunkSavedSearchRouteBuilder.java
index ef0e9c6..3bc451e 100644
--- a/examples/splunk/src/main/java/org/apache/camel/example/splunk/SplunkSavedSearchRouteBuilder.java
+++ b/examples/splunk/src/main/java/org/apache/camel/example/splunk/savedsearch/SplunkSavedSearchRouteBuilder.java
@@ -14,7 +14,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package org.apache.camel.example.splunk;
+package org.apache.camel.example.splunk.savedsearch;
import org.apache.camel.builder.RouteBuilder;
diff --git a/examples/splunk/src/main/java/org/apache/camel/example/splunk/SplunkSearchClient.java b/examples/splunk/src/main/java/org/apache/camel/example/splunk/search/SplunkSearchClient.java
similarity index 89%
rename from examples/splunk/src/main/java/org/apache/camel/example/splunk/SplunkSearchClient.java
rename to examples/splunk/src/main/java/org/apache/camel/example/splunk/search/SplunkSearchClient.java
index ad0961a..371582a 100644
--- a/examples/splunk/src/main/java/org/apache/camel/example/splunk/SplunkSearchClient.java
+++ b/examples/splunk/src/main/java/org/apache/camel/example/splunk/search/SplunkSearchClient.java
@@ -14,7 +14,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package org.apache.camel.example.splunk;
+package org.apache.camel.example.splunk.search;
import org.apache.camel.main.Main;
import org.slf4j.Logger;
@@ -29,8 +29,7 @@ public final class SplunkSearchClient {
public static void main(String[] args) throws Exception {
LOG.info("About to run splunk-camel integration...");
- Main main = new Main();
- main.configure().addRoutesBuilder(new SplunkSearchRouteBuilder());
+ Main main = new Main(SplunkSearchClient.class);
main.run();
}
diff --git a/examples/splunk/src/main/java/org/apache/camel/example/splunk/SplunkSearchRouteBuilder.java b/examples/splunk/src/main/java/org/apache/camel/example/splunk/search/SplunkSearchRouteBuilder.java
similarity index 96%
rename from examples/splunk/src/main/java/org/apache/camel/example/splunk/SplunkSearchRouteBuilder.java
rename to examples/splunk/src/main/java/org/apache/camel/example/splunk/search/SplunkSearchRouteBuilder.java
index 00ef93b..d07c148 100644
--- a/examples/splunk/src/main/java/org/apache/camel/example/splunk/SplunkSearchRouteBuilder.java
+++ b/examples/splunk/src/main/java/org/apache/camel/example/splunk/search/SplunkSearchRouteBuilder.java
@@ -14,7 +14,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package org.apache.camel.example.splunk;
+package org.apache.camel.example.splunk.search;
import org.apache.camel.builder.RouteBuilder;
diff --git a/examples/twitter-websocket/src/main/java/org/apache/camel/example/websocket/CamelTwitterWebSocketMain.java b/examples/twitter-websocket/src/main/java/org/apache/camel/example/websocket/CamelTwitterWebSocketMain.java
index 914b8b4..007e7f8 100644
--- a/examples/twitter-websocket/src/main/java/org/apache/camel/example/websocket/CamelTwitterWebSocketMain.java
+++ b/examples/twitter-websocket/src/main/java/org/apache/camel/example/websocket/CamelTwitterWebSocketMain.java
@@ -48,10 +48,7 @@ public final class CamelTwitterWebSocketMain {
System.out.println("\n\n\n\n");
// create a new Camel Main so we can easily start Camel
- Main main = new Main();
-
- // add our routes to Camel
- main.configure().addRoutesBuilder(createTwitterWebSocketRoute("gaga", 6_000));
+ Main main = new Main(CamelTwitterWebSocketMain.class);
// and run, which keeps blocking until we terminate the JVM (or stop CamelContext)
main.run();
diff --git a/examples/widget-gadget-java/src/main/java/org/apache/camel/example/widget/WidgetMain.java b/examples/widget-gadget-java/src/main/java/org/apache/camel/example/widget/WidgetConfiguration.java
similarity index 57%
copy from examples/widget-gadget-java/src/main/java/org/apache/camel/example/widget/WidgetMain.java
copy to examples/widget-gadget-java/src/main/java/org/apache/camel/example/widget/WidgetConfiguration.java
index 7870424..606a909 100644
--- a/examples/widget-gadget-java/src/main/java/org/apache/camel/example/widget/WidgetMain.java
+++ b/examples/widget-gadget-java/src/main/java/org/apache/camel/example/widget/WidgetConfiguration.java
@@ -13,41 +13,19 @@
* 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.widget;
+import org.apache.camel.BindToRegistry;
+import org.apache.camel.Configuration;
import org.apache.camel.component.activemq.ActiveMQComponent;
-import org.apache.camel.main.Main;
-
-/**
- * A plain Java Main to start the widget and gadget example.
- */
-public final class WidgetMain {
-
- // use Camel Main to setup and run Camel
- private static Main main = new Main();
-
- private WidgetMain() {
- // to comply with checkstyle
- }
- public static void main(String[] args) throws Exception {
- // create the ActiveMQ component
- main.bind("activemq", createActiveMQComponent());
-
- // add the widget/gadget route
- main.configure().addRoutesBuilder(new WidgetGadgetRoute());
-
- // add a 2nd route that routes files from src/main/data to the order queue
- main.configure().addRoutesBuilder(new CreateOrderRoute());
-
- // start and run Camel (block)
- main.run();
- }
-
- public static ActiveMQComponent createActiveMQComponent() {
- // you can set other options but this is the basic just needed
+@Configuration
+public class WidgetConfiguration {
+ @BindToRegistry("activemq")
+ public ActiveMQComponent activeMQComponent() {
ActiveMQComponent amq = new ActiveMQComponent();
// The ActiveMQ Broker allows anonymous connection by default
@@ -59,5 +37,4 @@ public final class WidgetMain {
return amq;
}
-
}
diff --git a/examples/widget-gadget-java/src/main/java/org/apache/camel/example/widget/WidgetMain.java b/examples/widget-gadget-java/src/main/java/org/apache/camel/example/widget/WidgetMain.java
index 7870424..2701571 100644
--- a/examples/widget-gadget-java/src/main/java/org/apache/camel/example/widget/WidgetMain.java
+++ b/examples/widget-gadget-java/src/main/java/org/apache/camel/example/widget/WidgetMain.java
@@ -16,6 +16,8 @@
*/
package org.apache.camel.example.widget;
+import org.apache.camel.BindToRegistry;
+import org.apache.camel.Configuration;
import org.apache.camel.component.activemq.ActiveMQComponent;
import org.apache.camel.main.Main;
@@ -24,40 +26,13 @@ import org.apache.camel.main.Main;
*/
public final class WidgetMain {
- // use Camel Main to setup and run Camel
- private static Main main = new Main();
-
private WidgetMain() {
// to comply with checkstyle
}
public static void main(String[] args) throws Exception {
- // create the ActiveMQ component
- main.bind("activemq", createActiveMQComponent());
-
- // add the widget/gadget route
- main.configure().addRoutesBuilder(new WidgetGadgetRoute());
-
- // add a 2nd route that routes files from src/main/data to the order queue
- main.configure().addRoutesBuilder(new CreateOrderRoute());
-
+ Main main = new Main(WidgetMain.class);
// start and run Camel (block)
main.run();
}
-
- public static ActiveMQComponent createActiveMQComponent() {
- // you can set other options but this is the basic just needed
-
- ActiveMQComponent amq = new ActiveMQComponent();
-
- // The ActiveMQ Broker allows anonymous connection by default
- // amq.setUserName("admin");
- // amq.setPassword("admin");
-
- // the url to the remote ActiveMQ broker
- amq.setBrokerURL("tcp://localhost:61616");
-
- return amq;
- }
-
}