이 콘텐츠는 선택한 언어로 제공되지 않습니다.
Getting Started with Red Hat build of Apache Camel for Spring Boot
Abstract
Preface 링크 복사링크가 클립보드에 복사되었습니다!
Making open source more inclusive
Red Hat is committed to replacing problematic language in our code, documentation, and web properties. We are beginning with these four terms: master, slave, blacklist, and whitelist. Because of the enormity of this endeavor, these changes will be implemented gradually over several upcoming releases. For more details, see our CTO Chris Wright’s message.
Chapter 1. Getting Started with Red Hat build of Apache Camel for Spring Boot 링크 복사링크가 클립보드에 복사되었습니다!
This guide introduces Red Hat build of Apache Camel for Spring Boot and demonstrates how to get started building an application using Red Hat build of Apache Camel for Spring Boot:
- Section 1.1, “Red Hat build of Apache Camel for Spring Boot starters”
- Section 1.2, “Spring Boot”
- Section 1.3, “Component Starters”
- Section 1.4, “Starter Configuration”
- Section 1.5, “Generating a Camel for Spring Boot application using Maven”
- Section 1.7, “Applying patch to Red Hat build of Apache Camel for Spring Boot”
- Section 1.8, “Camel REST DSL OpenApi Maven Plugin”
- Section 1.9, “Support for FIPS Compliance”
1.1. Red Hat build of Apache Camel for Spring Boot starters 링크 복사링크가 클립보드에 복사되었습니다!
Camel support for Spring Boot provides auto-configuration of the Camel and starters for many Camel components. The opinionated auto-configuration of the Camel context auto-detects Camel routes available in the Spring context and registers the key Camel utilities (such as producer template, consumer template and the type converter) as beans.
For information about using a Maven archtype to generate a Camel for Spring Boot application see Generating a Camel for Spring Boot application using Maven.
To get started, you must add the Camel Spring Boot BOM to your Maven pom.xml file.
The camel-spring-boot-bom is a basic BOM that contains the list of Camel Spring Boot starter JARs.
Next, add the Camel Spring Boot starter to startup the Camel Context.
You must also add the component starters that your Spring Boot application requires. The following example shows how to add the auto-configuration starter to the MQTT5 component.
1.1.1. Camel Spring Boot BOM vs Camel Spring Boot Dependencies BOM 링크 복사링크가 클립보드에 복사되었습니다!
The curated camel-spring-boot-dependencies BOM, which is generated, contains the adjusted JARs that both Spring Boot and Apache Camel use to avoid any conflicts. This BOM is used to test camel-spring-boot itself.
Spring Boot users may choose to use pure Camel dependencies by using the camel-spring-boot-bom that only has the Camel starter JARs as managed dependencies. However, this may lead to a classpath conflict if a third-party JAR from Spring Boot is not compatible with a particular Camel component.
1.1.2. Spring Boot configuration support 링크 복사링크가 클립보드에 복사되었습니다!
Each starter lists configuration parameters you can configure in the standard application.properties or application.yml files. These parameters have the form of camel.component.[component-name].[parameter]. For example to configure the URL of the MQTT5 broker you can set:
camel.component.paho-mqtt5.broker-url=tcp://localhost:61616
camel.component.paho-mqtt5.broker-url=tcp://localhost:61616
1.1.3. Adding Camel routes 링크 복사링크가 클립보드에 복사되었습니다!
Camel routes are detected in the Spring application context, for example a route annotated with org.springframework.stereotype.Component will be loaded, added to the Camel context and run.
1.2. Spring Boot 링크 복사링크가 클립보드에 복사되었습니다!
Spring Boot automatically configures Camel for you. The opinionated auto-configuration of the Camel context auto-detects Camel routes available in the Spring context and registers the key Camel utilities (like producer template, consumer template and the type converter) as beans.
Maven users will need to add the following dependency to their pom.xml in order to use this component:
<dependency>
<groupId>org.apache.camel.springboot</groupId>
<artifactId>camel-spring-boot</artifactId>
<version>4.0.0.redhat-00045</version> <!-- use the same version as your Camel core version -->
</dependency>
<dependency>
<groupId>org.apache.camel.springboot</groupId>
<artifactId>camel-spring-boot</artifactId>
<version>4.0.0.redhat-00045</version> <!-- use the same version as your Camel core version -->
</dependency>
camel-spring-boot jar comes with the spring.factories file, so as soon as you add that dependency into your classpath, Spring Boot will automatically auto-configure Camel for you.
1.2.1. Camel Spring Boot Starter 링크 복사링크가 클립보드에 복사되었습니다!
Apache Camel ships a Spring Boot Starter module that allows you to develop Spring Boot applications using starters. There is a sample application in the source code also.
To use the starter, add the following to your spring boot pom.xml file:
<dependency>
<groupId>org.apache.camel.springboot</groupId>
<artifactId>camel-spring-boot-bom</artifactId>
<version>4.0.0.redhat-00045</version> <!-- use the same version as your Camel core version -->
</dependency>
<dependency>
<groupId>org.apache.camel.springboot</groupId>
<artifactId>camel-spring-boot-bom</artifactId>
<version>4.0.0.redhat-00045</version> <!-- use the same version as your Camel core version -->
</dependency>
Then you can just add classes with your Camel routes such as:
Then these routes will be started automatically.
You can customize the Camel application in the application.properties or application.yml file.
1.2.2. Spring Boot Auto-configuration 링크 복사링크가 클립보드에 복사되었습니다!
When using spring-boot with Spring Boot make sure to use the following Maven dependency to have support for auto configuration:
<dependency> <groupId>org.apache.camel.springboot</groupId> <artifactId>camel-spring-boot-starter</artifactId> <version>4.0.0.redhat-00045</version> <!-- use the same version as your Camel core version --> </dependency>
<dependency>
<groupId>org.apache.camel.springboot</groupId>
<artifactId>camel-spring-boot-starter</artifactId>
<version>4.0.0.redhat-00045</version> <!-- use the same version as your Camel core version -->
</dependency>
1.2.3. Auto-configured Camel context 링크 복사링크가 클립보드에 복사되었습니다!
The most important piece of functionality provided by the Camel auto-configuration is the CamelContext instance. Camel auto-configuration creates a SpringCamelContext for you and takes care of the proper initialization and shutdown of that context. The created Camel context is also registered in the Spring application context (under the camelContext bean name), so you can access it like any other Spring bean.
1.2.4. Auto-detecting Camel routes 링크 복사링크가 클립보드에 복사되었습니다!
Camel auto-configuration collects all the RouteBuilder instances from the Spring context and automatically injects them into the provided CamelContext. This means that creating new Camel routes with the Spring Boot starter is as simple as adding the @Component annotated class to your classpath:
Or creating a new route RouteBuilder bean in your @Configuration class:
1.2.5. Camel properties 링크 복사링크가 클립보드에 복사되었습니다!
Spring Boot auto-configuration automatically connects to Spring Boot external configuration (which may contain properties placeholders, OS environment variables or system properties) with the Camel properties support. It basically means that any property defined in application.properties file:
route.from = jms:invoices
route.from = jms:invoices
Or set via system property:
java -Droute.to=jms:processed.invoices -jar mySpringApp.jar
java -Droute.to=jms:processed.invoices -jar mySpringApp.jar
can be used as placeholders in Camel route:
1.2.6. Custom Camel context configuration 링크 복사링크가 클립보드에 복사되었습니다!
If you want to perform some operations on CamelContext bean created by Camel auto-configuration, register CamelContextConfiguration instance in your Spring context:
The method beforeApplicationStart will be called just before the Spring context is started, so the CamelContext instance passed to this callback is fully auto-configured. If you add multiple instances of CamelContextConfiguration into your Spring context, each instance is executed.
1.2.7. Auto-configured consumer and producer templates 링크 복사링크가 클립보드에 복사되었습니다!
Camel auto-configuration provides pre-configured ConsumerTemplate and ProducerTemplate instances. You can simply inject them into your Spring-managed beans:
By default, consumer templates and producer templates come with the endpoint cache sizes set to 1000. You can change these values by modifying the following Spring properties:
camel.springboot.consumer-template-cache-size = 100 camel.springboot.producer-template-cache-size = 200
camel.springboot.consumer-template-cache-size = 100
camel.springboot.producer-template-cache-size = 200
1.2.8. Auto-configured TypeConverter 링크 복사링크가 클립보드에 복사되었습니다!
Camel auto-configuration registers a TypeConverter instance named typeConverter in the Spring context.
1.2.8.1. Spring type conversion API bridge 링크 복사링크가 클립보드에 복사되었습니다!
Spring comes with the powerful type conversion API. The Spring API is similar to the Camel type converter API. As both APIs are so similar, Camel Spring Boot automatically registers a bridge converter (SpringTypeConverter) that delegates to the Spring conversion API. This means that out-of-the-box Camel will treat Spring Converters like Camel ones. With this approach you can use both Camel and Spring converters accessed via Camel TypeConverter API:
Under the hood Camel Spring Boot delegates conversion to the Spring’s ConversionService instances available in the application context. If no ConversionService instance is available, Camel Spring Boot auto-configuration will create one for you.
1.2.9. Keeping the application alive 링크 복사링크가 클립보드에 복사되었습니다!
Camel applications which have this feature enabled launch a new thread on startup for the sole purpose of keeping the application alive by preventing JVM termination. This means that after you start a Camel application with Spring Boot, your application waits for a Ctrl+C signal and does not exit immediately.
The controller thread can be activated using the camel.springboot.main-run-controller to true.
camel.springboot.main-run-controller = true
camel.springboot.main-run-controller = true
Applications using web modules (for example, applications that import the org.springframework.boot:spring-boot-web-starter module), usually don’t need to use this feature because the application is kept alive by the presence of other non-daemon threads.
1.2.10. Adding XML routes 링크 복사링크가 클립보드에 복사되었습니다!
By default, you can put Camel XML routes in the classpath under the directory camel, which camel-spring-boot will auto-detect and include. You can configure the directory name or turn this off using the configuration option:
turn off
# turn off
camel.springboot.routes-include-pattern = false
scan only in the com/foo/routes classpath
# scan only in the com/foo/routes classpath
camel.springboot.routes-include-pattern = classpath:com/foo/routes/*.xml
The XML files should be Camel XML routes (not <CamelContext>) such as:
1.2.11. Testing the JUnit 5 way 링크 복사링크가 클립보드에 복사되었습니다!
For testing, Maven users will need to add the following dependencies to their pom.xml:
To test a Camel Spring Boot application, annotate your test class(es) with @CamelSpringBootTest. This brings Camel’s Spring Test support to your application, so that you can write tests using Spring Boot test conventions.
To get the CamelContext or ProducerTemplate, you can inject them into the class in the normal Spring manner, using @Autowired.
You can also use camel-test-spring-junit5 to configure tests declaratively. This example uses the @MockEndpoints annotation to auto-mock an endpoint:
1.3. Component Starters 링크 복사링크가 클립보드에 복사되었습니다!
Camel Spring Boot supports the following Camel artifacts as Spring Boot Starters:
| Component | Artifact | Description |
|---|---|---|
| camel-amqp-starter | Messaging with AMQP protocol using Apache QPid Client. | |
| camel-aws2-cw-starter | Sending metrics to AWS CloudWatch using AWS SDK version 2.x. | |
| camel-aws2-ddb-starter | Store and retrieve data from AWS DynamoDB service using AWS SDK version 2.x. | |
| camel-aws2-kinesis-starter | Consume and produce records from and to AWS Kinesis Streams using AWS SDK version 2.x. | |
| camel-aws2-lambda-starter | Manage and invoke AWS Lambda functions using AWS SDK version 2.x. | |
| camel-aws2-s3-starter | Store and retrieve objects from AWS S3 Storage Service using AWS SDK version 2.x. | |
| camel-aws2-sns-starter | Send messages to an AWS Simple Notification Topic using AWS SDK version 2.x. | |
| camel-aws2-sqs-starter | Send and receive messages to/from AWS SQS service using AWS SDK version 2.x. | |
| camel-azure-servicebus-starter | Send and receive messages to/from Azure Event Bus. | |
| camel-azure-storage-blob-starter | Store and retrieve blobs from Azure Storage Blob Service using SDK v12. | |
| camel-azure-storage-queue-starter | The azure-storage-queue component is used for storing and retrieving the messages to/from Azure Storage Queue using Azure SDK v12. | |
| camel-bean-starter | Invoke methods of Java beans stored in Camel registry. | |
| camel-bean-validator-starter | Validate the message body using the Java Bean Validation API. | |
| camel-browse-starter | Inspect the messages received on endpoints supporting BrowsableEndpoint. | |
| camel-cassandraql-starter | Integrate with Cassandra 2.0 using the CQL3 API (not the Thrift API). Based on Cassandra Java Driver provided by DataStax. | |
| camel-controlbus-starter | Manage and monitor Camel routes. | |
| camel-cron-starter | A generic interface for triggering events at times specified through the Unix cron syntax. | |
| camel-crypto-starter | Sign and verify exchanges using the Signature Service of the Java Cryptographic Extension (JCE). | |
| camel-cxf-soap-starter | Expose SOAP WebServices using Apache CXF or connect to external WebServices using CXF WS client. | |
| camel-dataformat-starter | Use a Camel Data Format as a regular Camel Component. | |
| camel-dataset-starter | Provide data for load and soak testing of your Camel application. | |
| camel-direct-starter | Call another endpoint from the same Camel Context synchronously. | |
| camel-elasticsearch-starter | Send requests to ElasticSearch via Java Client API. | |
| camel-fhir-starter | Exchange information in the healthcare domain using the FHIR (Fast Healthcare Interoperability Resources) standard. | |
| camel-file-starter | Read and write files. | |
| camel-ftp-starter | Upload and download files to/from FTP servers. | |
| camel-google-bigquery-starter | Google BigQuery data warehouse for analytics. | |
| camel-google-pubsub-starter | Send and receive messages to/from Google Cloud Platform PubSub Service. | |
| camel-grpc-starter | Expose gRPC endpoints and access external gRPC endpoints. | |
| camel-http-starter | Send requests to external HTTP servers using Apache HTTP Client 4.x. | |
| camel-infinispan-starter | Read and write from/to Infinispan distributed key/value store and data grid. | |
| camel-infinispan-embedded-starter | Read and write from/to Infinispan distributed key/value store and data grid. | |
| camel-jdbc-starter | Access databases through SQL and JDBC. | |
| camel-jira-starter | Interact with JIRA issue tracker. | |
| camel-jms-starter | Sent and receive messages to/from a JMS Queue or Topic. | |
| camel-jpa-starter | Store and retrieve Java objects from databases using Java Persistence API (JPA). | |
| camel-jslt-starter | Query or transform JSON payloads using an JSLT. | |
| camel-kafka-starter | Sent and receive messages to/from an Apache Kafka broker. | |
| camel-kamelet-starter | To call Kamelets | |
| link:https://access.redhat.com/documentation/en-us/red_hat_build_of_apache_camel/4.0/html-single/red_hat_build_of_apache_camel_for_spring_boot_reference/index#csb-camel-kubernetes-configmap-component-starter | camel-kubernetes-starter | Perform operations on Kubernetes ConfigMaps and get notified on ConfigMaps changes. |
| link:https://access.redhat.com/documentation/en-us/red_hat_build_of_apache_camel/4.0/html-single/red_hat_build_of_apache_camel_for_spring_boot_reference/index#csb-camel-kubernetes-custom-resources-component-starter | camel-kubernetes-starter | Perform operations on Kubernetes Custom Resources and get notified on Deployment changes. |
| link:https://access.redhat.com/documentation/en-us/red_hat_build_of_apache_camel/4.0/html-single/red_hat_build_of_apache_camel_for_spring_boot_reference/index#csb-camel-kubernetes-deployments-component-starter | camel-kubernetes-starter | Perform operations on Kubernetes Deployments and get notified on Deployment changes. |
| link:https://access.redhat.com/documentation/en-us/red_hat_build_of_apache_camel/4.0/html-single/red_hat_build_of_apache_camel_for_spring_boot_reference/index#csb-camel-kubernetes-event-component-starter | camel-kubernetes-starter | Perform operations on Kubernetes Events and get notified on Events changes. |
| link:https://access.redhat.com/documentation/en-us/red_hat_build_of_apache_camel/4.0/html-single/red_hat_build_of_apache_camel_for_spring_boot_reference/index#csb-camel-kubernetes-hpa-component-starter | camel-kubernetes-starter | Perform operations on Kubernetes Horizontal Pod Autoscalers (HPA) and get notified on HPA changes. |
| link:https://access.redhat.com/documentation/en-us/red_hat_build_of_apache_camel/4.0/html-single/red_hat_build_of_apache_camel_for_spring_boot_reference/index#csb-camel-kubernetes-job-component-starter | camel-kubernetes-starter | Perform operations on Kubernetes Jobs. |
| link:https://access.redhat.com/documentation/en-us/red_hat_build_of_apache_camel/4.0/html-single/red_hat_build_of_apache_camel_for_spring_boot_reference/index#csb-camel-kubernetes-namespaces-component-starter | camel-kubernetes-starter | Perform operations on Kubernetes Namespaces and get notified on Namespace changes. |
| link:https://access.redhat.com/documentation/en-us/red_hat_build_of_apache_camel/4.0/html-single/red_hat_build_of_apache_camel_for_spring_boot_reference/index#csb-camel-kubernetes-nodes-component-starter | camel-kubernetes-starter | Perform operations on Kubernetes Nodes and get notified on Node changes. |
| link:https://access.redhat.com/documentation/en-us/red_hat_build_of_apache_camel/4.0/html-single/red_hat_build_of_apache_camel_for_spring_boot_reference/index#csb-camel-kubernetes-persistent-volume-component-starter | camel-kubernetes-starter | Perform operations on Kubernetes Persistent Volumes and get notified on Persistent Volume changes. |
| link:https://access.redhat.com/documentation/en-us/red_hat_build_of_apache_camel/4.0/html-single/red_hat_build_of_apache_camel_for_spring_boot_reference/index#csb-camel-kubernetes-persistent-volume-claim-component-starter | camel-kubernetes-starter | Perform operations on Kubernetes Persistent Volumes Claims and get notified on Persistent Volumes Claim changes. |
| link:https://access.redhat.com/documentation/en-us/red_hat_build_of_apache_camel/4.0/html-single/red_hat_build_of_apache_camel_for_spring_boot_reference/index#csb-camel-kubernetes-pods-component-starter | camel-kubernetes-starter | Perform operations on Kubernetes Pods and get notified on Pod changes. |
| link:https://access.redhat.com/documentation/en-us/red_hat_build_of_apache_camel/4.0/html-single/red_hat_build_of_apache_camel_for_spring_boot_reference/index#csb-camel-kubernetes-replication-controller-component-starter | camel-kubernetes-starter | Perform operations on Kubernetes Replication Controllers and get notified on Replication Controllers changes. |
| link:https://access.redhat.com/documentation/en-us/red_hat_build_of_apache_camel/4.0/html-single/red_hat_build_of_apache_camel_for_spring_boot_reference/index#csb-camel-kubernetes-resources-quota-component-starter | camel-kubernetes-starter | Perform operations on Kubernetes Resources Quotas. |
| link:https://access.redhat.com/documentation/en-us/red_hat_build_of_apache_camel/4.0/html-single/red_hat_build_of_apache_camel_for_spring_boot_reference/index#csb-camel-kubernetes-secrets-component-starter | camel-kubernetes-starter | Perform operations on Kubernetes Secrets. |
| link:https://access.redhat.com/documentation/en-us/red_hat_build_of_apache_camel/4.0/html-single/red_hat_build_of_apache_camel_for_spring_boot_reference/index#csb-camel-kubernetes-service-account-component-starter | camel-kubernetes-starter | Perform operations on Kubernetes Service Accounts. |
| link:https://access.redhat.com/documentation/en-us/red_hat_build_of_apache_camel/4.0/html-single/red_hat_build_of_apache_camel_for_spring_boot_reference/index#csb-camel-kubernetes-services-component-starter | camel-kubernetes-starter | Perform operations on Kubernetes Services and get notified on Service changes. |
| camel-language-starter | Execute scripts in any of the languages supported by Camel. | |
| camel-ldap-starter | Perform searches on LDAP servers. | |
| camel-log-starter | Log messages to the underlying logging mechanism. | |
| camel-mail-starter | Send and receive emails using imap, pop3 and smtp protocols. | |
| camel-mail-microsoft-oauth-starter | Camel Mail OAuth2 Authenticator for Microsoft Exchange Online | |
| camel-mapstruct-starter | Type Conversion using Mapstruct | |
| camel-master-starter | Have only a single consumer in a cluster consuming from a given endpoint; with automatic failover if the JVM dies. | |
| camel-micrometer-starter | Collect various metrics directly from Camel routes using the Micrometer library. | |
| camel-minio-starter | Store and retrieve objects from Minio Storage Service using Minio SDK. | |
| camel-mllp-starter | Communicate with external systems using the MLLP protocol. | |
| camel-mock-starter | Test routes and mediation rules using mocks. | |
| camel-mongodb-starter | Perform operations on MongoDB documents and collections. | |
| camel-mybatis-starter | Performs a query, poll, insert, update or delete in a relational database using MyBatis. | |
| camel-netty-starter | Socket level networking using TCP or UDP with Netty 4.x. | |
| link:https://access.redhat.com/documentation/en-us/red_hat_build_of_apache_camel/4.0/html-single/red_hat_build_of_apache_camel_for_spring_boot_reference/index#csb-camel-kubernetes-openshift-build-config-component-starter | camel-kubernetes-starter | Perform operations on OpenShift Build Configs. |
| link:https://access.redhat.com/documentation/en-us/red_hat_build_of_apache_camel/4.0/html-single/red_hat_build_of_apache_camel_for_spring_boot_reference/index#csb-camel-kubernetes-openshift-builds-component-starter | camel-kubernetes-starter | Perform operations on OpenShift Builds. |
| link:https://access.redhat.com/documentation/en-us/red_hat_build_of_apache_camel/4.0/html-single/red_hat_build_of_apache_camel_for_spring_boot_reference/index#csb-camel-kubernetes-openshift-deploymentconfigs-component-starter | camel-kubernetes-starter | Perform operations on Openshift Deployment Configs and get notified on Deployment Config changes. |
| camel-netty-http-starter | Netty HTTP server and client using the Netty 4.x. | |
| camel-paho-starter | Communicate with MQTT message brokers using Eclipse Paho MQTT Client. | |
| camel-paho-mqtt5-starter | Communicate with MQTT message brokers using Eclipse Paho MQTT v5 Client. | |
| camel-platform-http-starter | Expose HTTP endpoints using the HTTP server available in the current platform. | |
| camel-quartz-starter | Schedule sending of messages using the Quartz 2.x scheduler. | |
| camel-ref-starter | Route messages to an endpoint looked up dynamically by name in the Camel Registry. | |
| camel-rest-starter | Expose REST services or call external REST services. | |
| camel-saga-starter | Execute custom actions within a route using the Saga EIP. | |
| camel-salesforce-starter | Communicate with Salesforce using Java DTOs. | |
| camel-sap-starter | Uses the SAP Java Connector (SAP JCo) library to facilitate bidirectional communication with SAP and the SAP IDoc library to facilitate the transmission of documents in the Intermediate Document (IDoc) format. | |
| camel-scheduler-starter | Generate messages in specified intervals using java.util.concurrent.ScheduledExecutorService. | |
| camel-seda-starter | Asynchronously call another endpoint from any Camel Context in the same JVM. | |
| camel-servlet-starter | Serve HTTP requests by a Servlet. | |
| camel-slack-starter | Send and receive messages to/from Slack. | |
| camel-snmp-starter | Receive traps and poll SNMP (Simple Network Management Protocol) capable devices. | |
| camel-spring-batch-starter | Send messages to Spring Batch for further processing. | |
| camel-spring-jdbc-starter | Access databases through SQL and JDBC with Spring Transaction support. | |
| camel-spring-ldap-starter | Perform searches in LDAP servers using filters as the message payload. | |
| camel-spring-rabbitmq-starter | Send and receive messages from RabbitMQ using Spring RabbitMQ client. | |
| camel-spring-redis-starter | Send and receive messages from Redis. | |
| camel-spring-ws-starter | You can use this component to integrate with Spring Web Services. It offers client-side support for accessing web services and server-side support for creating your contract-first web services. | |
| camel-sql-starter | Perform SQL queries using Spring JDBC. | |
| camel-stub-starter | Stub out any physical endpoints while in development or testing. | |
| camel-telegram-starter | Send and receive messages acting as a Telegram Bot Telegram Bot API. | |
| camel-timer-starter | Generate messages in specified intervals using java.util.Timer. | |
| camel-validator-starter | Validate the payload using XML Schema and JAXP Validation. | |
| camel-velocity-starter | Transform messages using a Velocity template. | |
| camel-vertx-http-starter | Send requests to external HTTP servers using Vert.x. | |
| camel-vertx-websocket-starter | Expose WebSocket endpoints and connect to remote WebSocket servers using Vert.x. | |
| camel-webhook-starter | Expose webhook endpoints to receive push notifications for other Camel components. | |
| camel-xj-starter | Transform JSON and XML message using a XSLT. | |
| camel-xslt-starter | Transforms XML payload using an XSLT template. | |
| camel-xslt-saxon-starter | Transform XML payloads using an XSLT template using Saxon. |
| Component | Artifact | Description |
|---|---|---|
| camel-avro-starter | Serialize and deserialize messages using Apache Avro binary data format. | |
| camel-jackson-avro-starter | Marshal POJOs to Avro and back using Jackson. | |
| camel-bindy-starter | Marshal and unmarshal between POJOs and key-value pair (KVP) format using Camel Bindy | |
| camel-hl7-starter | Marshal and unmarshal HL7 (Health Care) model objects using the HL7 MLLP codec. | |
| camel-jacksonxml-starter | Unmarshal a XML payloads to POJOs and back using XMLMapper extension of Jackson. | |
| camel-jaxb-starter | Unmarshal XML payloads to POJOs and back using JAXB2 XML marshalling standard. | |
| camel-gson-starter | Marshal POJOs to JSON and back using Gson | |
| camel-jackson-starter | Marshal POJOs to JSON and back using Jackson | |
| camel-jackson-protobuf-starter | Marshal POJOs to Protobuf and back using Jackson. | |
| camel-soap-starter | Marshal Java objects to SOAP messages and back. | |
| camel-zipfile-starter | Compression and decompress streams using java.util.zip.ZipStream. |
| Language | Artifact | Description |
|---|---|---|
| camel-core-starter | A fixed value set only once during the route startup. | |
| camel-core-starter | Evaluate a compiled simple expression. | |
| camel-core-starter | Gets a property from the Exchange. | |
| camel-core-starter | File related capabilities for the Simple language. | |
| camel-core-starter | Gets a header from the Exchange. | |
| camel-jq-starter | Evaluates a JQ expression against a JSON message body. | |
| camel-jsonpath-starter | Evaluates a JSONPath expression against a JSON message body. | |
| camel-core-starter | Uses an existing expression from the registry. | |
| camel-core-starter | Evaluates a Camel simple expression. | |
| camel-core-starter | Tokenize text payloads using delimiter patterns. | |
| camel-xml-jaxp-starter | Tokenize XML payloads. | |
| camel-xpath-starter | Evaluates an XPath expression against an XML payload. | |
| camel-saxon-starter | Query and/or transform XML payloads using XQuery and Saxon. |
| Extensions | Artifact | Description |
|---|---|---|
| camel-kamelet-main-starter | Main to run Kamelet standalone | |
| camel-openapi-java-starter | Rest-dsl support for using openapi doc | |
| camel-opentelemetry-starter | Distributed tracing using OpenTelemetry | |
| camel-spring-security-starter | Security using Spring Security | |
| camel-yaml-dsl-starter | Camel DSL with YAML |
1.4. Starter Configuration 링크 복사링크가 클립보드에 복사되었습니다!
Clear and accessible configuration is a crucial part of any application. Camel starters fully support Spring Boot’s external configuration mechanism. You can also configure them through Spring Beans for more complex use cases.
1.4.1. Using External Configuration 링크 복사링크가 클립보드에 복사되었습니다!
Internally, every starter is configured through Spring Boot’s ConfigurationProperties. Each configuration parameter can be set in various ways (application.[properties|json|yaml] files, command line arguments, environments variables etc.). Parameters have the form of camel.[component|language|dataformat].[name].[parameter]
For example to configure the URL of the MQTT5 broker you can set:
camel.component.paho-mqtt5.broker-url=tcp://localhost:61616
camel.component.paho-mqtt5.broker-url=tcp://localhost:61616
Or to configure the delimeter of the CSV dataformat to be a semicolon(;) you can set:
camel.dataformat.csv.delimiter=;
camel.dataformat.csv.delimiter=;
Camel will use the Type Converter mechanism when setting properties to the desired type.
You can refer to beans in the Registry using the #bean:name:
camel.component.jms.transactionManager=#bean:myjtaTransactionManager
camel.component.jms.transactionManager=#bean:myjtaTransactionManager
The Bean would be typically created in Java:
Beans can also be created in configuration files but this is not recommended for complex use cases.
1.4.2. Using Beans 링크 복사링크가 클립보드에 복사되었습니다!
Starters can also be created and configured via Spring Beans. Before creating a starter , Camel will first lookup it up in the Registry by it’s name if it already exists. For example to configure a Kafka component:
The Bean name has to be equal to that of the Component, Dataformat or Language that you are configuring. If the Bean name isn’t specified in the annotation it will be set to the method name.
Typical Camel Spring Boot projects will use a combination of external configuration and Beans to configure an application. For more examples on how to configure your Camel Spring Boot project, please see the example repository.
1.5. Generating a Camel for Spring Boot application using Maven 링크 복사링크가 클립보드에 복사되었습니다!
You can generate a Red Hat build of Apache Camel for Spring Boot application using the Maven archetype org.apache.camel.archetypes:camel-archetype-spring-boot:4.0.0.redhat-00045.
Procedure
Run the following command:
Copy to Clipboard Copied! Toggle word wrap Toggle overflow Build the application:
mvn package -f csb-app/pom.xml
mvn package -f csb-app/pom.xmlCopy to Clipboard Copied! Toggle word wrap Toggle overflow Run the application:
java -jar csb-app/target/csb-app-1.0-SNAPSHOT.jar
java -jar csb-app/target/csb-app-1.0-SNAPSHOT.jarCopy to Clipboard Copied! Toggle word wrap Toggle overflow Verify that the application is running by examining the console log for the Hello World output which is generated by the application.
com.redhat.MySpringBootApplication : Started MySpringBootApplication in 3.514 seconds (JVM running for 4.006) Hello World Hello World
com.redhat.MySpringBootApplication : Started MySpringBootApplication in 3.514 seconds (JVM running for 4.006) Hello World Hello WorldCopy to Clipboard Copied! Toggle word wrap Toggle overflow
1.6. Deploying a Camel Spring Boot application to OpenShift 링크 복사링크가 클립보드에 복사되었습니다!
This guide demonstrates how to deploy a Camel Spring Boot application to OpenShift.
Prerequisites
- You have access to the OpenShift cluster.
-
The OpenShift
ocCLI client is installed or you have access to the OpenShift Container Platform web console.
The certified OpenShift Container platforms are listed in the Camel for Spring Boot Supported Configurations. The Red Hat OpenJDK 11 (ubi8/openjdk-11) container image is used in the following example.
Procedure
- Generate a Camel for Spring Boot application using Maven by following the instructions in section 1.5 Generating a Camel for Spring Boot application using Maven of this guide.
Under the directory which the modified pom.xml exists, execute the following command.
mvn clean -DskipTests oc:deploy -Popenshift
mvn clean -DskipTests oc:deploy -PopenshiftCopy to Clipboard Copied! Toggle word wrap Toggle overflow Verify that the CSB application is running on the pod.
oc logs -f dc/csb-app
oc logs -f dc/csb-appCopy to Clipboard Copied! Toggle word wrap Toggle overflow
1.7. Applying patch to Red Hat build of Apache Camel for Spring Boot 링크 복사링크가 클립보드에 복사되었습니다!
Using the new patch-maven-plugin mechanism, you can apply a patch to your Red Hat Red Hat build of Apache Camel for Spring Boot application. This mechanism allows you to change the individual versions provided by different Red Hat application BOMS, for example, camel-spring-boot-bom.
The purpose of the patch-maven-plugin is to update the versions of the dependencies listed in the Camel on Spring Boot BOM to the versions specified in the patch metadata that you wish to apply to your applications.
The patch-maven-plugin performs the following operations:
- Retrieve the patch metadata related to current Red Hat application BOMs.
- Apply the version changes to <dependencyManagement> imported from the BOMs.
After the patch-maven-plugin fetches the metadata, it iterates through all managed and direct dependencies of the project where the plugin was declared and replaces the dependency versions (if they match) using CVE/patch metadata. After the versions are replaced, the Maven build continues and progresses through standard Maven project stages.
Procedure
The following procedure explains how to apply the patch to your application.
Add
patch-maven-pluginto your project’spom.xmlfile. The version of thepatch-maven-pluginmust be the same as the version of the Camel on Spring Boot BOM.Copy to Clipboard Copied! Toggle word wrap Toggle overflow When you run any of the
mvn clean deploy,mvn validate, ormvn dependency:treecommands, the plugin searches through the project modules to check if the modules use the Red Hat Red Hat build of Apache Camel for Spring Boot BOM. Only the following is the supported BOM:-
com.redhat.camel.springboot.platform:camel-spring-boot-bom: for Red Hat build of Apache Camel for Spring Boot BOM
-
If the plugin does not find the above BOM, the plugin displays the following messages:
Copy to Clipboard Copied! Toggle word wrap Toggle overflow If the correct BOM is used, the patch metadata is found, but without any patches.
Copy to Clipboard Copied! Toggle word wrap Toggle overflow The
patch-maven-pluginattempts to fetch this Maven metadata.For the projects with Camel Spring Boot BOM, the
com.redhat.camel.springboot.platform:redhat-camel-spring-boot-patch-metadata/maven-metadata.xmlis resolved. This XML data is the metadata for the artifact with thecom.redhat.camel.springboot.platform:redhat-camel-spring-boot-patch-metadata:RELEASEcoordinates.Example metadata generated by Maven
Copy to Clipboard Copied! Toggle word wrap Toggle overflow
-
The
patch-maven-pluginparses the metadata to select the version which applies to the current project. This action is possible only for the Maven projects using Camel on Spring Boot BOM with the specific version. Only the metadata that matches the version range or later is applicable, and it fetches only the latest version of the metadata. The
patch-maven-plugincollects a list of remote Maven repositories for downloading the patch metadata identified bygroupId,artifactId, andversionfound in previous steps. These Maven repositories are listed in the project’s<repositories>elements in the active profiles, and also the repositories from thesettings.xmlfile.Copy to Clipboard Copied! Toggle word wrap Toggle overflow Whether the metadata comes from a remote repository, local repository, or ZIP file, it is analyzed by the
patch-maven-plugin. The fetched metadata contains a list of CVEs, and for each CVE, we have a list of the affected Maven artifacts (specified by glob patterns and version ranges) together with a version that contains a fix for a given CVE. For example,Copy to Clipboard Copied! Toggle word wrap Toggle overflow Finally a list of fixes specified in patch metadata is consulted when iterating over all managed dependencies in the current project. These dependencies (and managed dependencies) that match are changed to fixed versions. For example:
Copy to Clipboard Copied! Toggle word wrap Toggle overflow
Skipping the patch
If you do not wish to apply a specific patch to your project, the patch-maven-plugin provides a skip option. Assuming that you have already added the patch-maven-plugin to the project’s pom.xml file, and you do not wish to alter the versions, you can use one of the following method to skip the patch.
-
Add the skip option to your project’s
pom.xmlfile as follows.
-
Or use the
-DskipPatchoption when running themvncommand as follows.
As shown in the above output, the patch-maven-plugin was not invoked, which resulted in the patch not being applied to the application.
1.8. Camel REST DSL OpenApi Maven Plugin 링크 복사링크가 클립보드에 복사되었습니다!
The Camel REST DSL OpenApi Maven Plugin supports the following goals.
- camel-restdsl-openapi:generate - To generate consumer REST DSL RouteBuilder source code from OpenApi specification
- camel-restdsl-openapi:generate-with-dto - To generate consumer REST DSL RouteBuilder source code from OpenApi specification and with DTO model classes generated via the swagger-codegen-maven-plugin.
- camel-restdsl-openapi:generate-xml - To generate consumer REST DSL XML source code from OpenApi specification
- camel-restdsl-openapi:generate-xml-with-dto - To generate consumer REST DSL XML source code from OpenApi specification and with DTO model classes generated via the swagger-codegen-maven-plugin.
- camel-restdsl-openapi:generate-yaml - To generate consumer REST DSL YAML source code from OpenApi specification
- camel-restdsl-openapi:generate-yaml-with-dto - To generate consumer REST DSL YAML source code from OpenApi specification and with DTO model classes generated via the swagger-codegen-maven-plugin.
1.8.1. Adding plugin to Maven pom.xml 링크 복사링크가 클립보드에 복사되었습니다!
This plugin can be added to your Maven pom.xml file by adding it to the plugins section, for example in a Spring Boot application:
The plugin can then be executed using its prefix camel-restdsl-openapi as shown below.
$mvn camel-restdsl-openapi:generate
$mvn camel-restdsl-openapi:generate
1.8.2. camel-restdsl-openapi:generate 링크 복사링크가 클립보드에 복사되었습니다!
The goal of the Camel REST DSL OpenApi Maven Plugin is used to generate REST DSL RouteBuilder implementation source code from Maven.
1.8.3. Options 링크 복사링크가 클립보드에 복사되었습니다!
The plugin supports the following options which can be configured from the command line (use -D syntax), or defined in the pom.xml file in the configuration tag.
| Parameter | Default Value | Description |
|---|---|---|
|
|
|
Set to |
|
|
Used for including only the operation ids specified. Multiple ids can be separated by comma. Wildcards can be used, eg | |
|
|
|
URI of the OpenApi specification, supports filesystem paths, HTTP and classpath resources, by default |
|
| Adds authorization headers when fetching the OpenApi specification definitions remotely. Pass in a URL-encoded string of name:header with a comma separating multiple values. | |
|
|
from |
Name of the generated class, taken from the OpenApi specification title or set to |
|
|
from |
Name of the package for the generated class, taken from the OpenApi specification host value or |
|
|
|
Which indenting character(s) to use, by default four spaces, you can use |
|
|
|
Where to place the generated source file, by default |
|
|
Fully qualified class name of the class that implements | |
|
|
| The default to syntax for the to uri, which is to use the direct component. |
|
|
| Whether to include generation of the rest configuration with detected rest component to be used. |
|
|
Define openapi endpoint path if | |
|
|
| Whether to enable request validation. |
|
| Overrides the api base path as defined in the OpenAPI specification. | |
|
|
| Allows generation of custom RequestMapping mapping values. Multiple mapping values can be passed as:
|
1.8.4. Spring Boot Project with Servlet component 링크 복사링크가 클립보드에 복사되었습니다!
If the Maven project is a Spring Boot project and restConfiguration is enabled and the servlet component is being used as REST component, then this plugin will autodetect the package name (if packageName has not been explicitly configured) where the @SpringBootApplication main class is located, and use the same package name for generating Rest DSL source code and a needed CamelRestController support class.
1.8.5. camel-restdsl-openapi:generate-with-dto 링크 복사링크가 클립보드에 복사되었습니다!
Works as generate goal but also generates DTO model classes by automatic executing the swagger-codegen-maven-plugin to generate java source code of the DTO model classes from the OpenApi specification.
This plugin has been scoped and limited to only support a good effort set of defaults for using the swagger-codegen-maven-plugin to generate the model DTOs. If you need more power and flexibility then use the Swagger Codegen Maven Plugin directly to generate the DTO and not this plugin.
The DTO classes may require additional dependencies such as:
1.8.6. Options 링크 복사링크가 클립보드에 복사되었습니다!
The plugin supports the following additional options
| Parameter | Default Value | Description |
|---|---|---|
|
| 3.0.36 |
The version of the |
|
| Target output path (default is ${project.build.directory}/generated-sources/openapi) | |
|
|
| The package to use for generated model objects/classes |
|
| Sets the pre- or suffix for model classes and enums | |
|
| Sets the pre- or suffix for model classes and enums | |
|
| false | Enable XML annotations inside the generated models (only works with libraries that provide support for JSON and XML) |
|
|
Pass a map of language-specific parameters to |
1.8.7. camel-restdsl-openapi:generate-xml 링크 복사링크가 클립보드에 복사되었습니다!
The camel-restdsl-openapi:generate-xml goal of the Camel REST DSL OpenApi Maven Plugin is used to generate REST DSL XML implementation source code from Maven.
1.8.8. Options 링크 복사링크가 클립보드에 복사되었습니다!
The plugin supports the following options which can be configured from the command line (use -D syntax), or defined in the pom.xml file in the <configuration> tag.
| Parameter | Default Value | Description |
|---|---|---|
|
|
|
Set to |
|
|
Used for including only the operation ids specified. Multiple ids can be separated by comma. Wildcards can be used, eg | |
|
|
|
URI of the OpenApi specification, supports filesystem paths, HTTP and classpath resources, by default |
|
| Adds authorization headers when fetching the OpenApi specification definitions remotely. Pass in a URL-encoded string of name:header with a comma separating multiple values. | |
|
|
|
Where to place the generated source file, by default |
|
|
| The name of the XML file as output. |
|
|
| If enabled generates OSGi Blueprint XML instead of Spring XML. |
|
|
Fully qualified class name of the class that implements | |
|
|
| The default to syntax for the to uri, which is to use the direct component. |
|
|
| |
| Whether to include generation of the rest configuration with detected rest component to be used. |
| |
|
Define openapi endpoint path if |
|
|
| Whether to enable request validation. |
| |
| Overrides the api base path as defined in the OpenAPI specification. |
|
|
1.8.9. camel-restdsl-openapi:generate-xml-with-dto 링크 복사링크가 클립보드에 복사되었습니다!
Works as generate-xml goal but also generates DTO model classes by automatic executing the swagger-codegen-maven-plugin to generate java source code of the DTO model classes from the OpenApi specification.
This plugin has been scoped and limited to only support a good effort set of defaults for using the swagger-codegen-maven-plugin to generate the model DTOs. If you need more power and flexibility then use the Swagger Codegen Maven Plugin directly to generate the DTO and not this plugin.
The DTO classes may require additional dependencies such as:
1.8.10. Options 링크 복사링크가 클립보드에 복사되었습니다!
The plugin supports the following additional options
| Parameter | Default Value | Description |
|---|---|---|
|
| 3.0.36 |
The version of the |
|
| Target output path (default is ${project.build.directory}/generated-sources/openapi) | |
|
|
| The package to use for generated model objects/classes |
|
| Sets the pre- or suffix for model classes and enums | |
|
| Sets the pre- or suffix for model classes and enums | |
|
| false | Enable XML annotations inside the generated models (only works with libraries that provide support for JSON and XML) |
|
|
Pass a map of language-specific parameters to |
1.8.11. camel-restdsl-openapi:generate-yaml 링크 복사링크가 클립보드에 복사되었습니다!
The camel-restdsl-openapi:generate-yaml goal of the Camel REST DSL OpenApi Maven Plugin is used to generate REST DSL YAML implementation source code from Maven.
1.8.12. Options 링크 복사링크가 클립보드에 복사되었습니다!
The plugin supports the following options which can be configured from the command line (use -D syntax), or defined in the pom.xml file in the <configuration> tag.
| Parameter | Default Value | Description |
|---|---|---|
|
|
|
Set to |
|
|
Used for including only the operation ids specified. Multiple ids can be separated by comma. Wildcards can be used, eg | |
|
|
|
URI of the OpenApi specification, supports filesystem paths, HTTP and classpath resources, by default |
|
| Adds authorization headers when fetching the OpenApi specification definitions remotely. Pass in a URL-encoded string of name:header with a comma separating multiple values. | |
|
|
|
Where to place the generated source file, by default |
|
|
| The name of the XML file as output. |
|
|
Fully qualified class name of the class that implements | |
|
|
| The default to syntax for the to uri, which is to use the direct component. |
|
|
| |
| Whether to include generation of the rest configuration with detected rest component to be used. |
| |
|
Define openapi endpoint path if |
|
|
| Whether to enable request validation. |
| |
| Overrides the api base path as defined in the OpenAPI specification. |
|
|
1.8.13. camel-restdsl-openapi:generate-yaml-with-dto 링크 복사링크가 클립보드에 복사되었습니다!
Works as generate-yaml goal but also generates DTO model classes by automatic executing the swagger-codegen-maven-plugin to generate java source code of the DTO model classes from the OpenApi specification.
This plugin has been scoped and limited to only support a good effort set of defaults for using the swagger-codegen-maven-plugin to generate the model DTOs. If you need more power and flexibility then use the Swagger Codegen Maven Plugin directly to generate the DTO and not this plugin.
The DTO classes may require additional dependencies such as:
1.8.14. Options 링크 복사링크가 클립보드에 복사되었습니다!
The plugin supports the following additional options
| Parameter | Default Value | Description |
|---|---|---|
|
| 3.0.36 |
The version of the |
|
| Target output path (default is ${project.build.directory}/generated-sources/openapi) | |
|
|
| The package to use for generated model objects/classes |
|
| Sets the pre- or suffix for model classes and enums | |
|
| Sets the pre- or suffix for model classes and enums | |
|
| false | Enable XML annotations inside the generated models (only works with libraries that provide support for JSON and XML) |
|
|
Pass a map of language-specific parameters to |
1.9. Support for FIPS Compliance 링크 복사링크가 클립보드에 복사되었습니다!
You can install an OpenShift Container Platform cluster that uses FIPS Validated / Modules in Process cryptographic libraries on the x86_64 architecture.
For the Red Hat Enterprise Linux CoreOS (RHCOS) machines in your cluster, this change applies when the machines deploy based on the status of an option in the install-config.yaml file, which governs the cluster options that users can change during cluster deployment. With Red Hat Enterprise Linux (RHEL) machines, you must enable FIPS mode when installing the operating system on the machines you plan to use as worker machines. These configuration methods ensure that your cluster meets the requirements of a FIPS compliance audit. Only FIPS Validated / Modules in Process cryptography packages are enabled before the initial system boot.
Because you must enable FIPS before your cluster’s operating system boots for the first time, you cannot enable FIPS after you deploy a cluster.
1.9.1. FIPS validation in OpenShift Container Platform 링크 복사링크가 클립보드에 복사되었습니다!
OpenShift Container Platform uses certain FIPS Validated / Modules in Process modules within RHEL and RHCOS for its operating system components. For example, when users SSH into OpenShift Container Platform clusters and containers, those connections are properly encrypted.
OpenShift Container Platform components are written in Go and built with Red Hat’s Golang compiler. When you enable FIPS mode for your cluster, all OpenShift Container Platform components that require cryptographic signing call RHEL and RHCOS cryptographic libraries.
For more details about FIPS, see FIPS mode attributes and limitations
For details on deploying Camel Spring Boot on OpenShift, see How to deploy a Camel Spring Boot application to OpenShift?
Details about supported configurations can be found at, Camel for Spring Boot Supported Configurations
Chapter 2. Monitoring Camel Spring Boot integrations 링크 복사링크가 클립보드에 복사되었습니다!
This chapter explains how to monitor integrations on Red Hat build of Camel Spring Boot at runtime. You can use the Prometheus Operator that is already deployed as part of OpenShift Monitoring to monitor your own applications.
2.1. Enabling user workload monitoring in OpenShift 링크 복사링크가 클립보드에 복사되었습니다!
You can enable the monitoring for user-defined projects by setting the enableUserWorkload: true field in the cluster monitoring ConfigMap object.
In OpenShift Container Platform 4.13 you must remove any custom Prometheus instances before enabling monitoring for user-defined projects.
Prerequisites
You must have access to the cluster as a user with the cluster-admin cluster role access to enable monitoring for user-defined projects in OpenShift Container Platform. Cluster administrators can then optionally grant users permission to configure the components that are responsible for monitoring user-defined projects.
- You have cluster admin access to the OpenShift cluster.
- You have installed the OpenShift CLI (oc).
-
You have created the
cluster-monitoring-configConfigMap object. -
Optional: You have created and configured the
user-workload-monitoring-configConfigMap object in theopenshift-user-workload-monitoringproject. You can add configuration options to this ConfigMap object for the components that monitor user-defined projects.
Every time you save configuration changes to the user-workload-monitoring-config ConfigMap object, the pods in the openshift-user-workload-monitoring project are redeployed. It can sometimes take a while for these components to redeploy. You can create and configure the ConfigMap object before you first enable monitoring for user-defined projects, to prevent having to redeploy the pods often.
Procedure
Login to OpenShift with administrator permissions.
oc login --user system:admin --token=my-token --server=https://my-cluster.example.com:6443
oc login --user system:admin --token=my-token --server=https://my-cluster.example.com:6443Copy to Clipboard Copied! Toggle word wrap Toggle overflow Edit the
cluster-monitoring-configConfigMap object.oc -n openshift-monitoring edit configmap cluster-monitoring-config
$ oc -n openshift-monitoring edit configmap cluster-monitoring-configCopy to Clipboard Copied! Toggle word wrap Toggle overflow Add
enableUserWorkload: truein the data/config.yaml section.Copy to Clipboard Copied! Toggle word wrap Toggle overflow When it is set to true, the
enableUserWorkloadparameter enables monitoring for user-defined projects in a cluster.Save the file to apply the changes. The monitoring for the user-defined projects is then enabled automatically.
NoteWhen the changes are saved to the
cluster-monitoring-configConfigMap object, the pods and other resources in theopenshift-monitoringproject might be redeployed. The running monitoring processes in that project might also be restarted.Verify that the
prometheus-operator,prometheus-user-workloadandthanos-ruler-user-workloadpods are running in theopenshift-user-workload-monitoringproject.Copy to Clipboard Copied! Toggle word wrap Toggle overflow
2.2. Deploying a Camel Spring Boot application 링크 복사링크가 클립보드에 복사되었습니다!
After you enable the monitoring for your project, you can deploy and monitor the Camel Spring Boot application. This section uses the monitoring-micrometrics-grafana-prometheus example listed in the Camel Spring Boot Examples.
Procedure
Add the openshift-maven-plugin to the
pom.xmlfile of themonitoring-micrometrics-grafana-prometheusexample. In thepom.xml, add an openshift profile to allow deployment to openshift through the openshift-maven-plugin.Copy to Clipboard Copied! Toggle word wrap Toggle overflow Add the Prometheus support. In order to add the Prometheus support to your Camel Spring Boot application, expose the Prometheus statistics on an actuator endpoint.
Edit your
src/main/resources/application.propertiesfile. If you have amanagement.endpoints.web.exposure.includeentry, add prometheus, metrics, and health. If you do not have amanagement.endpoints.web.exposure.includeentry, please add one.expose actuator endpoint via HTTP
# expose actuator endpoint via HTTP management.endpoints.web.exposure.include=mappings,metrics,health,shutdown,jolokia,prometheusCopy to Clipboard Copied! Toggle word wrap Toggle overflow
Add the following to the
<dependencies/>section of your pom.xml to add some starter support to your application.Copy to Clipboard Copied! Toggle word wrap Toggle overflow Add the following to the
Application.javaof your Camel Spring Boot application.Copy to Clipboard Copied! Toggle word wrap Toggle overflow The updated
Application.javais shown below.Copy to Clipboard Copied! Toggle word wrap Toggle overflow Deploy the application to OpenShift.
mvn -Popenshift oc:deploy
mvn -Popenshift oc:deployCopy to Clipboard Copied! Toggle word wrap Toggle overflow Verify if your application is deployed.
Copy to Clipboard Copied! Toggle word wrap Toggle overflow Add the Service Monitor for this application so that Openshift’s prometheus instance can start scraping from the / actuator/prometheus endpoint.
Create the following YAML manifest for a Service monitor. In this example, the file is named as
servicemonitor.yaml.Copy to Clipboard Copied! Toggle word wrap Toggle overflow Add a Service Monitor for this application.
oc apply -f servicemonitor.yml servicemonitor.monitoring.coreos.com/csb-demo-monitor "myapp" created
oc apply -f servicemonitor.yml servicemonitor.monitoring.coreos.com/csb-demo-monitor "myapp" createdCopy to Clipboard Copied! Toggle word wrap Toggle overflow
Verify that the service monitor was successfully deployed.
oc get servicemonitor NAME AGE csb-demo-monitor 9m17s
oc get servicemonitor NAME AGE csb-demo-monitor 9m17sCopy to Clipboard Copied! Toggle word wrap Toggle overflow -
Verify that you can see the service monitor in the list of scrape targets. In the Administrator view, navigate to Observe → Targets. You can find
csb-demo-monitorwithin the list of scrape targets. -
Wait about ten minutes after deploying the servicemonitor. Then navigate to the Observe → Metrics in the Developer view. Select Custom query in the drop-down menu and type
camelto view the Camel metrics that are exposed through the /actuator/prometheus endpoint.
Red Hat does not offer support for installing and configuring Prometheus and Grafana on non-OCP environments.
Chapter 3. Using Camel with Spring XML 링크 복사링크가 클립보드에 복사되었습니다!
Using Camel with Spring XML files, is a way, of using XML DSL with Camel. Camel has historically been using Spring XML for a long time. The Spring framework started with XML files as a popular and common configuration for building Spring applications.
Example of Spring application
3.1. Specifying Camel routes using Spring XML 링크 복사링크가 클립보드에 복사되었습니다!
You can use Spring XML files to specify Camel routes using XML DSL as shown:
3.2. Configuring Components and Endpoints 링크 복사링크가 클립보드에 복사되었습니다!
You can configure your Component or Endpoint instances in your Spring XML as follows in this example.
This allows you to configure a component using any name, but its common to use the same name, for example, jms. Then you can refer to the component using jms:destinationName.
This works by the Camel fetching components from the Spring context for the scheme name you use for Endpoint URIs.
3.3. Using Java DSL with Spring XML files 링크 복사링크가 클립보드에 복사되었습니다!
You can use Java Code to define your RouteBuilder implementations. These are defined as beans in spring and then referenced in your camel context, as shown:
<camelContext xmlns="http://camel.apache.org/schema/spring"> <routeBuilder ref="myBuilder"/> </camelContext> <bean id="myBuilder" class="org.apache.camel.spring.example.test1.MyRouteBuilder"/>
<camelContext xmlns="http://camel.apache.org/schema/spring">
<routeBuilder ref="myBuilder"/>
</camelContext>
<bean id="myBuilder" class="org.apache.camel.spring.example.test1.MyRouteBuilder"/>
3.4. Using package scanning 링크 복사링크가 클립보드에 복사되었습니다!
Camel also provides a powerful feature that allows for the automatic discovery and initialization of routes in given packages. This is configured by adding tags to the camel context in your spring context definition, specifying the packages to be recursively searched for RouteBuilder implementations. To use this feature add a <package></package> tag specifying a comma separated list of packages that should be searched. For example,
This scans for RouteBuilder classes in the com.foo and the sub-packages.
You can also filter the classes with includes or excludes such as:
This skips the classes that has Special in the name. Exclude patterns are applied before the include patterns. If no include or exclude patterns are defined then all the Route classes discovered in the packages are returned.
? matches one character, * matches zero or more characters, ** matches zero or more segments of a fully qualified name.
3.5. Using context scanning 링크 복사링크가 클립보드에 복사되었습니다!
You can allow Camel to scan the container context, for example, the Spring ApplicationContext for route builder instances. This allows you to use the Spring <component-scan> feature and have Camel pickup any RouteBuilder instances which was created by Spring in its scan process.
This allows you to just annotate your routes using the Spring @Component and have those routes included by Camel:
You can also use the ANT style for inclusion and exclusion, as mentioned above in the package scan section.