### Scaffold New Example Project with cq-maven-plugin Source: https://github.com/apache/camel-quarkus/blob/main/docs/modules/ROOT/pages/contributor-guide/create-new-example.adoc Use this command to scaffold a new example project. Specify the artifact ID base, a descriptive name, and a detailed description for the new example. ```shell cd camel-quarkus-examples mvn org.l2x6.cq:cq-maven-plugin:create-example -Dcq.artifactIdBase="yaml-to-log" -Dcq.exampleName="YAML To Log" -Dcq.exampleDescription="Shows how to use a YAML route with the log EIP" ``` -------------------------------- ### Copy and Navigate to Rest-JSON Example Source: https://github.com/apache/camel-quarkus/blob/main/docs/modules/ROOT/pages/user-guide/first-steps.adoc Copy the 'rest-json' example from the cloned repository and navigate into its directory. ```shell cp -r camel-quarkus-examples/rest-json . cd rest-json ``` -------------------------------- ### Verify Examples After Platform Upgrade Source: https://github.com/apache/camel-quarkus/blob/main/docs/modules/ROOT/pages/contributor-guide/release-guide.adoc Run tests on all examples after upgrading the Quarkus Platform version to ensure compatibility. ```shell ./mvnw-for-each.sh clean verify ``` -------------------------------- ### LDAP DirContext Configuration Example with SSL Source: https://github.com/apache/camel-quarkus/blob/main/docs/modules/ROOT/pages/reference/extensions/ldap.adoc Example of configuring a dirContext named 'your_context' for SSL communication. ```properties quarkus.camel.ldap.dir-contexts."your_context".initial-context-factory=com.sun.jndi.ldap.LdapCtxFactory quarkus.camel.ldap.dir-contexts."your_context".provider-url=ldaps://${ldap.host}:${ldap.sslPort} quarkus.camel.ldap.dir-contexts."your_context".security-protocol=ssl quarkus.camel.ldap.dir-contexts."your_context".socket-factory=org.apache.camel.quarkus.component.ldap.it.CustomSSLSocketFactory ``` -------------------------------- ### Simple RouteBuilder Example Source: https://github.com/apache/camel-quarkus/blob/main/docs/modules/ROOT/pages/user-guide/testing.adoc A basic example of a `RouteBuilder` class that can be used for testing. ```java public class MyRoutes extends RouteBuilder { ``` -------------------------------- ### Start Flight Recording with JVM Options (Native Mode) Source: https://github.com/apache/camel-quarkus/blob/main/docs/modules/ROOT/pages/reference/extensions/jfr.adoc Execute the native executable with Java options to enable Flight Recorder and start a recording at application startup in native mode. ```shell ./my-application-runner -XX:+FlightRecorder -XX:StartFlightRecording=filename=recording.jfr ``` -------------------------------- ### Example quarkus-extension.yaml Source: https://github.com/apache/camel-quarkus/blob/main/docs/modules/ROOT/pages/contributor-guide/extension-metadata.adoc This YAML file defines metadata for a Quarkus extension, including its name, description, and relevant guides or categories. It is located in the `src/main/resources/META-INF` directory. ```yaml name: "Camel ActiveMQ" description: "Send messages to (or consume from) Apache ActiveMQ. This component extends the Camel JMS component" metadata: guide: "https://camel.apache.org/camel-quarkus/latest/extensions/activemq.html" categories: - "integration" ``` -------------------------------- ### Start Flight Recording with JVM Options (JVM Mode) Source: https://github.com/apache/camel-quarkus/blob/main/docs/modules/ROOT/pages/reference/extensions/jfr.adoc Execute the application JAR with Java options to enable Flight Recorder and start a recording at application startup in JVM mode. ```shell java -XX:+FlightRecorder -XX:StartFlightRecording=filename=recording.jfr -jar quarkus-run.jar ``` -------------------------------- ### Start Development Mode with Maven Source: https://github.com/apache/camel-quarkus/blob/main/docs/modules/ROOT/pages/user-guide/first-steps.adoc Compiles the project and starts the application in development mode, enabling hot-reloading for code changes. ```shell mvn clean compile quarkus:dev ``` -------------------------------- ### Basic JVM Test Setup with Quarkus Source: https://github.com/apache/camel-quarkus/blob/main/docs/modules/ROOT/pages/user-guide/testing.adoc Use `@QuarkusTest` to bootstrap Quarkus and start Camel routes for JVM mode testing. This annotation enables the use of any suitable code to send test data and assert outcomes. ```java import io.quarkus.test.junit.QuarkusTest; import org.junit.jupiter.api.Test; @QuarkusTest class MyTest { @Test void test() { // Use any suitable code that send test data to the route and then assert outcomes } } ``` -------------------------------- ### Using AdviceWith to Replace Route Start Source: https://github.com/apache/camel-quarkus/blob/main/docs/modules/ROOT/pages/user-guide/testing.adoc Demonstrates using AdviceWith to modify a route during testing, specifically replacing its starting point. ```java @QuarkusTest class SimpleTest extends CamelQuarkusTestSupport { @BeforeEach public void beforeEach() throws Exception { AdviceWith.adviceWith(this.context, "advisedRoute", route -> { route.replaceFromWith("direct:replaced"); }); } @Override protected RoutesBuilder createRouteBuilder() throws Exception { return new RouteBuilder() { @Override public void configure() throws Exception { from("direct:start").routeId("advisedRoute") .transform().simple("Hello ${body}") .to("mock:result"); } }; } @Test void testAdvisedRoute() throws Exception { MockEndpoint mockEndpoint = getMockEndpoint("mock:result"); mockEndpoint.expectedBodiesReceived("Hello World"); template.sendBody("direct:replaced", "World"); mockEndpoint.assertIsSatisfied(); } } ``` -------------------------------- ### Run Partial Documentation Build Source: https://github.com/apache/camel-quarkus/blob/main/docs/README.adoc Builds the current project, integrates it into a local full build, and starts a server for live preview. Rebuilds on file changes and syncs the browser. ```bash ./local-build.sh ``` -------------------------------- ### Configure Infinispan Dev Services and Production Source: https://github.com/apache/camel-quarkus/blob/main/docs/modules/ROOT/pages/reference/extensions/infinispan.adoc Configure Infinispan Dev Services for development/testing and provide example production mode configuration. ```properties # dev / test mode Quarkus Infinispan Dev services configuration quarkus.infinispan-client.devservices.port=31222 %dev,test.camel.component.infinispan.username=admin %dev,test.camel.component.infinispan.password=password %dev,test.camel.component.infinispan.secure=true %dev,test.camel.component.infinispan.hosts=localhost:31222 # Example prod mode configuration %prod.camel.component.infinispan.username=prod-user %prod.camel.component.infinispan.password=prod-password %prod.camel.component.infinispan.secure=true %prod.camel.component.infinispan.hosts=infinispan.prod:11222 ``` -------------------------------- ### Qute Template Example Source: https://github.com/apache/camel-quarkus/blob/main/docs/modules/ROOT/pages/reference/extensions/qute.adoc An example of a Qute template demonstrating how to access headers and the message body. This template can be used with the Qute extension. ```qute Dear {headers.lastName}, {headers.firstName} Thanks for the order of {headers.item}. Regards Camel Riders Bookstore {body} ``` -------------------------------- ### Get Help for Performance Regression Tool Source: https://github.com/apache/camel-quarkus/blob/main/docs/modules/ROOT/pages/contributor-guide/release-guide.adoc Display the help message for the perf-regression tool to understand its available options for customization. ```shell java -jar target/quarkus-app/quarkus-run.jar --help ``` -------------------------------- ### Clone Camel Quarkus Examples Repository Source: https://github.com/apache/camel-quarkus/blob/main/docs/modules/ROOT/pages/user-guide/first-steps.adoc Clone the official Camel Quarkus examples repository to access various sample projects. ```shell git clone https://github.com/apache/camel-quarkus-examples.git ``` -------------------------------- ### Enable Startup Recording via application.properties Source: https://github.com/apache/camel-quarkus/blob/main/docs/modules/ROOT/pages/reference/extensions/jfr.adoc Configure `application.properties` to automatically start a Java Flight Recorder recording and dump it to disk after Camel startup. ```properties quarkus.camel.jfr.startup-recorder-recording=true ``` -------------------------------- ### Create Azure Resources Source: https://github.com/apache/camel-quarkus/blob/main/integration-test-groups/azure/README.adoc Use this script to create necessary Azure resources for testing. Ensure Azure CLI is installed beforehand. ```shell $ ./azure-resources.sh create ``` -------------------------------- ### Initialize MongoDB Replica Set Source: https://github.com/apache/camel-quarkus/blob/main/integration-tests-support/mongodb/src/main/resources/initMongodb.txt Initiates a MongoDB replica set with a single member. This is a basic setup for a replica set. ```javascript rs.initiate( { '_id' : 'my-mongo-set', 'members' : [{ '_id' : 0, 'host' : 'mongodb_private:27017', 'priority': 2}] }); ``` -------------------------------- ### Set New Camel Quarkus Version in Examples Source: https://github.com/apache/camel-quarkus/blob/main/docs/modules/ROOT/pages/contributor-guide/release-guide.adoc Update the Camel Quarkus version across all modules in the examples project and tag the release. ```shell NEW_CQ_VERSION=... # the recent release of Camel Quarkus; e.g. 2.2.0 git checkout main git fetch upstream git reset --hard upstream/main ./mvnw-for-each.sh versions:set versions:update-child-modules -DnewVersion=$NEW_CQ_VERSION # Update version labels in Kubernetes resources ./mvnw-for-each.sh process-sources git add -A git commit -m "Tag $NEW_CQ_VERSION" git tag $NEW_CQ_VERSION git push upstream main git push upstream $NEW_CQ_VERSION ``` -------------------------------- ### Simple Language OGNL Notation Example Source: https://github.com/apache/camel-quarkus/blob/main/docs/modules/ROOT/pages/reference/extensions/core.adoc When using OGNL notation within the simple language, ensure the camel-quarkus-bean extension is included. This example accesses the 'getAddress()' method on the message body. ```java simple("${body.address}") ``` -------------------------------- ### Platform HTTP Proxy Example Source: https://github.com/apache/camel-quarkus/blob/main/docs/modules/ROOT/pages/reference/extensions/platform-http.adoc Configure the Platform HTTP component to act as a reverse proxy, forwarding requests to the origin server based on host headers. ```java from("platform-http:proxy") .toD("http://" + "${headers." + Exchange.HTTP_HOST + "}"); ``` -------------------------------- ### List Pods using Kubernetes Component Source: https://github.com/apache/camel-quarkus/blob/main/docs/modules/ROOT/pages/reference/extensions/kubernetes.adoc Example of listing pods using the kubernetes-pods component. The Kubernetes client is automatically autowired by default. ```java from("direct:pods") .to("kubernetes-pods:local?operation=listPods") ``` -------------------------------- ### Custom XAConnectionFactory for IBM MQ Source: https://github.com/apache/camel-quarkus/blob/main/docs/modules/ROOT/pages/reference/extensions/jms.adoc Example of creating a custom XAConnectionFactory for IBM MQ when a dedicated Quarkus extension is not available. ```java @Produces public ConnectionFactory createXAConnectionFactory(PooledJmsWrapper wrapper) { MQXAConnectionFactory mq = new MQXAConnectionFactory(); try { mq.setHostName(ConfigProvider.getConfig().getValue("ibm.mq.host", String.class)); mq.setPort(ConfigProvider.getConfig().getValue("ibm.mq.port", Integer.class)); ``` -------------------------------- ### Display Performance Regression Report Source: https://github.com/apache/camel-quarkus/blob/main/docs/modules/ROOT/pages/contributor-guide/release-guide.adoc Example output of the performance regression tool, showing version comparison, duration, JVM/Native requests per second, and status. ```shell Camel Quarkus version | Duration | JVM req/s [%increase] | Native req/s [%increase] | Status | --------------------------------------------------------------------------------------------------------- 2.9.0 | 10m | 16127.95 req/s [+0.00%] | 9421.92 req/s [+0.00%] | OK | 2.10.0 | 10m | 15334.57 req/s [-4.92%] | 9044.55 req/s [-4.01%] | OK | ``` -------------------------------- ### Cluster-Aware Timer Route Example Source: https://github.com/apache/camel-quarkus/blob/main/docs/modules/ROOT/pages/reference/extensions/kubernetes-cluster-service.adoc Deploy this route on multiple pods to ensure only a single consumer is active at a time across the cluster for the specified master namespace. This prevents multiple instances from processing the same messages concurrently. ```java from("master:ns:timer:test?period=100") .log("Timer invoked on a single pod at a time"); ``` -------------------------------- ### Re-generate BOMs and Sync Files Source: https://github.com/apache/camel-quarkus/blob/main/docs/modules/ROOT/pages/contributor-guide/release-guide.adoc Use Maven wrapper to clean the project, install artifacts without running tests, and then synchronize files. This ensures dependencies are up-to-date and project files are correctly formatted. ```shell ./mvnw clean install -DskipTests # ^ This will take a couple of minutes because it resolves # every single dependency of every single extension included # in the platform # # double check files are well formatted ./mvnw -Dsync ``` -------------------------------- ### Use OpenAI Chat Completion with Output Class Source: https://github.com/apache/camel-quarkus/blob/main/docs/modules/ROOT/pages/reference/extensions/openai.adoc Example of configuring the OpenAI chat completion endpoint to use a specific output class, ensuring it's registered for reflection in native mode. ```java public class Routes extends RouteBuilder { @Override public void configure() { from("direct:chat") .to("openai:chat-completion?outputClass=" + MyStructuredOutputClass.class.getName()); } } ``` -------------------------------- ### Route Definition for Mock Example Source: https://github.com/apache/camel-quarkus/blob/main/extensions/mock/runtime/src/main/doc/usage.adoc A simple Camel route defined using RouteBuilder, which is used in conjunction with the mock test example. This route forwards messages from 'direct:start' to 'mock:result'. ```java import jakarta.enterprise.context.ApplicationScoped; import org.apache.camel.builder.RouteBuilder; @ApplicationScoped public class MockRoute extends RouteBuilder { @Override public void configure() throws Exception { from("direct:start").to("mock:result"); } } ``` -------------------------------- ### Run Full Documentation Build Source: https://github.com/apache/camel-quarkus/blob/main/docs/README.adoc Build the entire site locally, including your changes. This is a prerequisite for partial builds and shows the site as it would appear after merging. ```bash ./local-build.sh full ``` -------------------------------- ### Native Mode Test Setup with Quarkus Source: https://github.com/apache/camel-quarkus/blob/main/docs/modules/ROOT/pages/user-guide/testing.adoc Extend JVM mode tests using `@QuarkusIntegrationTest` to test your application in native mode. This annotation compiles the application to a native image and starts it for testing. ```java import io.quarkus.test.junit.QuarkusIntegrationTest; @QuarkusIntegrationTest class MyIT extends MyTest { } ``` -------------------------------- ### Run Quick Documentation Build Source: https://github.com/apache/camel-quarkus/blob/main/docs/README.adoc Use this command to build only the current project. Links will point to the published Camel website without a return link. ```bash ./local-build.sh quick ``` -------------------------------- ### Instantiate ProtobufDataFormat with JSON Content Type Source: https://github.com/apache/camel-quarkus/blob/main/docs/modules/ROOT/pages/reference/extensions/protobuf.adoc Example of creating a ProtobufDataFormat instance configured for JSON content type. Note that additional reflection configuration might be required for the generated Builder class. ```java ProtobufDataFormat protobufJsonDataFormat = new ProtobufDataFormat(Person.getDefaultInstance(), ProtobufDataFormat.CONTENT_TYPE_FORMAT_JSON); ``` -------------------------------- ### gRPC Stub Implementation Example Source: https://github.com/apache/camel-quarkus/blob/main/integration-tests/grpc/README.adoc This Java code demonstrates the generated implementation of a gRPC stub, showing how GrpcMethodHandler bridges gRPC calls to the Camel routing engine. It is generated using Maven with specific properties. ```java @Dependent public class PingPongGrpc$PingPongImplBaseQuarkusMethodHandler extends PingPongImplBase implements CamelQuarkusBindableService { private GrpcMethodHandler methodHandler; public void setMethodHandler(GrpcMethodHandler var1) { this.methodHandler = var1; } public StreamObserver pingAsyncAsync(StreamObserver var1) { return this.methodHandler.handleForConsumerStrategy(var1, "pingAsyncAsync"); } public StreamObserver pingAsyncSync(StreamObserver var1) { return this.methodHandler.handleForConsumerStrategy(var1, "pingAsyncSync"); } public void pingSyncAsync(PingRequest var1, StreamObserver var2) { this.methodHandler.handle(var1, var2, "pingSyncAsync"); } public void pingSyncSync(PingRequest var1, StreamObserver var2) { this.methodHandler.handle(var1, var2, "pingSyncSync"); } } ``` -------------------------------- ### Create Test Library on IBM i Source: https://github.com/apache/camel-quarkus/blob/main/integration-tests/jt400/README.adoc Use the 5250 emulator to run this command and create a library for testing purposes on the IBM i server. ```cl CRTLIB LIBRARY ``` -------------------------------- ### Serve Only GET Requests on an Endpoint Source: https://github.com/apache/camel-quarkus/blob/main/docs/modules/ROOT/pages/reference/extensions/platform-http.adoc This Java snippet shows how to restrict an endpoint to only serve GET requests on `/hello`. ```java from("platform-http:/hello?httpMethodRestrict=GET").setBody(simple("Hello ${header.name}")); ``` -------------------------------- ### Execute Maven Release Prepare and Perform Source: https://github.com/apache/camel-quarkus/blob/main/docs/modules/ROOT/pages/contributor-guide/release-guide.adoc Run the Maven release plugin to prepare and perform the release. The `-B` flag enables batch mode. ```shell mvn clean release:clean release:prepare -DreleaseVersion=$VERSION -DdevelopmentVersion=$NEXT_VERSION -B release:perform ``` -------------------------------- ### Verify Native Build and Run Integration Tests Source: https://github.com/apache/camel-quarkus/blob/main/docs/modules/ROOT/pages/contributor-guide/promote-jvm-to-native.adoc After promoting an extension, navigate to its integration test directory and run tests in native mode. This ensures the extension functions correctly when compiled as a native image. ```shell cd integration-tests/foo mvn clean verify -Pnative ``` -------------------------------- ### Example Route with Master and File Cluster Service Source: https://github.com/apache/camel-quarkus/blob/main/docs/modules/ROOT/pages/reference/extensions/file-cluster-service.adoc This Java route demonstrates how to use the 'master' component in conjunction with the file cluster service. Only one consumer will be active at a time across all JVMs using the same master namespace. ```java from("master:ns:timer:test?period=100") .log("Timer invoked on a single JVM at a time"); ``` -------------------------------- ### Upgrade Quarkus Platform Version in Examples Source: https://github.com/apache/camel-quarkus/blob/main/docs/modules/ROOT/pages/contributor-guide/release-guide.adoc Update the Quarkus Platform version used in the Camel Quarkus examples project. This command requires the `cq-maven-plugin`. ```shell NEW_PLATFORM_VERSION=... # E.g. 2.2.0.Final git fetch upstream git checkout camel-quarkus-main git reset --hard upstream/camel-quarkus-main mvn org.l2x6.cq:cq-maven-plugin:2.10.0:examples-set-platform -Dcq.quarkus.platform.version=$NEW_PLATFORM_VERSION ./refresh-dockerfiles.sh git add -A git commit -m "Upgrade to Quarkus Platform $NEW_PLATFORM_VERSION" ``` -------------------------------- ### JOLT Route Example Source: https://github.com/apache/camel-quarkus/blob/main/docs/modules/ROOT/pages/reference/extensions/jolt.adoc Example of a Camel route that uses the JOLT component to transform JSON. The JOLT spec is loaded from a classpath resource named 'defaultr.json'. ```java from("direct:start").to("jolt:defaultr.json"); ``` -------------------------------- ### Set Google Application Credentials and Project ID Source: https://github.com/apache/camel-quarkus/blob/main/integration-tests/google-pubsub/README.adoc Set these environment variables to authenticate with real Google Pubsub. Ensure you have a service account key and the necessary permissions. ```bash export GOOGLE_APPLICATION_CREDENTIALS="/home/user/Downloads/my-key.json" export GOOGLE_PROJECT_ID="#your_project" ``` -------------------------------- ### Run Native Mode Application Source: https://github.com/apache/camel-quarkus/blob/main/docs/modules/ROOT/pages/user-guide/first-steps.adoc Executes the compiled native binary directly. Observe the significantly faster startup time and lower memory consumption. ```shell ./target/*-runner ``` -------------------------------- ### Full Build Command Source: https://github.com/apache/camel-quarkus/blob/main/AGENTS.md Performs a complete build, including running all JVM unit tests. This ensures code correctness and integration. ```bash ./mvnw clean install ``` -------------------------------- ### Serve All HTTP Methods on an Endpoint Source: https://github.com/apache/camel-quarkus/blob/main/docs/modules/ROOT/pages/reference/extensions/platform-http.adoc This Java snippet demonstrates how to serve all HTTP methods on the `/hello` endpoint using the Platform HTTP component. ```java from("platform-http:/hello").setBody(simple("Hello ${header.name}")); ``` -------------------------------- ### Producing a Named CDI Bean Source: https://github.com/apache/camel-quarkus/blob/main/docs/modules/ROOT/pages/user-guide/testing.adoc Example of producing a named CDI bean that can be bound to the Camel registry. ```java public class MyBeanProducers { @Produces @Named("myBean") public MyBean createMyBean() { return new MyBean(); } } ``` -------------------------------- ### Configure TransformerFactory Features Source: https://github.com/apache/camel-quarkus/blob/main/docs/modules/ROOT/pages/reference/extensions/xslt.adoc Configure TransformerFactory features using the `quarkus.camel.xslt.features` property. For example, disabling secure processing. ```properties quarkus.camel.xslt.features."http\://javax.xml.XMLConstants/feature/secure-processing"=false ``` -------------------------------- ### Initialize MongoDB Replica Set Source: https://github.com/apache/camel-quarkus/blob/main/integration-test-groups/debezium/mongodb/src/test/resources/initMongodb.txt Initiates a MongoDB replica set configuration. Replace '%container-host%' with the actual hostname or IP address of the MongoDB container. ```javascript rs.initiate( { '_id' : 'my-mongo-set', 'members' : [{ '_id' : 0, 'host' : '%container-host%', 'priority': 2}] }); ``` -------------------------------- ### Inject DataSource in Camel Route Source: https://github.com/apache/camel-quarkus/blob/main/docs/modules/ROOT/pages/reference/extensions/pgevent.adoc Example of injecting a named DataSource ('pgDatasource') into a Camel Route for the pgevent component. ```java pgevent:///postgres/testchannel?datasource=#pgDatasource ``` -------------------------------- ### Run Native Executable Source: https://github.com/apache/camel-quarkus/blob/main/docs/modules/ROOT/pages/user-guide/command-mode.adoc Execute the compiled native application. You can pass properties like 'greeted.subject' to customize its behavior. ```shell $ target/*runner -Dgreeted.subject=Joe 2020-07-15 12:19:22,810 INFO [org.apa.cam.qua.cor.CamelBootstrapRecorder] (main) bootstrap runtime: org.apache.camel.quarkus.main.CamelMainRuntime 2020-07-15 12:19:22,811 INFO [org.apa.cam.mai.BaseMainSupport] (main) Auto-configuration summary: 2020-07-15 12:19:22,811 INFO [org.apa.cam.mai.BaseMainSupport] (main) camel.main.durationMaxMessages=1 2020-07-15 12:19:22,812 INFO [org.apa.cam.imp.eng.AbstractCamelContext] (main) Apache Camel 3.4.0 (camel-1) is starting 2020-07-15 12:19:22,812 INFO [org.apa.cam.imp.eng.AbstractCamelContext] (main) StreamCaching is not in use. If using streams then its recommended to enable stream caching. See more details at https://camel.apache.org/stream-caching.html 2020-07-15 12:19:22,812 INFO [org.apa.cam.imp.eng.InternalRouteStartupManager] (main) Route: route1 started and consuming from: timer://hello 2020-07-15 12:19:22,812 INFO [org.apa.cam.imp.eng.AbstractCamelContext] (main) Total 1 routes, of which 1 are started 2020-07-15 12:19:22,812 INFO [org.apa.cam.imp.eng.AbstractCamelContext] (main) Apache Camel 3.4.0 (camel-1) started in 0.000 seconds 2020-07-15 12:19:22,812 INFO [io.quarkus] (main) camel-quarkus-integration-test-main-command-mode 1.1.0-SNAPSHOT native (powered by Quarkus 1.6.0.Final) started in 0.007s. 2020-07-15 12:19:22,813 INFO [io.quarkus] (main) Profile prod activated. 2020-07-15 12:19:22,812 INFO [hello] (Camel (camel-1) thread #0 - timer://hello) Exchange[ExchangePattern: InOnly, BodyType: String, Body: Hello Joe!] 2020-07-15 12:19:22,813 INFO [io.quarkus] (main) Installed features: [camel-core, camel-log, camel-main, camel-policy, camel-support-common, camel-timer, cdi] 2020-07-15 12:19:22,813 INFO [org.apa.cam.mai.MainSupport] (camel-main) Waiting until: 1 messages has been processed 2020-07-15 12:19:22,813 INFO [org.apa.cam.mai.MainLifecycleStrategy] (Camel (camel-1) thread #0 - timer://hello) Duration max messages triggering shutdown of the JVM. 2020-07-15 12:19:22,813 INFO [org.apa.cam.imp.eng.AbstractCamelContext] (Camel (camel-1) thread #1 - CamelMainShutdownCamelContext) Apache Camel 3.4.0 (camel-1) is shutting down 2020-07-15 12:19:22,813 INFO [org.apa.cam.mai.MainLifecycleStrategy] (Camel (camel-1) thread #1 - CamelMainShutdownCamelContext) CamelContext: camel-1 has been shutdown, triggering shutdown of the JVM. 2020-07-15 12:19:22,813 INFO [org.apa.cam.imp.eng.AbstractCamelContext] (Camel (camel-1) thread #1 - CamelMainShutdownCamelContext) Apache Camel 3.4.0 (camel-1) uptime 0.001 seconds 2020-07-15 12:19:22,813 INFO [org.apa.cam.imp.eng.AbstractCamelContext] (Camel (camel-1) thread #1 - CamelMainShutdownCamelContext) Apache Camel 3.4.0 (camel-1) is shutdown in 0.000 seconds 2020-07-15 12:19:22,813 INFO [io.quarkus] (main) camel-quarkus-integration-test-main-command-mode stopped in 0.000s ``` -------------------------------- ### Native Build with Docker Command Source: https://github.com/apache/camel-quarkus/blob/main/AGENTS.md Builds the project for native execution and runs native integration tests. Requires Docker and can be very time-consuming. ```bash ./mvnw clean install -Dnative -Ddocker ``` -------------------------------- ### Exclude Route Patterns from Tracing Source: https://github.com/apache/camel-quarkus/blob/main/extensions/opentelemetry2/runtime/src/main/doc/usage.adoc Configure route patterns to be excluded from tracing in application.properties. This example excludes all direct and netty-http endpoints. ```properties # Exclude all direct & netty-http endpoints from tracing quarkus.camel.opentelemetry2.exclude-patterns=direct:*,netty-http:* ``` -------------------------------- ### Using JSONata Component in Camel Route Source: https://github.com/apache/camel-quarkus/blob/main/extensions/jsonata/runtime/src/main/doc/configuration.adoc Example of how to use the JSONata component within a Camel route to process JSONata expressions. ```java from("direct:start").to("jsonata:spec/expressions.spec"); ``` -------------------------------- ### Format Code and Rebuild Project Source: https://github.com/apache/camel-quarkus/blob/main/docs/modules/ROOT/pages/contributor-guide/promote-jvm-to-native.adoc After making changes and ensuring tests pass, format the entire project's source files and perform a full rebuild, skipping tests. This step ensures code consistency and prepares the project for installation. ```shell mvn clean install -DskipTests -Pformat ``` -------------------------------- ### Promote JVM Extension using cq:promote Mojo Source: https://github.com/apache/camel-quarkus/blob/main/docs/modules/ROOT/pages/contributor-guide/promote-jvm-to-native.adoc Use this command to automate the initial steps of promoting a JVM extension to native. Ensure you are in the `camel-quarkus` directory and set `cq.artifactIdBase` to the unique part of your extension's artifact ID. ```shell cd camel-quarkus mvn -N cq:promote -Dcq.artifactIdBase=... ``` -------------------------------- ### Define Test-Specific Routes Source: https://github.com/apache/camel-quarkus/blob/main/docs/modules/ROOT/pages/user-guide/testing.adoc Override `createRouteBuilder` to define routes specifically for your tests. This example demonstrates setting up a simple route with a mock endpoint. ```java @QuarkusTest class SimpleTest extends CamelQuarkusTestSupport { @Test void testGreeting() { MockEndpoint mockEndpoint = getMockEndpoint("mock:result"); mockEndpoint.expectedBodiesReceived("Hello World"); template.sendBody("direct:start", "World"); mockEndpoint.assertIsSatisfied(); } @Override protected RoutesBuilder createRouteBuilder() throws Exception { return new RouteBuilder() { @Override public void configure() throws Exception { from("direct:start") .transform().simple("Hello ${body}") .to("mock:result"); } }; } } ``` -------------------------------- ### Include Resources for Native Mode Source: https://github.com/apache/camel-quarkus/blob/main/extensions/grpc/runtime/src/main/doc/usage.adoc Configure `application.properties` to include necessary resources, such as SSL/TLS keys and certificates, in the native executable. ```properties quarkus.native.resources.includes = certs/*.pem,certs.*.key ``` -------------------------------- ### Fast Build Command Source: https://github.com/apache/camel-quarkus/blob/main/AGENTS.md Use this command for a quick build without running tests. It's useful for rapid development cycles. ```bash ./mvnw clean install -Dquickly ``` -------------------------------- ### Configure Agroal Datasource Properties Source: https://github.com/apache/camel-quarkus/blob/main/docs/modules/ROOT/pages/reference/extensions/pgevent.adoc Set Agroal properties for a named DataSource, such as 'pgDatasource'. This example configures connection details for a PostgreSQL database. ```properties quarkus.datasource.pgDatasource.db-kind=pgsql quarkus.datasource.pgDatasource.jdbc.url=jdbc:pgsql://localhost:5432/myDB quarkus.datasource.pgDatasource.username=postgres quarkus.datasource.pgDatasource.password=mysecretpassword quarkus.datasource.pgDatasource.jdbc.max-size=16 ``` -------------------------------- ### Camel Quarkus Platform HTTP and Jackson Dependencies Source: https://github.com/apache/camel-quarkus/blob/main/docs/modules/ROOT/pages/user-guide/first-steps.adoc Example dependencies for Camel Quarkus applications, including platform-http and jackson. These are managed by the io.quarkus.platform:quarkus-camel-bom. ```xml org.apache.camel.quarkus camel-quarkus-platform-http org.apache.camel.quarkus camel-quarkus-jackson ``` -------------------------------- ### Use OpenAI Chat Completion with JSON Schema Source: https://github.com/apache/camel-quarkus/blob/main/docs/modules/ROOT/pages/reference/extensions/openai.adoc Example of configuring the OpenAI chat completion endpoint to use a JSON schema resource from the classpath. ```java public class Routes extends RouteBuilder { @Override public void configure() { from("direct:chat") .to("openai:chat-completion?jsonSchema=resource:classpath:schemas/mySchema.json"); } } ``` -------------------------------- ### Accept MS SQL Server EULA Source: https://github.com/apache/camel-quarkus/blob/main/integration-tests/debezium-grouped/README.adoc To run MS SQL Server integration tests, create a file named 'container-license-acceptance.txt' with the specified image name to indicate EULA acceptance. ```shell echo "mcr.microsoft.com/mssql/server:2022-latest" > integration-tests/debezium-grouped/src/test/resources/container-license-acceptance.txt ``` -------------------------------- ### Rest DSL Definition in YAML Source: https://github.com/apache/camel-quarkus/blob/main/docs/modules/ROOT/pages/user-guide/defining-camel-routes.adoc Defines a REST endpoint with a GET method that triggers a direct route. This is useful for creating RESTful services with Camel. ```yaml - rest: get: - path: "/greeting" to: "direct:greet" - route: id: "rest-route" from: uri: "direct:greet" steps: - set-body: constant: "Hello YAML!" ``` -------------------------------- ### XML DSL Rest Definition Source: https://github.com/apache/camel-quarkus/blob/main/docs/modules/ROOT/pages/user-guide/defining-camel-routes.adoc Defines a REST service using XML DSL, specifying a path and a GET method that routes to a direct endpoint. ```xml ``` -------------------------------- ### Promote Extension to Native Mode Support Source: https://github.com/apache/camel-quarkus/blob/main/AGENTS.md Use this command to promote an extension from JVM-only support to native mode support by specifying the base artifact ID. ```bash ./mvnw -N cq:promote -Dcq.artifactIdBase=kafka ``` -------------------------------- ### Programmatic Component Configuration Source: https://context7.com/apache/camel-quarkus/llms.txt Observe `ComponentAddEvent` to programmatically configure Camel components before routes and `CamelContext` start. This is the recommended approach over `@Named` producer methods. ```APIDOC ## Component Configuration via CDI Observer (ComponentAddEvent) Observe `ComponentAddEvent` to programmatically configure a Camel component before routes and `CamelContext` start. This is the recommended approach over `@Named` producer methods. ```java import jakarta.enterprise.context.ApplicationScoped; import jakarta.enterprise.event.Observes; import org.apache.camel.quarkus.core.events.ComponentAddEvent; import org.apache.camel.component.log.LogComponent; import org.apache.camel.component.kafka.KafkaComponent; import org.apache.camel.support.processor.DefaultExchangeFormatter; @ApplicationScoped public class ComponentConfigurer { public void onComponentAdd(@Observes ComponentAddEvent event) { if (event.getComponent() instanceof LogComponent logComponent) { DefaultExchangeFormatter formatter = new DefaultExchangeFormatter(); formatter.setShowExchangePattern(false); formatter.setShowBodyType(false); formatter.setShowHeaders(true); logComponent.setExchangeFormatter(formatter); } if (event.getComponent() instanceof KafkaComponent kafkaComponent) { kafkaComponent.getConfiguration().setBrokers("kafka-broker:9092"); kafkaComponent.getConfiguration().setGroupId("my-app-group"); } } } ``` ``` -------------------------------- ### Compile to Native Executable Source: https://github.com/apache/camel-quarkus/blob/main/docs/modules/ROOT/pages/user-guide/command-mode.adoc Activate the 'native' profile to compile your Camel Quarkus application into a native executable. Ensure GraalVM is installed and GRAALVM_HOME is set. ```shell export GRAALVM_HOME=... Mvn clean package -Pnative ``` -------------------------------- ### Loading Simple Scripts from Classpath Source: https://github.com/apache/camel-quarkus/blob/main/extensions-core/core/runtime/src/main/doc/configuration.adoc Load Simple scripts from the classpath. In native mode, include the resource file using the `quarkus.native.resources.includes` property. ```java from("direct:start").transform().simple("resource:classpath:mysimple.txt"); ``` ```properties quarkus.native.resources.includes = mysimple.txt ``` -------------------------------- ### Package Application for JVM Mode Source: https://github.com/apache/camel-quarkus/blob/main/docs/modules/ROOT/pages/user-guide/first-steps.adoc Prepares a thin JAR file for running the application on a standard JVM. ```shell mvn clean package ``` -------------------------------- ### Configure Quartz Clustering with JDBC Job Store Source: https://github.com/apache/camel-quarkus/blob/main/docs/modules/ROOT/pages/reference/extensions/quartz.adoc Enable Quartz clustered mode and configure a DataSource for JDBC job persistence. This example uses PostgreSQL. ```properties # Quartz configuration quarkus.quartz.clustered=true quarkus.quartz.store-type=jdbc-cmt quarkus.scheduler.start-mode=forced # Datasource configuration quarkus.datasource.db-kind=postgresql quarkus.datasource.username=quarkus_test quarkus.datasource.password=quarkus_test quarkus.datasource.jdbc.url=jdbc:postgresql://localhost/quarkus_test # Optional automatic creation of Quartz tables quarkus.flyway.connect-retries=10 quarkus.flyway.table=flyway_quarkus_history quarkus.flyway.migrate-at-start=true quarkus.flyway.baseline-on-migrate=true quarkus.flyway.baseline-version=1.0 quarkus.flyway.baseline-description=Quartz ``` -------------------------------- ### Load Mustache Template from Classpath Source: https://github.com/apache/camel-quarkus/blob/main/docs/modules/ROOT/pages/reference/extensions/mustache.adoc Example route that loads a Mustache template from the classpath. Ensure the template is included in the native executable if running in native mode. ```java from("direct:start").to("mustache://template/simple.mustache"); ``` -------------------------------- ### Use JSLT Component in a Route Source: https://github.com/apache/camel-quarkus/blob/main/docs/modules/ROOT/pages/reference/extensions/jslt.adoc Example of using the JSLT component in a Camel route to transform a payload using a JSLT template located at `transformation.json` on the classpath. ```java from("direct:start").to("jslt:transformation.json"); ``` -------------------------------- ### Create Release Branch from Main Source: https://github.com/apache/camel-quarkus/blob/main/docs/modules/ROOT/pages/contributor-guide/release-guide.adoc Fetch upstream changes, checkout the main branch, reset to the latest upstream main, and create a new release branch. ```shell git fetch upstream # upstream is git@github.com:apache/camel-quarkus.git git checkout main # main is the branch from which you want to release git reset --hard upstream/main # make sure you are in sync with upstream git checkout -b $BRANCH ``` -------------------------------- ### Configure JSON Schema Loading in Native Mode Source: https://github.com/apache/camel-quarkus/blob/main/docs/modules/ROOT/pages/reference/extensions/json-validator.adoc Embed schema files in the native executable using the `quarkus.native.resources.includes` property in `application.properties`. This example includes `schema.json`. ```properties quarkus.native.resources.includes = schema.json ``` -------------------------------- ### Execute Command-Line Application Source: https://github.com/apache/camel-quarkus/blob/main/docs/modules/ROOT/pages/user-guide/command-mode.adoc This shell command demonstrates how to run a packaged Camel Quarkus application as a command-line tool. The output shows the application startup and the log message from the route. ```shell ]$ java -jar target/*-runner.jar 2020-07-15 11:32:13,577 INFO [org.apa.cam.qua.cor.CamelBootstrapRecorder] (main) bootstrap runtime: org.apache.camel.quarkus.main.CamelMainRuntime 2020-07-15 11:32:13,623 INFO [org.apa.cam.mai.BaseMainSupport] (main) Auto-configuration summary: 2020-07-15 11:32:13,623 INFO [org.apa.cam.mai.BaseMainSupport] (main) camel.main.durationMaxMessages=1 2020-07-15 11:32:13,700 INFO [org.apa.cam.imp.eng.AbstractCamelContext] (main) Apache Camel 3.4.0 (camel-1) is starting 2020-07-15 11:32:13,701 INFO [org.apa.cam.imp.eng.AbstractCamelContext] (main) StreamCaching is not in use. If using streams then its recommended to enable stream caching. See more details at https://camel.apache.org/stream-caching.html 2020-07-15 11:32:13,709 INFO [org.apa.cam.imp.eng.InternalRouteStartupManager] (main) Route: route1 started and consuming from: timer://hello 2020-07-15 11:32:13,714 INFO [org.apa.cam.imp.eng.AbstractCamelContext] (main) Total 1 routes, of which 1 are started 2020-07-15 11:32:13,715 INFO [org.apa.cam.imp.eng.AbstractCamelContext] (main) Apache Camel 3.4.0 (camel-1) started in 0.014 seconds 2020-07-15 11:32:13,718 INFO [org.apa.cam.mai.MainSupport] (camel-main) Waiting until: 1 messages has been processed 2020-07-15 11:32:13,719 INFO [io.quarkus] (main) camel-quarkus-integration-test-main-command-mode 1.1.0-SNAPSHOT on JVM (powered by Quarkus 1.6.0.Final) started in 0.592s. 2020-07-15 11:32:13,720 INFO [io.quarkus] (main) Profile prod activated. 2020-07-15 11:32:13,721 INFO [io.quarkus] (main) Installed features: [camel-core, camel-log, camel-main, camel-policy, camel-support-common, camel-timer, cdi] 2020-07-15 11:32:13,725 INFO [hello] (Camel (camel-1) thread #0 - timer://hello) Exchange[ExchangePattern: InOnly, BodyType: String, Body: Hello World!] ``` -------------------------------- ### Compile Rust WASM Functions Source: https://github.com/apache/camel-quarkus/blob/main/integration-tests/wasm/README.adoc Navigate to the Rust directory and execute the build script to compile the functions.wasm file. Ensure the Rust toolchain is installed first. ```shell cd rust ./build.sh ``` -------------------------------- ### JQ Transformation to Custom Result Type Source: https://github.com/apache/camel-quarkus/blob/main/docs/modules/ROOT/pages/reference/extensions/jq.adoc Example of using the .jq() transform to specify a custom result class (Book.class) for JQ transformations within a Camel route. ```java public class MyJQRoutes extends RouteBuilder { @Override public void configure() { from("direct:jq") .transform().jq(".book", Book.class); } } ``` -------------------------------- ### Run JVM Mode Application Source: https://github.com/apache/camel-quarkus/blob/main/docs/modules/ROOT/pages/user-guide/first-steps.adoc Executes the packaged JAR file on a JVM. Note the fast boot time. ```shell java -jar target/quarkus-app/quarkus-run.jar ``` -------------------------------- ### Stop Route using Simple Language and ProducerTemplate Source: https://github.com/apache/camel-quarkus/blob/main/docs/modules/ROOT/pages/reference/extensions/controlbus.adoc This example uses a ProducerTemplate to stop a route with the id 'foo' via the control bus using the Simple language. ```java template.sendBody( "controlbus:language:simple", "${camelContext.getRouteController().stopRoute('foo')}" ); ``` -------------------------------- ### Minimal Servlet Configuration Source: https://github.com/apache/camel-quarkus/blob/main/docs/modules/ROOT/pages/reference/extensions/servlet.adoc Configure the Servlet extension with minimal properties by defining URL patterns. A corresponding Camel route is also shown. ```properties quarkus.camel.servlet.url-patterns = /* ``` ```java from("servlet://greet") .setBody().constant("Hello World"); ``` -------------------------------- ### YAML DSL Exception Handling with throw-exception Source: https://github.com/apache/camel-quarkus/blob/main/docs/modules/ROOT/pages/reference/extensions/yaml-dsl.adoc Example of throwing a custom exception in Camel YAML DSL using the 'throw-exception' step. The 'ForcedException' class must be registered for reflection. ```yaml - route: id: "my-yaml-route" from: uri: "direct:start" steps: - choice: when: - simple: "${body} == 'bad value'" steps: - throw-exception: exception-type: "org.acme.ForcedException" message: "Forced exception" otherwise: steps: - to: "log:end" ``` -------------------------------- ### Set Slack Environment Variables Source: https://github.com/apache/camel-quarkus/blob/main/integration-tests/slack/README.adoc Configure these environment variables to connect to the Slack API. Replace placeholders with your actual credentials and URLs. ```shell export SLACK_TOKEN=your-slack-token export SLACK_SERVER_URL=https://slack.com export SLACK_WEBHOOK_URL=https://hooks.slack.com/services/some/webhook/path ```