Ce contenu n'est pas disponible dans la langue sélectionnée.
Chapter 3. Camel Quarkus extensions reference
This chapter provides usage information for Red Hat build of Apache Camel for Quarkus.
3.1. AMQP
Messaging with AMQP protocol using Apache QPid Client.
3.1.1. What’s inside
-
AMQP component, URI syntax:
amqp:destinationType:destinationName
Refer to the above link for usage and configuration details.
3.1.2. Maven coordinates
Create a new project with this extension on code.quarkus.redhat.com
Or add the coordinates to your existing project:
<dependency> <groupId>org.apache.camel.quarkus</groupId> <artifactId>camel-quarkus-amqp</artifactId> </dependency>
3.1.3. Usage
3.1.3.1. Message mapping with org.w3c.dom.Node
The Camel AMQP component supports message mapping between jakarta.jms.Message
and org.apache.camel.Message
. When wanting to convert a Camel message body type of org.w3c.dom.Node
, you must ensure that the camel-quarkus-xml-jaxp
extension is present on the classpath.
3.1.3.2. Native mode support for jakarta.jms.ObjectMessage
When sending JMS message payloads as jakarta.jms.ObjectMessage
, you must annotate the relevant classes to be registered for serialization with @RegisterForReflection(serialization = true)
. Note that this extension automatically sets quarkus.camel.native.reflection.serialization-enabled = true
for you. Refer to the native mode user guide for more information.
3.1.3.3. Connection Pooling
You can use the quarkus-pooled-jms
extension to get pooling support for the connections. Refer to the quarkus-pooled-jms extension documentation for more information.
Just add the following dependency to your pom.xml
:
<dependency> <groupId>io.quarkiverse.messaginghub</groupId> <artifactId>quarkus-pooled-jms</artifactId> </dependency>
To enable the pooling support, you need to add the following configuration to your application.properties
:
quarkus.qpid-jms.wrap=true
3.1.4. transferException option in native mode
To use the transferException
option in native mode, you must enable support for object serialization. Refer to the native mode user guide for more information.
You will also need to enable serialization for the exception classes that you intend to serialize. For example:
@RegisterForReflection(targets = { IllegalStateException.class, MyCustomException.class }, serialization = true)
3.1.5. Additional Camel Quarkus configuration
The extension leverages the Quarkus Qpid JMS extension. A ConnectionFactory bean is automatically created and wired into the AMQP component for you. The connection factory can be configured via the Quarkus Qpid JMS configuration options.
3.2. Attachments
Support for attachments on Camel messages
3.2.1. What’s inside
Refer to the above link for usage and configuration details.
3.2.2. Maven coordinates
Create a new project with this extension on code.quarkus.redhat.com
Or add the coordinates to your existing project:
<dependency> <groupId>org.apache.camel.quarkus</groupId> <artifactId>camel-quarkus-attachments</artifactId> </dependency>
3.3. Avro
Serialize and deserialize messages using Apache Avro binary data format.
3.3.1. What’s inside
Refer to the above link for usage and configuration details.
3.3.2. Maven coordinates
Create a new project with this extension on code.quarkus.redhat.com
Or add the coordinates to your existing project:
<dependency> <groupId>org.apache.camel.quarkus</groupId> <artifactId>camel-quarkus-avro</artifactId> </dependency>
3.3.3. Additional Camel Quarkus configuration
Beyond standard usages known from vanilla Camel, Camel Quarkus adds the possibility to parse the Avro schema at build time both in JVM and Native mode.
The approach to generate Avro classes from Avro schema files is the one coined by the quarkus-avro
extension. It requires the following:
-
Store
*.avsc
files in a folder namedsrc/main/avro
orsrc/test/avro
In addition to the usual
build
goal ofquarkus-maven-plugin
, add thegenerate-code
goal:<plugin> <groupId>io.quarkus</groupId> <artifactId>quarkus-maven-plugin</artifactId> <executions> <execution> <id>generate-code-and-build</id> <goals> <goal>generate-code</goal> <goal>build</goal> </goals> </execution> </executions> </plugin>
Please see a working configuration in Camel Quarkus Avro integration test and Quarkus Avro integration test.
3.4. AWS 2 CloudWatch
Sending metrics to AWS CloudWatch.
3.4.1. What’s inside
-
AWS CloudWatch component, URI syntax:
aws2-cw:namespace
Refer to the above link for usage and configuration details.
3.4.2. Maven coordinates
Create a new project with this extension on code.quarkus.redhat.com
Or add the coordinates to your existing project:
<dependency> <groupId>org.apache.camel.quarkus</groupId> <artifactId>camel-quarkus-aws2-cw</artifactId> </dependency>
3.4.3. SSL in native mode
This extension auto-enables SSL support in native mode. Hence you do not need to add quarkus.ssl.native=true
to your application.properties
yourself. See also Quarkus SSL guide.
3.5. AWS 2 DynamoDB
Store and retrieve data from AWS DynamoDB service or receive messages from AWS DynamoDB Stream using AWS SDK version 2.x.
3.5.1. What’s inside
-
AWS DynamoDB component, URI syntax:
aws2-ddb:tableName
-
AWS DynamoDB Streams component, URI syntax:
aws2-ddbstream:tableName
Refer to the above links for usage and configuration details.
3.5.2. Maven coordinates
Create a new project with this extension on code.quarkus.redhat.com
Or add the coordinates to your existing project:
<dependency> <groupId>org.apache.camel.quarkus</groupId> <artifactId>camel-quarkus-aws2-ddb</artifactId> </dependency>
3.5.3. SSL in native mode
This extension auto-enables SSL support in native mode. Hence you do not need to add quarkus.ssl.native=true
to your application.properties
yourself. See also Quarkus SSL guide.
3.5.4. Additional Camel Quarkus configuration
3.5.4.1. Optional integration with Quarkus Amazon DynamoDB
If desired, it is possible to use the Quarkus Amazon DynamoDB extension in conjunction with Camel Quarkus AWS 2 DynamoDB. Note that this is fully optional and not mandatory at all. Please follow the Quarkus documentation but beware of the following caveats:
The client type
apache
has to be selected by configuring the following property:quarkus.dynamodb.sync-client.type=apache
The
DynamoDbClient
has to be made "unremovable" in the sense of Quarkus CDI reference so that Camel Quarkus is able to look it up at runtime. You can reach that e.g. by adding a dummy bean injectingDynamoDbClient
:import jakarta.enterprise.context.ApplicationScoped; import io.quarkus.arc.Unremovable; import software.amazon.awssdk.services.dynamodb.DynamoDbClient; @ApplicationScoped @Unremovable class UnremovableDynamoDbClient { @Inject DynamoDbClient dynamoDbClient; }
3.6. AWS 2 Kinesis
Consume and produce records from AWS Kinesis Streams using AWS SDK version 2.x.
3.6.1. What’s inside
-
AWS Kinesis component, URI syntax:
aws2-kinesis:streamName
-
AWS Kinesis Firehose component, URI syntax:
aws2-kinesis-firehose:streamName
Refer to the above links for usage and configuration details.
3.6.2. Maven coordinates
Create a new project with this extension on code.quarkus.redhat.com
Or add the coordinates to your existing project:
<dependency> <groupId>org.apache.camel.quarkus</groupId> <artifactId>camel-quarkus-aws2-kinesis</artifactId> </dependency>
3.6.3. SSL in native mode
This extension auto-enables SSL support in native mode. Hence you do not need to add quarkus.ssl.native=true
to your application.properties
yourself. See also Quarkus SSL guide.
3.7. AWS 2 Lambda
Manage and invoke AWS Lambda functions using AWS SDK version 2.x.
3.7.1. What’s inside
-
AWS Lambda component, URI syntax:
aws2-lambda:function
Refer to the above link for usage and configuration details.
3.7.2. Maven coordinates
Create a new project with this extension on code.quarkus.redhat.com
Or add the coordinates to your existing project:
<dependency> <groupId>org.apache.camel.quarkus</groupId> <artifactId>camel-quarkus-aws2-lambda</artifactId> </dependency>
3.7.3. SSL in native mode
This extension auto-enables SSL support in native mode. Hence you do not need to add quarkus.ssl.native=true
to your application.properties
yourself. See also Quarkus SSL guide.
3.7.4. Additional Camel Quarkus configuration
3.7.4.1. Not possible to leverage quarkus-amazon-lambda by Camel aws2-lambda extension
Quarkus-amazon-lambda extension allows you to use Quarkus to build your AWS Lambdas, whereas Camel component manages (deploy, undeploy, …) existing functions. Therefore, it is not possible to use quarkus-amazon-lambda
as a client for Camel aws2-lambda
extension.
3.8. AWS 2 S3 Storage Service
Store and retrieve objects from AWS S3 Storage Service.
3.8.1. What’s inside
-
AWS S3 Storage Service component, URI syntax:
aws2-s3://bucketNameOrArn
Refer to the above link for usage and configuration details.
3.8.2. Maven coordinates
Create a new project with this extension on code.quarkus.redhat.com
Or add the coordinates to your existing project:
<dependency> <groupId>org.apache.camel.quarkus</groupId> <artifactId>camel-quarkus-aws2-s3</artifactId> </dependency>
3.8.3. SSL in native mode
This extension auto-enables SSL support in native mode. Hence you do not need to add quarkus.ssl.native=true
to your application.properties
yourself. See also Quarkus SSL guide.
3.8.4. Additional Camel Quarkus configuration
3.8.4.1. Optional integration with Quarkus Amazon S3
If desired, it is possible to use the Quarkus Amazon S3 extension in conjunction with Camel Quarkus AWS 2 S3 Storage Service. Note that this is fully optional and not mandatory at all. Please follow the Quarkus documentation but beware of the following caveats:
The client type
apache
has to be selected by configuring the following property:quarkus.s3.sync-client.type=apache
The
S3Client
has to be made "unremovable" in the sense of Quarkus CDI reference so that Camel Quarkus is able to look it up at runtime. You can reach that e.g. by adding a dummy bean injectingS3Client
:import jakarta.enterprise.context.ApplicationScoped; import io.quarkus.arc.Unremovable; import software.amazon.awssdk.services.s3.S3Client; @ApplicationScoped @Unremovable class UnremovableS3Client { @Inject S3Client s3Client; }
3.9. AWS 2 Simple Notification System (SNS)
Send messages to an AWS Simple Notification Topic.
3.9.1. What’s inside
-
AWS Simple Notification System (SNS) component, URI syntax:
aws2-sns:topicNameOrArn
Refer to the above link for usage and configuration details.
3.9.2. Maven coordinates
Create a new project with this extension on code.quarkus.redhat.com
Or add the coordinates to your existing project:
<dependency> <groupId>org.apache.camel.quarkus</groupId> <artifactId>camel-quarkus-aws2-sns</artifactId> </dependency>
3.9.3. SSL in native mode
This extension auto-enables SSL support in native mode. Hence you do not need to add quarkus.ssl.native=true
to your application.properties
yourself. See also Quarkus SSL guide.
3.9.4. Additional Camel Quarkus configuration
3.9.4.1. Optional integration with Quarkus Amazon SNS
If desired, it is possible to use the Quarkus Amazon SNS extension in conjunction with Camel Quarkus AWS 2 Simple Notification System (SNS). Note that this is fully optional and not mandatory at all. Please follow the Quarkus documentation but beware of the following caveats:
The client type
apache
has to be selected by configuring the following property:quarkus.sns.sync-client.type=apache
The
SnsClient
has to be made "unremovable" in the sense of Quarkus CDI reference so that Camel Quarkus is able to look it up at runtime. You can reach that e.g. by adding a dummy bean injectingSnsClient
:import jakarta.enterprise.context.ApplicationScoped; import io.quarkus.arc.Unremovable; import software.amazon.awssdk.services.sns.SnsClient; @ApplicationScoped @Unremovable class UnremovableSnsClient { @Inject SnsClient snsClient; }
3.10. AWS 2 Simple Queue Service (SQS)
Send and receive messages to/from AWS SQS service.
3.10.1. What’s inside
-
AWS Simple Queue Service (SQS) component, URI syntax:
aws2-sqs:queueNameOrArn
Refer to the above link for usage and configuration details.
3.10.2. Maven coordinates
Create a new project with this extension on code.quarkus.redhat.com
Or add the coordinates to your existing project:
<dependency> <groupId>org.apache.camel.quarkus</groupId> <artifactId>camel-quarkus-aws2-sqs</artifactId> </dependency>
3.10.3. SSL in native mode
This extension auto-enables SSL support in native mode. Hence you do not need to add quarkus.ssl.native=true
to your application.properties
yourself. See also Quarkus SSL guide.
3.10.4. Additional Camel Quarkus configuration
3.10.4.1. Optional integration with Quarkus Amazon SQS
If desired, it is possible to use the Quarkus Amazon SQS extension in conjunction with Camel Quarkus AWS 2 Simple Queue Service (SQS). Note that this is fully optional and not mandatory at all. Please follow the Quarkus documentation but beware of the following caveats:
The client type
apache
has to be selected by configuring the following property:quarkus.sqs.sync-client.type=apache
The
SqsClient
has to be made "unremovable" in the sense of Quarkus CDI reference so that Camel Quarkus is able to look it up at runtime. You can reach that e.g. by adding a dummy bean injectingSqsClient
:import jakarta.enterprise.context.ApplicationScoped; import io.quarkus.arc.Unremovable; import software.amazon.awssdk.services.sqs.SqsClient; @ApplicationScoped @Unremovable class UnremovableSqsClient { @Inject SqsClient sqsClient; }
3.11. Azure ServiceBus
Send and receive messages to/from Azure Service Bus.
3.11.1. What’s inside
-
Azure ServiceBus component, URI syntax:
azure-servicebus:topicOrQueueName
Refer to the above link for usage and configuration details.
3.11.2. Maven coordinates
<dependency> <groupId>org.apache.camel.quarkus</groupId> <artifactId>camel-quarkus-azure-servicebus</artifactId> </dependency>
3.12. Azure Storage Blob Service
Store and retrieve blobs from Azure Storage Blob Service using SDK v12.
3.12.1. What’s inside
-
Azure Storage Blob Service component, URI syntax:
azure-storage-blob:accountName/containerName
Refer to the above link for usage and configuration details.
3.12.2. Maven coordinates
Create a new project with this extension on code.quarkus.redhat.com
Or add the coordinates to your existing project:
<dependency> <groupId>org.apache.camel.quarkus</groupId> <artifactId>camel-quarkus-azure-storage-blob</artifactId> </dependency>
3.12.3. Usage
3.12.3.1. Micrometer metrics support
If you wish to enable the collection of Micrometer metrics for the Reactor Netty transports, then you should declare a dependency on quarkus-micrometer
to ensure that they are available via the Quarkus metrics HTTP endpoint.
<dependency> <groupId>io.quarkus</groupId> <artifactId>quarkus-micrometer</artifactId> </dependency>
3.12.4. SSL in native mode
This extension auto-enables SSL support in native mode. Hence you do not need to add quarkus.ssl.native=true
to your application.properties
yourself. See also Quarkus SSL guide.
3.13. Azure Storage Queue Service
The azure-storage-queue component is used for storing and retrieving the messages to/from Azure Storage Queue using Azure SDK v12.
3.13.1. What’s inside
-
Azure Storage Queue Service component, URI syntax:
azure-storage-queue:accountName/queueName
Refer to the above link for usage and configuration details.
3.13.2. Maven coordinates
Create a new project with this extension on code.quarkus.redhat.com
Or add the coordinates to your existing project:
<dependency> <groupId>org.apache.camel.quarkus</groupId> <artifactId>camel-quarkus-azure-storage-queue</artifactId> </dependency>
3.13.3. Usage
3.13.3.1. Micrometer metrics support
If you wish to enable the collection of Micrometer metrics for the Reactor Netty transports, then you should declare a dependency on quarkus-micrometer
to ensure that they are available via the Quarkus metrics HTTP endpoint.
<dependency> <groupId>io.quarkus</groupId> <artifactId>quarkus-micrometer</artifactId> </dependency>
3.13.4. SSL in native mode
This extension auto-enables SSL support in native mode. Hence you do not need to add quarkus.ssl.native=true
to your application.properties
yourself. See also Quarkus SSL guide.
3.14. Bean Validator
Validate the message body using the Java Bean Validation API.
3.14.1. What’s inside
-
Bean Validator component, URI syntax:
bean-validator:label
Refer to the above link for usage and configuration details.
3.14.2. Maven coordinates
Create a new project with this extension on code.quarkus.redhat.com
Or add the coordinates to your existing project:
<dependency> <groupId>org.apache.camel.quarkus</groupId> <artifactId>camel-quarkus-bean-validator</artifactId> </dependency>
3.14.3. Usage
3.14.3.1. Configuring the ValidatorFactory
Implementation of this extension leverages the Quarkus Hibernate Validator extension.
Therefore it is not possible to configure the ValidatorFactory
by Camel’s properties (constraintValidatorFactory
, messageInterpolator
, traversableResolver
, validationProviderResolver
and validatorFactory
).
You can configure the ValidatorFactory
by the creation of beans which will be injected into the default ValidatorFactory
(created by Quarkus). See the Quarkus CDI documentation for more information.
3.14.3.2. Custom validation groups in native mode
When using custom validation groups in native mode, all the interfaces need to be registered for reflection (see the documentation).
Example:
@RegisterForReflection public interface OptionalChecks { }
3.14.4. Camel Quarkus limitations
It is not possible to describe your constraints as XML (by providing the file META-INF/validation.xml), only Java annotations are supported. This is caused by the limitation of the Quarkus Hibernate Validator extension (see the issue).
3.15. Bean
Invoke methods of Java beans
3.15.1. What’s inside
-
Bean component, URI syntax:
bean:beanName
- Bean Method language
-
Class component, URI syntax:
class:beanName
Refer to the above links for usage and configuration details.
3.15.2. Maven coordinates
Create a new project with this extension on code.quarkus.redhat.com
Or add the coordinates to your existing project:
<dependency> <groupId>org.apache.camel.quarkus</groupId> <artifactId>camel-quarkus-bean</artifactId> </dependency>
3.15.3. Usage
Except for invoking methods of beans available in Camel registry, Bean component and Bean method language can also invoke Quarkus CDI beans.
3.16. Bindy
Marshal and unmarshal between POJOs on one side and Comma separated values (CSV), fixed field length or key-value pair (KVP) formats on the other side using Camel Bindy
3.16.1. What’s inside
Refer to the above links for usage and configuration details.
3.16.2. Maven coordinates
Create a new project with this extension on code.quarkus.redhat.com
Or add the coordinates to your existing project:
<dependency> <groupId>org.apache.camel.quarkus</groupId> <artifactId>camel-quarkus-bindy</artifactId> </dependency>
3.16.3. Camel Quarkus limitations
When using camel-quarkus-bindy in native mode, only the build machine’s locale is supported.
For instance, on build machines with french locale, the code below:
BindyDataFormat dataFormat = new BindyDataFormat(); dataFormat.setLocale("ar");
formats numbers the arabic way in JVM mode as expected. However, it formats numbers the french way in native mode.
Without further tuning, the build machine’s default locale would be used. Another locale could be specified with the quarkus.native.user-language and quarkus.native.user-country configuration properties.
3.17. Browse
Inspect the messages received on endpoints supporting BrowsableEndpoint.
3.17.1. What’s inside
-
Browse component, URI syntax:
browse:name
Refer to the above link for usage and configuration details.
3.17.2. Maven coordinates
Create a new project with this extension on code.quarkus.redhat.com
Or add the coordinates to your existing project:
<dependency> <groupId>org.apache.camel.quarkus</groupId> <artifactId>camel-quarkus-browse</artifactId> </dependency>
3.18. Cassandra CQL
Integrate with Cassandra 2.0 using the CQL3 API (not the Thrift API). Based on Cassandra Java Driver provided by DataStax.
3.18.1. What’s inside
-
Cassandra CQL component, URI syntax:
cql:beanRef:hosts:port/keyspace
Refer to the above link for usage and configuration details.
3.18.2. Maven coordinates
Create a new project with this extension on code.quarkus.redhat.com
Or add the coordinates to your existing project:
<dependency> <groupId>org.apache.camel.quarkus</groupId> <artifactId>camel-quarkus-cassandraql</artifactId> </dependency>
3.18.3. Additional Camel Quarkus configuration
3.18.3.1. Cassandra aggregation repository in native mode
In order to use Cassandra aggregation repositories like CassandraAggregationRepository
in native mode, you must enable native serialization support.
In addition, if your exchange bodies are custom types, then they must be registered for serialization by annotating their class declaration with @RegisterForReflection(serialization = true)
.
3.19. CLI Connector
Runtime adapter connecting with Camel CLI
3.19.1. What’s inside
Refer to the above link for usage and configuration details.
3.19.2. Maven coordinates
<dependency> <groupId>org.apache.camel.quarkus</groupId> <artifactId>camel-quarkus-cli-connector</artifactId> </dependency>
3.20. Control Bus
Manage and monitor Camel routes.
3.20.1. What’s inside
-
Control Bus component, URI syntax:
controlbus:command:language
Refer to the above link for usage and configuration details.
3.20.2. Maven coordinates
Create a new project with this extension on code.quarkus.redhat.com
Or add the coordinates to your existing project:
<dependency> <groupId>org.apache.camel.quarkus</groupId> <artifactId>camel-quarkus-controlbus</artifactId> </dependency>
3.20.3. Usage
3.20.3.1. Statistics
When using the stats
command endpoint, the camel-quarkus-management
extension must be added as a project dependency to enable JMX. Maven users will have to add the following to their pom.xml
:
<dependency> <groupId>org.apache.camel.quarkus</groupId> <artifactId>camel-quarkus-management</artifactId> </dependency>
3.20.3.2. Languages
The following languages are supported for use in the Control Bus extension in Red Hat build of Apache Camel for Quarkus:
3.20.3.2.1. Bean
The Bean language can be used to invoke a method on a bean to control the state of routes. The org.apache.camel.quarkus:camel-quarkus-bean
extension must be added to the classpath. Maven users must add the following dependency to the POM:
<dependency> <groupId>org.apache.camel.quarkus</groupId> <artifactId>camel-quarkus-bean</artifactId> </dependency>
In native mode, the bean class must be annotated with @RegisterForReflection
.
3.20.3.2.2. Simple
The Simple language can be used to control the state of routes. The following example uses a ProducerTemplate
to stop a route with the id foo
:
template.sendBody( "controlbus:language:simple", "${camelContext.getRouteController().stopRoute('foo')}" );
To use the OGNL notation, the org.apache.camel.quarkus:camel-quarkus-bean
extension must be added as a dependency.
In native mode, the classes used in the OGNL notation must be registered for reflection. In the above code snippet, the org.apache.camel.spi.RouteController
class returned from camelContext.getRouteController()
must be registered. As this is a third-party class, it cannot be annotated with @RegisterForReflection
directly - instead you can annotate a different class and specifying the target classes to register. For example, the class defining the Camel routes could be annotated with @RegisterForReflection(targets = { org.apache.camel.spi.RouteController.class })
.
Alternatively, add the following line to your src/main/resources/application.properties
:
quarkus.camel.native.reflection.include-patterns = org.apache.camel.spi.RouteController
3.20.4. Camel Quarkus limitations
3.20.4.1. Statistics
The stats
action is not available in native mode as JMX is not supported on GraalVM. Therefore, attempting to build a native image with the camel-quarkus-management
extension on the classpath will result in a build failure.
This feature is not supported in Red Hat build of Apache Camel for Quarkus.
3.21. Core
Camel core functionality and basic Camel languages/ Constant, ExchangeProperty, Header, Ref, Simple and Tokenize
3.21.1. What’s inside
Refer to the above links for usage and configuration details.
3.21.2. Maven coordinates
Create a new project with this extension on code.quarkus.redhat.com
Or add the coordinates to your existing project:
<dependency> <groupId>org.apache.camel.quarkus</groupId> <artifactId>camel-quarkus-core</artifactId> </dependency>
3.21.3. Additional Camel Quarkus configuration
3.21.3.1. Simple language
3.21.3.1.1. Using the OGNL notation
When using the OGNL notation from the simple language, the camel-quarkus-bean
extension should be used.
For instance, the simple expression below is accessing the getAddress()
method on the message body of type Client
.
--- simple("${body.address}") ---
In such a situation, one should take an additional dependency on the camel-quarkus-bean extension as described here. Note that in native mode, some classes may need to be registered for reflection. In the example above, the Client
class needs to be registered for reflection.
3.21.3.1.2. Using dynamic type resolution in native mode
When dynamically resolving a type from simple expressions like:
-
simple("${mandatoryBodyAs(TYPE)}")
-
simple("${type:package.Enum.CONSTANT}")
-
from("…").split(bodyAs(TYPE.class))
-
simple("${body} is TYPE")
It may be needed to register some classes for reflection manually.
For instance, the simple expression below is dynamically resolving the type java.nio.ByteBuffer
at runtime:
--- simple("${body} is 'java.nio.ByteBuffer'") ---
As such, the class java.nio.ByteBuffer
needs to be registered for reflection.
3.21.3.1.3. Using the simple language with classpath resources in native mode
If your route is supposed to load a Simple script from classpath, like in the following example
from("direct:start").transform().simple("resource:classpath:mysimple.txt");
then you need to use Quarkus quarkus.native.resources.includes
property to include the resource in the native executable as demonstrated below:
quarkus.native.resources.includes = mysimple.txt
3.21.3.1.4. Configuring a custom bean via properties in native mode
When specifying a custom bean via properties in native mode with configuration like #class:*
or #type:*
, it may be needed to register some classes for reflection manually.
For instance, the custom bean definition below involves the use of reflection for bean instantiation and setter invocation:
--- camel.beans.customBeanWithSetterInjection = #class:org.example.PropertiesCustomBeanWithSetterInjection camel.beans.customBeanWithSetterInjection.counter = 123 ---
As such, the class PropertiesCustomBeanWithSetterInjection
needs to be registered for reflection, note that field access could be omitted in this case.
Configuration property | Type | Default |
---|---|---|
When set to true, the |
|
|
A comma-separated list of Ant-path style patterns to match Camel service definition files in the classpath. The services defined in the matching files will not be discoverable via the ** The excludes have higher precedence than includes. The excludes defined here can also be used to veto the discoverability of services included by Camel Quarkus extensions.
Example values: |
| |
A comma-separated list of Ant-path style patterns to match Camel service definition files in the classpath. The services defined in the matching files will be discoverable via the
Note that Camel Quarkus extensions may include some services by default. The services selected here added to those services and the exclusions defined in
Example values: |
| |
A comma-separated list of Ant-path style patterns to match Camel service definition files in the classpath. The services defined in the matching files will not be added to Camel registry during application’s static initialization. The excludes have higher precedence than includes. The excludes defined here can also be used to veto the registration of services included by Camel Quarkus extensions.
Example values: |
| |
A comma-separated list of Ant-path style patterns to match Camel service definition files in the classpath. The services defined in the matching files will be added to Camel registry during application’s static initialization unless the given file is excluded via
Note that Camel Quarkus extensions may include some services by default. The services selected here added to those services and the exclusions defined in
Example values: |
| |
If
Setting this to |
|
|
If
Setting this to |
|
|
If
Setting this to |
|
|
If
Setting this to |
|
|
Enable automatic discovery of routes during static initialization. |
|
|
Used for exclusive filtering scanning of RouteBuilder classes. The exclusive filtering takes precedence over inclusive filtering. The pattern is using Ant-path style pattern. Multiple patterns can be specified separated by comma. For example to exclude all classes starting with Bar use: **/Bar* To exclude all routes form a specific package use: com/mycompany/bar/* To exclude all routes form a specific package and its sub-packages use double wildcards: com/mycompany/bar/** And to exclude all routes from two specific packages use: com/mycompany/bar/*,com/mycompany/stuff/* |
| |
Used for inclusive filtering scanning of RouteBuilder classes. The exclusive filtering takes precedence over inclusive filtering. The pattern is using Ant-path style pattern. Multiple patterns can be specified separated by comma. For example to include all classes starting with Foo use: **/Foo* To include all routes form a specific package use: com/mycompany/foo/* To include all routes form a specific package and its sub-packages use double wildcards: com/mycompany/foo/** And to include all routes from two specific packages use: com/mycompany/foo/*,com/mycompany/stuff/* |
| |
A comma separated list of Ant-path style patterns to match class names that should be excluded from registering for reflection. Use the class name format as returned by the
This option narrows down the set selected by This option cannot be used to unregister classes which have been registered internally by Quarkus extensions. |
| |
A comma separated list of Ant-path style patterns to match class names that should be registered for reflection. Use the class name format as returned by the
By default, no classes are included. The set selected by this option can be narrowed down by Note that Quarkus extensions typically register the required classes for reflection by themselves. This option is useful in situations when the built in functionality is not sufficient.
Note that this option enables the full reflective access for constructors, fields and methods. If you need a finer grained control, consider using For this option to work properly, at least one of the following conditions must be satisfied:
- There are no wildcards (
where |
| |
If |
|
|
What to do if it is not possible to extract expressions from a route definition at build time. |
|
|
Indicates whether the expression extraction from the route definitions at build time must be done. If disabled, the expressions are compiled at runtime. |
|
|
Whether to enable the bridging of Camel events to CDI events.
This allows CDI observers to be configured for Camel events. E.g. those belonging to the Note that this configuration item only has any effect when observers configured for Camel events are present in the application. |
|
|
Build time configuration options for enable/disable camel source location |
|
|
A timeout (with millisecond precision) to wait for |
|
|
The action to take when |
|
|
Configuration property fixed at build time. All other configuration properties are overridable at runtime.
3.22. Cron
A generic interface for triggering events at times specified through the Unix cron syntax.
3.22.1. What’s inside
-
Cron component, URI syntax:
cron:name
Refer to the above link for usage and configuration details.
3.22.2. Maven coordinates
Create a new project with this extension on code.quarkus.redhat.com
Or add the coordinates to your existing project:
<dependency> <groupId>org.apache.camel.quarkus</groupId> <artifactId>camel-quarkus-cron</artifactId> </dependency>
3.22.3. Additional Camel Quarkus configuration
The cron component is a generic interface component, as such Camel Quarkus users will need to use the cron extension together with another extension offering an implementation.
3.23. Crypto (JCE)
Sign and verify exchanges using the Signature Service of the Java Cryptographic Extension (JCE).
3.23.1. What’s inside
- Crypto (Java Cryptographic Extension) data format
-
Crypto (JCE) component, URI syntax:
crypto:cryptoOperation:name
- PGP data format
Refer to the above links for usage and configuration details.
3.23.2. Maven coordinates
Create a new project with this extension on code.quarkus.redhat.com
Or add the coordinates to your existing project:
<dependency> <groupId>org.apache.camel.quarkus</groupId> <artifactId>camel-quarkus-crypto</artifactId> </dependency>
3.23.3. SSL in native mode
This extension auto-enables SSL support in native mode. Hence you do not need to add quarkus.ssl.native=true
to your application.properties
yourself. See also Quarkus SSL guide.
3.24. CXF
Expose SOAP WebServices using Apache CXF or connect to external WebServices using CXF WS client.
3.24.1. What’s inside
-
CXF component, URI syntax:
cxf:beanId:address
Refer to the above link for usage and configuration details.
3.24.2. Maven coordinates
Create a new project with this extension on code.quarkus.redhat.com
Or add the coordinates to your existing project:
<dependency> <groupId>org.apache.camel.quarkus</groupId> <artifactId>camel-quarkus-cxf-soap</artifactId> </dependency>
3.24.3. Usage
3.24.3.1. General
camel-quarkus-cxf-soap
uses extensions from the CXF Extensions for Quarkus project - quarkus-cxf
.
This means the set of supported use cases and WS specifications is largely given by quarkus-cxf
.
== Supported extensions
Currently, only these quarkus-cxf extensions are supported:
Implicitly, as transitive dependencies of camel-quarkus-cxf-soap
:
-
quarkus-cxf
-
quarkus-cxf-rt-features-logging
If you need WS-Security or other associated functionality, you can add the following supported extensions:
-
quarkus-cxf-rt-ws-security
-
quarkus-cxf-services-sts
-
quarkus-cxf-xjc-plugins
=== WS-ReliableMessaging
Full support for CXF WS-ReliableMessaging is currently unavailable, and it remains in Technology Preview in version 3.8.
To learn about supported use cases and WS specifications, see the Quarkus CXF Reference.
3.24.3.2. Dependency management
Red Hat build of Apache Camel for Quarkus manages the CXF and quarkus-cxf
versions. You do not need to select compatible versions for those projects.
3.24.3.3. Client
With camel-quarkus-cxf-soap
(no additional dependencies required), you can use CXF clients as producers in Camel routes:
import org.apache.camel.builder.RouteBuilder; import jakarta.enterprise.context.ApplicationScoped; import jakarta.enterprise.context.SessionScoped; import jakarta.enterprise.inject.Produces; import jakarta.inject.Named; @ApplicationScoped public class CxfSoapClientRoutes extends RouteBuilder { @Override public void configure() { /* You can either configure the client inline */ from("direct:cxfUriParamsClient") .to("cxf://http://localhost:8082/calculator-ws?wsdlURL=wsdl/CalculatorService.wsdl&dataFormat=POJO&serviceClass=org.foo.CalculatorService"); /* Or you can use a named bean produced below by beanClient() method */ from("direct:cxfBeanClient") .to("cxf:bean:beanClient?dataFormat=POJO"); } @Produces @SessionScoped @Named CxfEndpoint beanClient() { final CxfEndpoint result = new CxfEndpoint(); result.setServiceClass(CalculatorService.class); result.setAddress("http://localhost:8082/calculator-ws"); result.setWsdlURL("wsdl/CalculatorService.wsdl"); // a resource in the class path return result; } }
The CalculatorService
may look like the following:
import jakarta.jws.WebMethod; import jakarta.jws.WebService; @WebService(targetNamespace = CalculatorService.TARGET_NS) 1 public interface CalculatorService { public static final String TARGET_NS = "http://acme.org/wscalculator/Calculator"; @WebMethod 2 public int add(int intA, int intB); @WebMethod 3 public int subtract(int intA, int intB); @WebMethod 4 public int divide(int intA, int intB); @WebMethod 5 public int multiply(int intA, int intB); }
You can test this client application against the quay.io/l2x6/calculator-ws:1.2 container that implements this service endpoint interface:
$ docker run -p 8082:8080 quay.io/l2x6/calculator-ws:1.2
quarkus-cxf
supports injecting SOAP clients using @io.quarkiverse.cxf.annotation.CXFClient
annotation. Refer to the SOAP Clients chapter of quarkus-cxf
user guide for more details.
3.24.3.4. Server
With camel-quarkus-cxf-soap
, you can expose SOAP endpoints as consumers in Camel routes. No additional dependencies are required for this use case.
import org.apache.camel.builder.RouteBuilder; import jakarta.enterprise.context.ApplicationScoped; import jakarta.enterprise.inject.Produces; import jakarta.inject.Named; @ApplicationScoped public class CxfSoapRoutes extends RouteBuilder { @Override public void configure() { /* A CXF Service configured through a CDI bean */ from("cxf:bean:helloBeanEndpoint") .setBody().simple("Hello ${body} from CXF service"); /* A CXF Service configured through Camel URI parameters */ from("cxf:///hello-inline?wsdlURL=wsdl/HelloService.wsdl&serviceClass=org.foo.HelloService") .setBody().simple("Hello ${body} from CXF service"); } @Produces @ApplicationScoped @Named CxfEndpoint helloBeanEndpoint() { final CxfEndpoint result = new CxfEndpoint(); result.setServiceClass(HelloService.class); result.setAddress("/hello-bean"); result.setWsdlURL("wsdl/HelloService.wsdl"); return result; } }
The path under which these two services will be served depends on the value of quarkus.cxf.path
configuration property which can for example be set in application.properties
:
application.properties
quarkus.cxf.path = /soap-services
With this configuration in place, our two services can be reached under http://localhost:8080/soap-services/hello-bean
and http://localhost:8080/soap-services/hello-inline
respectively.
The WSDL can be accessed by adding ?wsdl
to the above URLs.
Do not use quarkus.cxf.path = /
in your application unless you are 100% sure that no other extension will want to expose HTTP endpoints.
Before quarkus-cxf
2.0.0 (i.e. before Red Hat build of Apache Camel for Quarkus 3.0.0), the default value of quarkus.cxf.path
was /
. The default was changed because it prevented other Quarkus extensions from exposing any further HTTP endpoints. Among others, RESTEasy, Vert.x, SmallRye Health (no health endpoints exposed!) were impacted by this.
quarkus-cxf
supports alternative ways of exposing SOAP endpoints. Refer to the SOAP Services chapter of quarkus-cxf
user guide for more details.
3.24.3.5. Logging of requests and responses
You can enable verbose logging of SOAP messages for both clients and servers with org.apache.cxf.ext.logging.LoggingFeature
:
import org.apache.camel.builder.RouteBuilder; import org.apache.cxf.ext.logging.LoggingFeature; import jakarta.enterprise.context.ApplicationScoped; import jakarta.enterprise.context.SessionScoped; import jakarta.enterprise.inject.Produces; import jakarta.inject.Named; @ApplicationScoped public class MyBeans { @Produces @ApplicationScoped @Named("prettyLoggingFeature") public LoggingFeature prettyLoggingFeature() { final LoggingFeature result = new LoggingFeature(); result.setPrettyLogging(true); return result; } @Inject @Named("prettyLoggingFeature") LoggingFeature prettyLoggingFeature; @Produces @SessionScoped @Named CxfEndpoint cxfBeanClient() { final CxfEndpoint result = new CxfEndpoint(); result.setServiceClass(CalculatorService.class); result.setAddress("https://acme.org/calculator"); result.setWsdlURL("wsdl/CalculatorService.wsdl"); result.getFeatures().add(prettyLoggingFeature); return result; } @Produces @ApplicationScoped @Named CxfEndpoint helloBeanEndpoint() { final CxfEndpoint result = new CxfEndpoint(); result.setServiceClass(HelloService.class); result.setAddress("/hello-bean"); result.setWsdlURL("wsdl/HelloService.wsdl"); result.getFeatures().add(prettyLoggingFeature); return result; } }
The support for org.apache.cxf.ext.logging.LoggingFeature
is provided by io.quarkiverse.cxf:quarkus-cxf-rt-features-logging
as a camel-quarkus-cxf-soap
dependency. You do not need to add it explicitly to your application.
3.24.3.6. WS Specifications
The extent of supported WS specifications is given by the Quarkus CXF project.
camel-quarkus-cxf-soap
covers only the following specifications via the io.quarkiverse.cxf:quarkus-cxf
extension:
- JAX-WS
- JAXB
- WS-Addressing
- WS-Policy
- MTOM
If your application requires some other WS specification, such as WS-Security or WS-Trust, you must add an additional Quarkus CXF dependency covering it. Refer to Quarkus CXF Reference page to see which WS specifications are covered by which Quarkus CXF extensions.
Both Red Hat build of Apache Camel for Quarkus and Quarkus CXF contain a number of integration tests which can serve as executable examples of applications that implement various WS specifications.
3.24.3.7. Tooling
quarkus-cxf
wraps the following two CXF tools:
-
wsdl2Java
- for generating service classes from WSDL -
java2ws
- for generating WSDL from Java classes
For wsdl2Java
to work properly, your application will have to directly depend on io.quarkiverse.cxf:quarkus-cxf
.
While wsdlvalidator
is not supported, you can use wsdl2Java
with the following configuration in application.properties
to validate your WSDLs:
application.properties
quarkus.cxf.codegen.wsdl2java.additional-params = -validate
3.24.3.8. Possible DoS vector with CXF clients using java.net.http.HttpClient
If your CXF clients are using java.net.http.HttpClient
as the underlying HTTP client, then due to CXF issue, the application may crash if many clients are created, as their threads do not terminated.
The problem occurs with java.net.http.HttpClient
when CXF clients is created repeatedly, for example per request. If you keep the clients throughout the whole lifespan of the application, this issue does not occur.
Since Apache Camel for Quarkus 3.2.0 and Quarkus CXF 2.2.3, the selection of the HTTP client implementation for some specific CXF client is controlled via quarkus.cxf.client.yourClient.http-conduit-factory
property. By default, the CXF clients created by Quarkus CXF use java.net.HttpURLConnection
as an HTTP client and thus, this issue does not occur by default. This issue may occur if you set quarkus.cxf.client.yourClient.http-conduit-factory=HttpClientHTTPConduitFactory
.
3.24.3.8.1. Mitigation of the DoS vector
-
Only use
java.net.http.HttpClient
-backed CXF clients if you are absolutely certain that the clients are only created once during the lifespan of the application. -
Use CXF clients backed by different HTTP client implementations such as HC5 or
java.net.HttpURLConnection
.
3.25. Data Format
Use a Camel Data Format as a regular Camel Component.
For more details of the supported data formats in Red Hat build of Apache Camel for Quarkus, see Supported Data Formats.
3.25.1. What’s inside
-
Data Format component, URI syntax:
dataformat:name:operation
Refer to the above link for usage and configuration details.
3.25.2. Maven coordinates
Create a new project with this extension on code.quarkus.redhat.com
Or add the coordinates to your existing project:
<dependency> <groupId>org.apache.camel.quarkus</groupId> <artifactId>camel-quarkus-dataformat</artifactId> </dependency>
3.26. Dataset
Provide data for load and soak testing of your Camel application.
3.26.1. What’s inside
-
Dataset component, URI syntax:
dataset:name
-
DataSet Test component, URI syntax:
dataset-test:name
Refer to the above links for usage and configuration details.
3.26.2. Maven coordinates
Create a new project with this extension on code.quarkus.redhat.com
Or add the coordinates to your existing project:
<dependency> <groupId>org.apache.camel.quarkus</groupId> <artifactId>camel-quarkus-dataset</artifactId> </dependency>
3.27. Direct
Call another endpoint from the same Camel Context synchronously.
3.27.1. What’s inside
-
Direct component, URI syntax:
direct:name
Refer to the above link for usage and configuration details.
3.27.2. Maven coordinates
Create a new project with this extension on code.quarkus.redhat.com
Or add the coordinates to your existing project:
<dependency> <groupId>org.apache.camel.quarkus</groupId> <artifactId>camel-quarkus-direct</artifactId> </dependency>
3.28. FHIR
Exchange information in the healthcare domain using the FHIR (Fast Healthcare Interoperability Resources) standard. Marshall and unmarshall FHIR objects to/from JSON. Marshall and unmarshall FHIR objects to/from XML.
3.28.1. What’s inside
-
FHIR component, URI syntax:
fhir:apiName/methodName
- FHIR JSon data format
- FHIR XML data format
Refer to the above links for usage and configuration details.
3.28.2. Maven coordinates
Create a new project with this extension on code.quarkus.redhat.com
Or add the coordinates to your existing project:
<dependency> <groupId>org.apache.camel.quarkus</groupId> <artifactId>camel-quarkus-fhir</artifactId> </dependency>
3.28.3. SSL in native mode
This extension auto-enables SSL support in native mode. Hence you do not need to add quarkus.ssl.native=true
to your application.properties
yourself. See also Quarkus SSL guide.
3.28.4. Additional Camel Quarkus configuration
By default, only FHIR versions R4
& DSTU3
are enabled in native mode, since they are the default values on the FHIR component and DataFormat.
Configuration property | Type | Default |
---|---|---|
Enable FHIR DSTU2 Specs in native mode. |
|
|
Enable FHIR DSTU2_HL7ORG Specs in native mode. |
|
|
Enable FHIR DSTU2_1 Specs in native mode. |
|
|
Enable FHIR DSTU3 Specs in native mode. |
|
|
Enable FHIR R4 Specs in native mode. |
|
|
Enable FHIR R5 Specs in native mode. |
|
|
Configuration property fixed at build time. All other configuration properties are overridable at runtime.
3.29. File
Read and write files.
3.29.1. What’s inside
-
File component, URI syntax:
file:directoryName
Refer to the above link for usage and configuration details.
3.29.2. Maven coordinates
Create a new project with this extension on code.quarkus.redhat.com
Or add the coordinates to your existing project:
<dependency> <groupId>org.apache.camel.quarkus</groupId> <artifactId>camel-quarkus-file</artifactId> </dependency>
3.29.3. Additional Camel Quarkus configuration
3.29.3.1. Having only a single consumer in a cluster consuming from a given endpoint
When the same route is deployed on multiple JVMs, it could be interesting to use this extension in conjunction with the Master one. In such a setup, a single consumer will be active at a time across the whole camel master namespace.
For instance, having the route below deployed on multiple JVMs:
from("master:ns:timer:test?period=100").log("Timer invoked on a single JVM at a time");
It’s possible to enable the file cluster service with a property like below:
quarkus.camel.cluster.file.enabled = true quarkus.camel.cluster.file-root = target/cluster-folder-where-lock-file-will-be-held
As a result, a single consumer will be active across the ns
camel master namespace. It means that, at a given time, only a single timer will generate exchanges across all JVMs. In other words, messages will be logged every 100ms on a single JVM at a time.
The file cluster service could further be tuned by tweaking quarkus.camel.cluster.file.*
properties.
Configuration property | Type | Default |
---|---|---|
Whether a File Lock Cluster Service should be automatically configured according to 'quarkus.camel.cluster.file.*' configurations. |
|
|
The cluster service ID (defaults to null). |
| |
The root path (defaults to null). |
| |
The service lookup order/priority (defaults to 2147482647). |
| |
The time to wait before starting to try to acquire lock (defaults to 1000ms). |
| |
The time to wait between attempts to try to acquire lock (defaults to 10000ms). |
| |
The custom attributes associated to the service (defaults to empty map). |
|
Configuration property fixed at build time. All other configuration properties are overridable at runtime.
3.30. Flink
Send DataSet jobs to an Apache Flink cluster.
3.30.1. What’s inside
-
Flink component, URI syntax:
flink:endpointType
Refer to the above link for usage and configuration details.
3.30.2. Maven coordinates
<dependency> <groupId>org.apache.camel.quarkus</groupId> <artifactId>camel-quarkus-flink</artifactId> </dependency>
3.31. FTP
Upload and download files to/from SFTP, FTP or SFTP servers
3.31.1. What’s inside
-
FTP component, URI syntax:
ftp:host:port/directoryName
-
FTPS component, URI syntax:
ftps:host:port/directoryName
-
SFTP component, URI syntax:
sftp:host:port/directoryName
Refer to the above links for usage and configuration details.
3.31.2. Maven coordinates
Create a new project with this extension on code.quarkus.redhat.com
Or add the coordinates to your existing project:
<dependency> <groupId>org.apache.camel.quarkus</groupId> <artifactId>camel-quarkus-ftp</artifactId> </dependency>
3.32. Google BigQuery
Access Google Cloud BigQuery service using SQL queries or Google Client Services API
3.32.1. What’s inside
-
Google BigQuery component, URI syntax:
google-bigquery:projectId:datasetId:tableId
-
Google BigQuery Standard SQL component, URI syntax:
google-bigquery-sql:projectId:queryString
Refer to the above links for usage and configuration details.
3.32.2. Maven coordinates
Create a new project with this extension on code.quarkus.redhat.com
Or add the coordinates to your existing project:
<dependency> <groupId>org.apache.camel.quarkus</groupId> <artifactId>camel-quarkus-google-bigquery</artifactId> </dependency>
3.32.3. Usage
If you want to read SQL scripts from the classpath with google-bigquery-sql
in native mode, then you will need to ensure that they are added to the native image via the quarkus.native.resources.includes
configuration property. Please check Quarkus documentation for more details.
3.33. Google Pubsub
Send and receive messages to/from Google Cloud Platform PubSub Service.
3.33.1. What’s inside
-
Google Pubsub component, URI syntax:
google-pubsub:projectId:destinationName
Refer to the above link for usage and configuration details.
3.33.2. Maven coordinates
Create a new project with this extension on code.quarkus.redhat.com
Or add the coordinates to your existing project:
<dependency> <groupId>org.apache.camel.quarkus</groupId> <artifactId>camel-quarkus-google-pubsub</artifactId> </dependency>
3.33.3. Camel Quarkus limitations
By default, the Camel PubSub component uses JDK object serialization via ObjectOutputStream
whenever the message body is anything other than String
or byte[]
.
Since such serialization is not yet supported by GraalVM, this extension provides a custom Jackson based serializer to serialize complex message payloads as JSON.
If your payload contains binary data, then you will need to handle that by creating a custom Jackson Serializer / Deserializer. Refer to the Quarkus Jackson guide for information on how to do this.
3.34. gRPC
Expose gRPC endpoints and access external gRPC endpoints.
3.34.1. What’s inside
-
gRPC component, URI syntax:
grpc:host:port/service
Refer to the above link for usage and configuration details.
3.34.2. Maven coordinates
Create a new project with this extension on code.quarkus.redhat.com
Or add the coordinates to your existing project:
<dependency> <groupId>org.apache.camel.quarkus</groupId> <artifactId>camel-quarkus-grpc</artifactId> </dependency>
3.34.3. Usage
3.34.3.1. Protobuf generated code
Camel Quarkus gRPC can generate gRPC service stubs for .proto
files. When using Maven, ensure that you have enabled the generate-code
goals of the quarkus-maven-plugin
in your project build.
<build> <plugins> <plugin> <groupId>io.quarkus</groupId> <artifactId>quarkus-maven-plugin</artifactId> <version>${quarkus.platform.version}</version> <extensions>true</extensions> <executions> <execution> <goals> <goal>build</goal> <goal>generate-code</goal> <goal>generate-code-tests</goal> </goals> </execution> </executions> </plugin> </plugins> </build>
With this configuration, you can put your service and message definitions into the src/main/proto
directory and the quarkus-maven-plugin
will generate code from your .proto
files.
3.34.3.1.1. Scanning proto
files with imports
The Protocol Buffers specification provides a way to import proto files. You can control the scope of dependencies to scan by adding configuration property quarkus.camel.grpc.codegen.scan-for-imports
property to application.properties
. The available options are outlined below.
-
all
- Scan all dependencies -
none
- Disable dependency scanning. Use only the proto definitions defined insrc/main/proto
orsrc/test/proto
-
groupId1:artifactId1,groupId2:artifactId2
- Scan only the dependencies matching thegroupId
andartifactId
list
The default value is com.google.protobuf:protobuf-java
.
3.34.3.1.2. Scanning proto
files from dependencies
If you have proto files shared across multiple dependencies, you can generate gRPC service stubs for them by adding configuration property quarkus.camel.grpc.codegen.scan-for-proto
to application.properties
.
First add a dependency for the artifact(s) containing proto files to your project. Next, enable proto file dependency scanning.
quarkus.camel.grpc.codegen.scan-for-proto=org.my.groupId1:my-artifact-id-1,org.my.groupId2:my-artifact-id-2
It is possible to include / exclude specific proto files from dependency scanning via configuration properties.
The configuration property name suffix is the Maven groupId
/ artifactId
for the dependency to configure includes / excludes on. Paths are relative to the classpath location of the proto files within the dependency. Paths can be an explicit path to a proto file, or as glob patterns to include / exclude multiple files.
quarkus.camel.grpc.codegen.scan-for-proto-includes."<groupId>\:<artifactId>"=foo/**,bar/**,baz/a-proto.proto quarkus.camel.grpc.codegen.scan-for-proto-excludes."<groupId>\:<artifactId>"=foo/private/**,baz/another-proto.proto
The :
character within property keys must be escaped with \
.
3.34.3.2. Accessing classpath resources in native mode
The gRPC component has various options where resources are resolved from the classpath:
-
keyCertChainResource
-
keyResource
-
serviceAccountResource
-
trustCertCollectionResource
When using these options in native mode, you must ensure that any such resources are included in the native image.
This can be accomplished by adding the configuration property quarkus.native.resources.includes
to application.properties
. For example, to include SSL / TLS keys and certificates.
quarkus.native.resources.includes = certs/*.pem,certs.*.key
3.34.4. Camel Quarkus limitations
3.34.4.1. Integration with Quarkus gRPC is not supported
At present there is no support for integrating Camel Quarkus gRPC with Quarkus gRPC. If you have both the camel-quarkus-grpc
and quarkus-grpc
extension dependency on the classpath, you are likely to encounter problems at build time when compiling your application.
3.34.5. Additional Camel Quarkus configuration
Configuration property | Type | Default |
---|---|---|
If |
|
|
Camel Quarkus gRPC code generation can scan application dependencies for .proto files to generate Java stubs from them. This property sets the scope of the dependencies to scan. Applicable values: - none - default - don’t scan dependencies - a comma separated list of groupId:artifactId coordinates to scan - all - scan all dependencies |
|
|
Camel Quarkus gRPC code generation can scan dependencies for .proto files that can be imported by protos in this applications. Applicable values: - none - default - don’t scan dependencies - a comma separated list of groupId:artifactId coordinates to scan - all - scan all dependencies The default is com.google.protobuf:protobuf-java. |
|
|
Package path or file glob pattern includes per dependency containing .proto files to be considered for inclusion. |
| |
Package path or file glob pattern includes per dependency containing .proto files to be considered for exclusion. |
|
Configuration property fixed at build time. All other configuration properties are overridable at runtime.
3.35. Gson
Marshal POJOs to JSON and back using Gson
3.35.1. What’s inside
Refer to the above link for usage and configuration details.
3.35.2. Maven coordinates
Create a new project with this extension on code.quarkus.redhat.com
Or add the coordinates to your existing project:
<dependency> <groupId>org.apache.camel.quarkus</groupId> <artifactId>camel-quarkus-gson</artifactId> </dependency>
3.35.3. Additional Camel Quarkus configuration
3.35.3.1. Marshaling/Unmarshaling objects in native mode
When marshaling/unmarshaling objects in native mode, all the serialized classes need to be registered for reflection. As such, when using GsonDataFormat.setUnmarshalType(…)
, GsonDataFormat.setUnmarshalTypeName(…)
and even GsonDataFormat.setUnmarshalGenericType(…)
, the unmarshal type as well as sub field types should be registered for reflection. See a working example in this integration test.
3.36. HL7
Marshal and unmarshal HL7 (Health Care) model objects using the HL7 MLLP codec.
3.36.1. What’s inside
Refer to the above links for usage and configuration details.
3.36.2. Maven coordinates
Create a new project with this extension on code.quarkus.redhat.com
Or add the coordinates to your existing project:
<dependency> <groupId>org.apache.camel.quarkus</groupId> <artifactId>camel-quarkus-hl7</artifactId> </dependency>
3.36.3. Camel Quarkus limitations
For MLLP with TCP, Netty is the only supported means of running an Hl7 MLLP listener. Mina is not supported since it has no GraalVM native support at present.
Optional support for HL7MLLPNettyEncoderFactory
& HL7MLLPNettyDecoderFactory
codecs can be obtained by adding a dependency in your project pom.xml
to camel-quarkus-netty
.
3.37. HTTP
Send requests to external HTTP servers using Apache HTTP Client 5.x.
3.37.1. What’s inside
-
HTTP component, URI syntax:
http://httpUri
-
HTTPS (Secure) component, URI syntax:
https://httpUri
Refer to the above links for usage and configuration details.
3.37.2. Maven coordinates
Create a new project with this extension on code.quarkus.redhat.com
Or add the coordinates to your existing project:
<dependency> <groupId>org.apache.camel.quarkus</groupId> <artifactId>camel-quarkus-http</artifactId> </dependency>
3.37.3. SSL in native mode
This extension auto-enables SSL support in native mode. Hence you do not need to add quarkus.ssl.native=true
to your application.properties
yourself. See also Quarkus SSL guide.
3.37.4. Additional Camel Quarkus configuration
- Check the Character encodings section of the Native mode guide if you expect your application to send or receive requests using non-default encodings.
3.38. Infinispan
Read and write from/to Infinispan distributed key/value store and data grid.
3.38.1. What’s inside
-
Infinispan component, URI syntax:
infinispan:cacheName
Refer to the above link for usage and configuration details.
3.38.2. Maven coordinates
Create a new project with this extension on code.quarkus.redhat.com
Or add the coordinates to your existing project:
<dependency> <groupId>org.apache.camel.quarkus</groupId> <artifactId>camel-quarkus-infinispan</artifactId> </dependency>
3.38.3. Additional Camel Quarkus configuration
3.38.3.1. Infinispan Client Configuration
You can either configure the Infinispan client via the relevant Camel Infinispan component & endpoint options, or you may use the Quarkus Infinispan extension configuration properties.
Note that if you choose to use Quarkus Infinispan configuration properties, you must add an injection point for the RemoteCacheManager
in order for it to be discoverable by the Camel Infinispan component. For example:
public class Routes extends RouteBuilder { // Injects the default unnamed RemoteCacheManager @Inject RemoteCacheManager cacheManager; // If configured, injects an optional named RemoteCacheManager @Inject @InfinispanClientName("myNamedClient") RemoteCacheManager namedCacheManager; @Override public void configure() { // Route configuration here... } }
3.38.3.2. Camel Infinispan InfinispanRemoteAggregationRepository
in native mode
If you chose to use the InfinispanRemoteAggregationRepository
in native mode, then you must enable native serialization support.
3.39. Avro Jackson
Marshal POJOs to Avro and back using Jackson.
3.39.1. What’s inside
Refer to the above link for usage and configuration details.
3.39.2. Maven coordinates
Create a new project with this extension on code.quarkus.redhat.com
Or add the coordinates to your existing project:
<dependency> <groupId>org.apache.camel.quarkus</groupId> <artifactId>camel-quarkus-jackson-avro</artifactId> </dependency>
3.40. Protobuf Jackson
Marshal POJOs to Protobuf and back using Jackson.
3.40.1. What’s inside
Refer to the above link for usage and configuration details.
3.40.2. Maven coordinates
Create a new project with this extension on code.quarkus.redhat.com
Or add the coordinates to your existing project:
<dependency> <groupId>org.apache.camel.quarkus</groupId> <artifactId>camel-quarkus-jackson-protobuf</artifactId> </dependency>
3.41. Jackson
Marshal POJOs to JSON and back using Jackson
3.41.1. What’s inside
Refer to the above link for usage and configuration details.
3.41.2. Maven coordinates
Create a new project with this extension on code.quarkus.redhat.com
Or add the coordinates to your existing project:
<dependency> <groupId>org.apache.camel.quarkus</groupId> <artifactId>camel-quarkus-jackson</artifactId> </dependency>
3.41.3. Usage
3.41.3.1. Configuring the Jackson ObjectMapper
There are a few ways of configuring the ObjectMapper
that the JacksonDataFormat
uses. These are outlined below.
3.41.3.1.1. ObjectMapper
created internally by JacksonDataFormat
By default, JacksonDataFormat
will create its own ObjectMapper
and use the various configuration options on the DataFormat
to configure additional Jackson modules, pretty printing and other features.
3.41.3.1.2. Custom ObjectMapper
for JacksonDataFormat
You can pass a custom ObjectMapper
instance to JacksonDataFormat
as follows.
import com.fasterxml.jackson.databind.ObjectMapper; import org.apache.camel.builder.RouteBuilder; import org.apache.camel.component.jackson.JacksonDataFormat; public class Routes extends RouteBuilder { public void configure() { ObjectMapper mapper = new ObjectMapper(); JacksonDataFormat dataFormat = new JacksonDataFormat(); dataFormat.setObjectMapper(mapper); // Use the dataFormat instance in a route definition from("direct:my-direct").marshal(dataFormat) } }
3.41.3.1.3. Using the Quarkus Jackson ObjectMapper
with JacksonDataFormat
The Quarkus Jackson extension exposes an ObjectMapper
CDI bean which can be discovered by the JacksonDataFormat
.
import org.apache.camel.builder.RouteBuilder; import org.apache.camel.component.jackson.JacksonDataFormat; public class Routes extends RouteBuilder { public void configure() { JacksonDataFormat dataFormat = new JacksonDataFormat(); // Make JacksonDataFormat discover the Quarkus Jackson `ObjectMapper` from the Camel registry dataFormat.setAutoDiscoverObjectMapper(true); // Use the dataFormat instance in a route definition from("direct:my-direct").marshal(dataFormat) } }
If you are using the JSON binding mode in the Camel REST DSL and want to use the Quarkus Jackson ObjectMapper
, it can be achieved as follows.
import org.apache.camel.builder.RouteBuilder; @ApplicationScoped public class Routes extends RouteBuilder { public void configure() { restConfiguration().dataFormatProperty("autoDiscoverObjectMapper", "true"); // REST definition follows... } }
You can perform customizations on the Quarkus ObjectMapper
with a ObjectMapperCustomizer
.
import com.fasterxml.jackson.databind.ObjectMapper; import io.quarkus.jackson.ObjectMapperCustomizer; @Singleton public class RegisterCustomModuleCustomizer implements ObjectMapperCustomizer { public void customize(ObjectMapper mapper) { mapper.registerModule(new CustomModule()); } }
It’s also possible to @Inject
the Quarkus ObjectMapper
and pass it to the JacksonDataFormat
.
import com.fasterxml.jackson.databind.ObjectMapper; import org.apache.camel.builder.RouteBuilder; import org.apache.camel.component.jackson.JacksonDataFormat; @ApplicationScoped public class Routes extends RouteBuilder { @Inject ObjectMapper mapper; public void configure() { JacksonDataFormat dataFormat = new JacksonDataFormat(); dataFormat.setObjectMapper(mapper); // Use the dataFormat instance in a route definition from("direct:my-direct").marshal(dataFormat) } }
3.42. JacksonXML
Unmarshal an XML payloads to POJOs and back using XMLMapper extension of Jackson.
3.42.1. What’s inside
Refer to the above link for usage and configuration details.
3.42.2. Maven coordinates
Create a new project with this extension on code.quarkus.redhat.com
Or add the coordinates to your existing project:
<dependency> <groupId>org.apache.camel.quarkus</groupId> <artifactId>camel-quarkus-jacksonxml</artifactId> </dependency>
3.43. Jasypt
Security using Jasypt
3.43.1. What’s inside
Refer to the above link for usage and configuration details.
3.43.2. Maven coordinates
Create a new project with this extension on code.quarkus.redhat.com
Or add the coordinates to your existing project:
<dependency> <groupId>org.apache.camel.quarkus</groupId> <artifactId>camel-quarkus-jasypt</artifactId> </dependency>
3.43.3. Usage
The configuration of Jasypt in Camel Quarkus is driven by configuration properties.
The minimum expectation is that you provide a master password for Jasypt decryption with configuration property quarkus.camel.jasypt.password
.
You can choose the encryption algorithm and other aspects of the Jasypt configuration via the quarkus.camel.jasypt
options described below.
By default, you do not need to write custom code to configure the Camel JasyptPropertiesParser
or PropertiesComponent
. This is done for you automatically.
Any Camel configuration property added to application.properties
can be secured with Jasypt. To encrypt a value, there is a utility that can be run with JBang.
jbang org.apache.camel:camel-jasypt:{camel-version} -c encrypt -p secret-password -i "Some secret content"
If you choose to use a different Jasypt algorithm to the default (PBEWithMD5AndDES
), you must provide -a
(algorithm), -riga
(IV generator algorithm) & -rsga
(Salt generator algorithm) arguments to set the correct algorithms used in encryption. Else your application will not be able to decrypt configuration values.
Alternatively, when running in dev mode, open the Dev UI and click the 'utilities' link in the Camel Jasypt pane. Next, select either the 'Decrypt' or 'Encrypt' action, enter some text and click the submit button. The result of the action is output together with a button to copy it to the clipboard.
Configuration properties can be added to application.properties
with the encrypted value enclosed within ENC()
For example.
my.secret = ENC(BoDSRQfdBME4V/AcugPOkaR+IcyKufGz)
In your Camel routes, you can refer to the property name using the standard placeholder syntax and its value will get decrypted.
public class MySecureRoute extends RouteBuilder { @Override public void configure() { from("timer:tick?period=5s") .to("{{my.secret}}"); } }
You can use the ability to mask security sensitive configuration in Camel by suffixing property values with .secret
. You can also disable the startup configuration summary with the configuration camel.main.autoConfigurationLogSummary = false
.
3.43.3.1. Injecting encrypted configuration
You can use the @ConfigProperty
annotation to inject encrypted configuration into your Camel routes or CDI beans.
@ApplicationScoped public class MySecureRoute extends RouteBuilder { @ConfigInject("my.secret") String mySecret; @Override public void configure() { from("timer:tick?period=5s") .to(mySecret); } }
3.43.3.1.1. Securing alternate configuration sources
If you prefer to keep your secret configuration in a file separate to application.properties
, you can use the quarkus.config.locations
configuration option to specify additional configuration files.
In native mode you must also add any additional configuration file resource paths to quarkus.native.resources.includes
.
3.43.3.1.2. Finer control of Jasypt configuration
If you require finer control of the Jasypt configuration than that provided by the default configuration, the following options are available.
3.43.3.1.2.1. JasyptConfigurationCustomizer
Implement a JasyptConfigurationCustomizer
class to customize any aspect of the Jasypt EnvironmentStringPBEConfig
.
package org.acme; import org.apache.camel.quarkus.component.jasypt.JasyptConfigurationCustomizer; import org.jasypt.encryption.pbe.config.EnvironmentStringPBEConfig; import org.jasypt.iv.RandomIvGenerator; import org.jasypt.salt.RandomSaltGenerator; public class JasyptConfigurationCustomizer implements JasyptConfigurationCustomizer { public void customize(EnvironmentStringPBEConfig config) { // Custom algorithms config.setAlgorithm("PBEWithHmacSHA256AndAES_256"); config.setSaltGenerator(new RandomSaltGenerator("PKCS11")); config.setIvGenerator(new RandomIvGenerator("PKCS11")); // Additional customizations... } }
In application.properties
add the quarkus.camel.jasypt.configuration-customizer-class-name
configuration property.
quarkus.camel.jasypt.configuration-customizer-class-name = org.acme.MyJasyptEncryptorCustomizer
3.43.3.1.2.2. Disabling automatic Jasypt configuration
If you prefer to use the 'classic' Java DSL way of configuring Camel Jasypt, you can disable the automatic configuration with quarkus.camel.jasypt.enabled = false
.
This allows you to configure the Camel JasyptPropertiesParser
and PropertiesComponent
manually.
In this mode, you cannot use the @ConfigProperty
annotation to inject encrypted configuration properties.
import org.apache.camel.CamelContext; import org.apache.camel.component.jasypt.JasyptPropertiesParser; import org.apache.camel.component.properties.PropertiesComponent; public class MySecureRoute extends RouteBuilder { @Override public void configure() { JasyptPropertiesParser jasypt = new JasyptPropertiesParser(); jasypt.setPassword("secret"); PropertiesComponent component = (PropertiesComponent) getContext().getPropertiesComponent(); jasypt.setPropertiesComponent(component); component.setPropertiesParser(jasypt); from("timer:tick?period=5s") .to("{{my.secret}}"); } }
If you call setLocation(…)
on the PropertiesComponent
to specify a custom configuration file location using the classpath:
prefix, you must add the file to quarkus.native.resources.includes
so that it can be loaded in native mode.
3.43.4. Additional Camel Quarkus configuration
Configuration property | Type | Default |
---|---|---|
Setting this option to false will disable Jasypt integration with Quarkus SmallRye configuration. You can however, manually configure Jasypt with Camel in the 'classic' way of manually configuring JasyptPropertiesParser and PropertiesComponent. Refer to the usage section for more details. |
|
|
The algorithm to be used for decryption. |
|
|
The master password used by Jasypt for decrypting configuration values. This option supports prefixes which influence the master password lookup behaviour.
|
| |
Configures the Jasypt StandardPBEStringEncryptor with a RandomIvGenerator using the given algorithm. |
|
|
Configures the Jasypt StandardPBEStringEncryptor with a RandomSaltGenerator using the given algorithm. |
|
|
The fully qualified class name of an org.apache.camel.quarkus.component.jasypt.JasyptConfigurationCustomizer implementation. This provides the optional capability of having full control over the Jasypt configuration. |
|
Configuration property fixed at build time. All other configuration properties are overridable at runtime.
3.43.5. Camel Quarkus limitations
3.43.6. Jasypt: quarkus.camel.jasypt.enabled=false not working
The camel-quarkus-jasypt
extension has an issue resolving configuration properties when they are provided from system properties or environment variables. For example, passing -Dquarkus.camel.jasypt.enabled=false
or -Dquarkus.camel.jasypt.password=my-password
does not work.
To work around this you can specify quarkus.camel.jasypt.enabled
in application.properties
.
Disable jasypt
quarkus.camel.jasypt.enabled = false
To override quarkus.camel.jasypt.password
from a system property or environment variable you can configure application.properties
as follows:
Either hard code the password in application.properties
Hardcoded password
quarkus.camel.jasypt.password = my-password
Or it’s possible to have the password resolved from a system property or environment variable using the 'sys' or 'sysenv' prefix.
Password with sys prefix
quarkus.camel.jasypt.password = sys:jasyptPassword
Then build the application with your desired password.
Building with password
mvn clean package -DjasyptPassword=my-password
And when running the application JAR.
Application JAR
java -DjasyptPassword=my-password -jar target/quarkus-app/quarkus-run.jar
Or in native mode:
Native mode
target/my-native-application-runner -DjasyptPassword=my-password
3.44. Java jOOR DSL
Support for parsing Java route definitions at runtime
3.44.1. What’s inside
Refer to the above link for usage and configuration details.
3.44.2. Maven coordinates
Create a new project with this extension on code.quarkus.redhat.com
Or add the coordinates to your existing project:
<dependency> <groupId>org.apache.camel.quarkus</groupId> <artifactId>camel-quarkus-java-joor-dsl</artifactId> </dependency>
3.44.3. Camel Quarkus limitations
The annotations added to the classes to be compiled by the component are ignored by Quarkus. The only annotation that is partially supported by the extension is the annotation RegisterForReflection
to ease the configuration of the reflection for the native mode however please note that the element registerFullHierarchy
is not supported.
3.45. JAXB
Unmarshal XML payloads to POJOs and back using JAXB2 XML marshalling standard.
3.45.1. What’s inside
Refer to the above link for usage and configuration details.
3.45.2. Maven coordinates
Create a new project with this extension on code.quarkus.redhat.com
Or add the coordinates to your existing project:
<dependency> <groupId>org.apache.camel.quarkus</groupId> <artifactId>camel-quarkus-jaxb</artifactId> </dependency>
3.45.3. Usage
3.45.3.1. Native mode ObjectFactory
instantiation of non-JAXB annotated classes
When performing JAXB marshal operations with a custom ObjectFactory
to instantiate POJO classes that do not have JAXB annotations, you must register those POJO classes for reflection in order for them to be instantiated in native mode. E.g via the @RegisterForReflection
annotation or configuration property quarkus.camel.native.reflection.include-patterns
.
Refer to the Native mode user guide for more information.
3.46. JDBC
Access databases through SQL and JDBC.
3.46.1. What’s inside
-
JDBC component, URI syntax:
jdbc:dataSourceName
Refer to the above link for usage and configuration details.
3.46.2. Maven coordinates
Create a new project with this extension on code.quarkus.redhat.com
Or add the coordinates to your existing project:
<dependency> <groupId>org.apache.camel.quarkus</groupId> <artifactId>camel-quarkus-jdbc</artifactId> </dependency>
3.46.3. Additional Camel Quarkus configuration
3.46.3.1. Configuring a DataSource
This extension leverages Quarkus Agroal for DataSource
support. Setting up a DataSource
can be achieved via configuration properties. It is recommended that you explicitly name the datasource so that it can be referenced in the JDBC endpoint URI. E.g like to("jdbc:camel")
.
quarkus.datasource.camel.db-kind=postgresql quarkus.datasource.camel.username=your-username quarkus.datasource.camel.password=your-password quarkus.datasource.camel.jdbc.url=jdbc:postgresql://localhost:5432/your-database quarkus.datasource.camel.jdbc.max-size=16
If you choose to not name the datasource, you can resolve the default DataSource
by defining your endpoint like to("jdbc:default")
.
3.46.3.1.1. Zero configuration with Quarkus Dev Services
In dev and test mode you can take advantage of Configuration Free Databases. All you need to do is reference the default database in your routes. E.g to("jdbc:default")
.
3.47. Jira
Interact with JIRA issue tracker.
3.47.1. What’s inside
-
Jira component, URI syntax:
jira:type
Refer to the above link for usage and configuration details.
3.47.2. Maven coordinates
Create a new project with this extension on code.quarkus.redhat.com
Or add the coordinates to your existing project:
<dependency> <groupId>org.apache.camel.quarkus</groupId> <artifactId>camel-quarkus-jira</artifactId> </dependency>
Applications using the camel-quarkus-jira extension require an additional Maven repository https://packages.atlassian.com/maven-external/ to be configured either in the Maven settings.xml file or in the pom.xml file of the application project.
3.47.3. SSL in native mode
This extension auto-enables SSL support in native mode. Hence you do not need to add quarkus.ssl.native=true
to your application.properties
yourself. See also Quarkus SSL guide.
3.48. JMS
Sent and receive messages to/from a JMS Queue or Topic.
3.48.1. What’s inside
-
JMS component, URI syntax:
jms:destinationType:destinationName
Refer to the above link for usage and configuration details.
3.48.2. Maven coordinates
Create a new project with this extension on code.quarkus.redhat.com
Or add the coordinates to your existing project:
<dependency> <groupId>org.apache.camel.quarkus</groupId> <artifactId>camel-quarkus-jms</artifactId> </dependency>
3.48.3. Usage
3.48.3.1. Message mapping with org.w3c.dom.Node
The Camel JMS component supports message mapping between jakarta.jms.Message
and org.apache.camel.Message
. When wanting to convert a Camel message body type of org.w3c.dom.Node
, you must ensure that the camel-quarkus-xml-jaxp
extension is present on the classpath.
3.48.3.2. Native mode support for jakarta.jms.ObjectMessage
When sending JMS message payloads as jakarta.jms.ObjectMessage
, you must annotate the relevant classes to be registered for serialization with @RegisterForReflection(serialization = true)
.
This extension automatically sets quarkus.camel.native.reflection.serialization-enabled = true
for you. Refer to the native mode user guide for more information.
3.48.3.3. Support for Connection pooling and X/Open XA distributed transactions
To use connection pooling in the camel-quarkus-jms
components, you must add io.quarkiverse.artemis:quarkus-artemis
and io.quarkiverse.messaginghub:quarkus-pooled-jms
to your pom.xml and set the following configuration:
quarkus.pooled-jms.max-connections = 8
You can use the quarkus-pooled-jms
extension to get pooling and XA support for JMS connections. Refer to the quarkus-pooled-jms extension documentation for more information. Currently, it can work with quarkus-artemis-jms
, quarkus-qpid-jms
and ibmmq-client
. Just add the dependency to your pom.xml
:
<dependency> <groupId>io.quarkiverse.messaginghub</groupId> <artifactId>quarkus-pooled-jms</artifactId> </dependency>
Pooling is enabled by default.
clientID
and durableSubscriptionName
are not supported in pooling connections. If setClientID
is called on a reused
connection from the pool, an IllegalStateException
will be thrown. You will get some error messages such like Cause: setClientID can only be called directly after the connection is created
To enable XA, you need to add quarkus-narayana-jta
extension:
<dependency> <groupId>io.quarkus</groupId> <artifactId>quarkus-narayana-jta</artifactId> </dependency>
and add the following configuration to your application.properties
:
quarkus.pooled-jms.transaction=xa quarkus.transaction-manager.enable-recovery=true
XA support is only available with quarkus-artemis-jms
and ibmmq-client
.
We strongly recommend that you enable transaction recovery.
Since there currently exists no quarkus extension for ibmmq-client
, you need to create a custom ConnectionFactory
and wrap it yourself.
Here is an example:
Wrapper example: ConnectionFactory
for ibmmq-client
@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)); mq.setChannel(ConfigProvider.getConfig().getValue("ibm.mq.channel", String.class)); mq.setQueueManager(ConfigProvider.getConfig().getValue("ibm.mq.queueManagerName", String.class)); mq.setTransportType(WMQConstants.WMQ_CM_CLIENT); mq.setStringProperty(WMQConstants.USERID, ConfigProvider.getConfig().getValue("ibm.mq.user", String.class)); mq.setStringProperty(WMQConstants.PASSWORD, ConfigProvider.getConfig().getValue("ibm.mq.password", String.class)); } catch (Exception e) { throw new RuntimeException("Unable to create new IBM MQ connection factory", e); } return wrapper.wrapConnectionFactory(mq); }
If you use ibmmq-client
to consume messages and enable XA, you need to configure TransactionManager
in the camel route like this:
@Inject TransactionManager transactionManager; @Override public void configure() throws Exception { from("jms:queue:DEV.QUEUE.XA?transactionManager=#jtaTransactionManager"); } @Named("jtaTransactionManager") public PlatformTransactionManager getTransactionManager() { return new JtaTransactionManager(transactionManager); }
Otherwise, you will get an exception like MQRC_SYNCPOINT_NOT_AVAILABLE
.
When you are using ibmmq-client
and rollback a transaction, there will be a WARN message like:
WARN [com.arj.ats.jta] (executor-thread-1) ARJUNA016045: attempted rollback of < formatId=131077, gtrid_length=35, bqual_length=36, tx_uid=0:ffffc0a86510:aed3:650915d7:16, node_name=quarkus, branch_uid=0:ffffc0a86510:aed3:650915d7:1f, subordinatenodename=null, eis_name=0 > (com.ibm.mq.jmqi.JmqiXAResource@79786dde) failed with exception code XAException.XAER_NOTA: javax.transaction.xa.XAException: The method 'xa_rollback' has failed with errorCode '-4'.
you can ignore it and assume that MQ has discarded the transaction’s work. Refer to Red Hat Knowledgebase for more information.
3.48.4. transferException option in native mode
To use the transferException
option in native mode, you must enable support for object serialization. Refer to the native mode user guide for more information.
You will also need to enable serialization for the exception classes that you intend to serialize. For example.
@RegisterForReflection(targets = { IllegalStateException.class, MyCustomException.class }, serialization = true)
3.49. JPA
Store and retrieve Java objects from databases using Java Persistence API (JPA).
3.49.1. What’s inside
-
JPA component, URI syntax:
jpa:entityType
Refer to the above link for usage and configuration details.
3.49.2. Maven coordinates
Create a new project with this extension on code.quarkus.redhat.com
Or add the coordinates to your existing project:
<dependency> <groupId>org.apache.camel.quarkus</groupId> <artifactId>camel-quarkus-jpa</artifactId> </dependency>
3.49.3. Additional Camel Quarkus configuration
The extension leverages Quarkus Hibernate ORM to provide the JPA implementation via Hibernate.
Refer to the Quarkus Hibernate ORM documentation to see how to configure Hibernate and your datasource.
Also, it leverages Quarkus TX API to provide TransactionStrategy
implementation.
When a single persistence unit is used, the Camel Quarkus JPA extension will automatically configure the JPA component with a EntityManagerFactory
and TransactionStrategy
.
3.49.3.1. Configuring JpaMessageIdRepository
It needs to use EntityManagerFactory
and TransactionStrategy
from the CDI container to configure the JpaMessageIdRepository
:
@Inject EntityManagerFactory entityManagerFactory; @Inject TransactionStrategy transactionStrategy; from("direct:idempotent") .idempotentConsumer( header("messageId"), new JpaMessageIdRepository(entityManagerFactory, transactionStrategy, "idempotentProcessor"));
Since it excludes the spring-orm
dependency, some options such as sharedEntityManager
, transactionManager
are not supported.
3.50. JSLT
Query or transform JSON payloads using an JSLT.
3.50.1. What’s inside
-
JSLT component, URI syntax:
jslt:resourceUri
Refer to the above link for usage and configuration details.
3.50.2. Maven coordinates
Create a new project with this extension on code.quarkus.redhat.com
Or add the coordinates to your existing project:
<dependency> <groupId>org.apache.camel.quarkus</groupId> <artifactId>camel-quarkus-jslt</artifactId> </dependency>
3.50.3. allowContextMapAll option in native mode
The allowContextMapAll
option is not supported in native mode as it requires reflective access to security sensitive camel core classes such as CamelContext
& Exchange
. This is considered a security risk and thus access to the feature is not provided by default.
3.50.4. Additional Camel Quarkus configuration
3.50.4.1. Loading JSLT templates from classpath in native mode
This component typically loads the templates from classpath. To make it work also in native mode, you need to explicitly embed the templates files in the native executable by using the quarkus.native.resources.includes
property.
For instance, the route below would load the JSLT schema from a classpath resource named transformation.json
:
from("direct:start").to("jslt:transformation.json");
To include this (an possibly other templates stored in .json
files) in the native image, you would have to add something like the following to your application.properties
file:
quarkus.native.resources.includes = *.json
3.50.4.2. Using JSLT functions in native mode
When using JSLT functions from camel-quarkus in native mode, the classes hosting the functions would need to be registered for reflection. When registering the target function is not possible, one may end up writing a stub as below.
@RegisterForReflection public class MathFunctionStub { public static double pow(double a, double b) { return java.lang.Math.pow(a, b); } }
The target function Math.pow(…)
is now accessible through the MathFunctionStub
class that could be registered in the component as below:
@Named JsltComponent jsltWithFunction() throws ClassNotFoundException { JsltComponent component = new JsltComponent(); component.setFunctions(singleton(wrapStaticMethod("power", "org.apache.cq.example.MathFunctionStub", "pow"))); return component; }
3.51. JSON Path
Evaluate a JSONPath expression against a JSON message body
3.51.1. What’s inside
Refer to the above link for usage and configuration details.
3.51.2. Maven coordinates
Create a new project with this extension on code.quarkus.redhat.com
Or add the coordinates to your existing project:
<dependency> <groupId>org.apache.camel.quarkus</groupId> <artifactId>camel-quarkus-jsonpath</artifactId> </dependency>
3.52. JTA
Enclose Camel routes in transactions using Java Transaction API (JTA) and Narayana transaction manager
3.52.1. What’s inside
Refer to the above link for usage and configuration details.
3.52.2. Maven coordinates
Create a new project with this extension on code.quarkus.redhat.com
Or add the coordinates to your existing project:
<dependency> <groupId>org.apache.camel.quarkus</groupId> <artifactId>camel-quarkus-jta</artifactId> </dependency>
3.52.3. Usage
This extension should be added when you need to use the transacted()
EIP in the router. It leverages the transaction capabilities provided by the narayana-jta extension in Quarkus.
Refer to the Quarkus Transaction guide for the more details about transaction support. For a simple usage:
from("direct:transaction") .transacted() .to("sql:INSERT INTO A TABLE ...?dataSource=#ds1") .to("sql:INSERT INTO A TABLE ...?dataSource=#ds2") .log("all data are in the ds1 and ds2")
Support is provided for various transaction policies.
Policy | Description |
---|---|
| Support a current transaction; throw an exception if no current transaction exists. |
| Do not support a current transaction; throw an exception if a current transaction exists. |
| Do not support a current transaction; rather always execute non-transactionally. |
| Support a current transaction; create a new one if none exists. |
| Create a new transaction, suspending the current transaction if one exists. |
| Support a current transaction; execute non-transactionally if none exists. |
3.53. JT400
Exchanges messages with an IBM i system using data queues, message queues, or program call. IBM i is the replacement for AS/400 and iSeries servers.
3.53.1. What’s inside
-
JT400 component, URI syntax:
jt400:userID:password@systemName/QSYS.LIB/objectPath.type
Refer to the above link for usage and configuration details.
3.53.2. Maven coordinates
<dependency> <groupId>org.apache.camel.quarkus</groupId> <artifactId>camel-quarkus-jt400</artifactId> </dependency>
When using the native extension, you may get an error like
Resource bundle lookup must be loaded during native image generation:
This is caused by missing native registration (https://github.com/apache/camel-quarkus/pull/6029)
As a workaround, you can include multiple resource bundles:
quarkus.native.additional-build-args = -H:IncludeResourceBundles=com.ibm.as400.access.JDMRI,-H:IncludeResourceBundles=com.ibm.as400.access.SVMRI_en,-H:IncludeResourceBundles=com.ibm.as400.access.MRI2,-H:IncludeResourceBundles=com.ibm.as400.access.JDMRI2,-H:IncludeResourceBundles=com.ibm.as400.access.SVMRI,-H:IncludeResourceBundles=com.ibm.as400.data.DAMRI,-H:IncludeResourceBundles=com.ibm.as400.security.SecurityMRI,-H:IncludeResourceBundles=com.ibm.as400.util.commtrace.CTMRI,-H:IncludeResourceBundles=com.ibm.as400.access.CoreMRI,-H:IncludeResourceBundles=com.ibm.as400.resource.ResourceMRI,-H:IncludeResourceBundles=com.ibm.as400.access.MRI
3.54. Kafka
Sent and receive messages to/from an Apache Kafka broker.
3.54.1. What’s inside
-
Kafka component, URI syntax:
kafka:topic
Refer to the above link for usage and configuration details.
3.54.2. Maven coordinates
Create a new project with this extension on code.quarkus.redhat.com
Or add the coordinates to your existing project:
<dependency> <groupId>org.apache.camel.quarkus</groupId> <artifactId>camel-quarkus-kafka</artifactId> </dependency>
3.54.3. Usage
3.54.3.1. Quarkus Kafka Dev Services
Camel Quarkus Kafka can take advantage of Quarkus Kafka Dev services to simplify development and testing with a local containerized Kafka broker.
Kafka Dev Services is enabled by default in dev & test mode. The Camel Kafka component is automatically configured so that the brokers
component option is set to point at the local containerized Kafka broker. Meaning that there’s no need to configure this option yourself.
This functionality can be disabled with the configuration property quarkus.kafka.devservices.enabled=false
.
3.54.4. Additional Camel Quarkus configuration
Configuration property | Type | Default |
---|---|---|
If |
|
|
Configuration property fixed at build time. All other configuration properties are overridable at runtime.
3.55. Kamelet
Materialize route templates
3.55.1. What’s inside
-
Kamelet component, URI syntax:
kamelet:templateId/routeId
Refer to the above link for usage and configuration details.
3.55.2. Maven coordinates
Create a new project with this extension on code.quarkus.redhat.com
Or add the coordinates to your existing project:
<dependency> <groupId>org.apache.camel.quarkus</groupId> <artifactId>camel-quarkus-kamelet</artifactId> </dependency>
3.55.3. Usage
3.55.3.1. Pre-load Kamelets at build-time
This extension allows to pre-load a set of Kamelets at build time using the quarkus.camel.kamelet.identifiers
property.
3.55.3.2. Using the Kamelet Catalog
A set of pre-made Kamelets can be found on the /camel-kamelets/latest[Kamelet Catalog]. To use the Kamelet from the catalog you need to copy their yaml definition (that you can find in the camel-kamelet repo) on your project in the classpath. Alternatively you can add the camel-kamelets-catalog
artifact to your pom.xml
:
<dependency> <groupId>org.apache.camel.kamelets</groupId> <artifactId>camel-kamelets-catalog</artifactId> </dependency>
This artifact add all the kamelets available in the catalog to your Camel Quarkus application for build time processing. If you include it with the scope provided
the artifact should not be part of the runtime classpath, but at build time, all the kamelets listed via quarkus.camel.kamelet.identifiers
property should be preloaded.
3.55.4. Additional Camel Quarkus configuration
Configuration property | Type | Default |
---|---|---|
List of kamelets identifiers to pre-load at build time.
Each individual identifier is used to set the related |
|
Configuration property fixed at build time. All other configuration properties are overridable at runtime.
3.56. Kubernetes
Perform operations against Kubernetes API
3.56.1. Maven coordinates
Create a new project with this extension on code.quarkus.redhat.com
Or add the coordinates to your existing project:
<dependency> <groupId>org.apache.camel.quarkus</groupId> <artifactId>camel-quarkus-kubernetes</artifactId> </dependency>
3.56.2. Additional Camel Quarkus configuration
In this release of Red Hat build of Apache Camel for Quarkus, the camel-quarkus-kubernetes
extension is only supported when used with the camel-quarkus-master
extension as a cluster service. Additionally, in order for the camel-quarkus-kubernetes
extension to be supported, you must explicitly add a dependency on the quarkus-openshift-client
extension in your application.
3.56.2.1. Automatic registration of a Kubernetes Client instance
The extension automatically registers a Kubernetes Client bean named kubernetesClient
. You can reference the bean in your routes like this:
from("direct:pods") .to("kubernetes-pods:///?kubernetesClient=#kubernetesClient&operation=listPods")
By default the client is configured from the local kubeconfig file. You can customize the client configuration via properties within application.properties
:
quarkus.kubernetes-client.master-url=https://my.k8s.host quarkus.kubernetes-client.namespace=my-namespace
The full set of configuration options are documented in the Quarkus Kubernetes Client guide.
3.56.2.2. Having only a single consumer in a cluster consuming from a given endpoint
When the same route is deployed on multiple pods, it could be interesting to use this extension in conjunction with the Master one. In such a setup, a single consumer will be active at a time across the whole camel master namespace.
For instance, having the route below deployed on multiple pods:
from("master:ns:timer:test?period=100").log("Timer invoked on a single pod at a time");
It’s possible to enable the kubernetes cluster service with a property like below:
quarkus.camel.cluster.kubernetes.enabled = true
As a result, a single consumer will be active across the ns
camel master namespace. It means that, at a given time, only a single timer will generate exchanges across the whole cluster. In other words, messages will be logged every 100ms on a single pod at a time.
The kubernetes cluster service could further be tuned by tweaking quarkus.camel.cluster.kubernetes.*
properties.
Configuration property | Type | Default |
---|---|---|
Whether a Kubernetes Cluster Service should be automatically configured according to 'quarkus.camel.cluster.kubernetes.*' configurations. |
|
|
The cluster service ID (defaults to null). |
| |
The URL of the Kubernetes master (read from Kubernetes client properties by default). |
| |
The connection timeout in milliseconds to use when making requests to the Kubernetes API server. |
| |
The name of the Kubernetes namespace containing the pods and the configmap (autodetected by default). |
| |
The name of the current pod (autodetected from container host name by default). |
| |
The jitter factor to apply in order to prevent all pods to call Kubernetes APIs in the same instant (defaults to 1.2). |
| |
The default duration of the lease for the current leader (defaults to 15000). |
| |
The deadline after which the leader must stop its services because it may have lost the leadership (defaults to 10000). |
| |
The time between two subsequent attempts to check and acquire the leadership. It is randomized using the jitter factor (defaults to 2000). |
| |
Service lookup order/priority (defaults to 2147482647). |
| |
The name of the lease resource used to do optimistic locking (defaults to 'leaders'). The resource name is used as prefix when the underlying Kubernetes resource can manage a single lock. |
| |
The lease resource type used in Kubernetes, either 'config-map' or 'lease' (defaults to 'lease'). |
| |
Whether the camel master namespace leaders should be distributed evenly across all the camel contexts in the cluster. |
|
|
The labels key/value used to identify the pods composing the cluster, defaults to empty map. |
|
Configuration property fixed at build time. All other configuration properties are overridable at runtime.
3.57. Kudu
Interact with Apache Kudu, a free and open source column-oriented data store of the Apache Hadoop ecosystem.
3.57.1. What’s inside
-
Kudu component, URI syntax:
kudu:host:port/tableName
Refer to the above link for usage and configuration details.
3.57.2. Maven coordinates
Create a new project with this extension on code.quarkus.redhat.com
Or add the coordinates to your existing project:
<dependency> <groupId>org.apache.camel.quarkus</groupId> <artifactId>camel-quarkus-kudu</artifactId> </dependency>
3.57.3. SSL in native mode
This extension auto-enables SSL support in native mode. Hence you do not need to add quarkus.ssl.native=true
to your application.properties
yourself. See also Quarkus SSL guide.
Kudu is not supported for IBM Z and IBM Power.
3.58. Language
Execute scripts in any of the languages supported by Camel.
3.58.1. What’s inside
-
Language component, URI syntax:
language:languageName:resourceUri
Refer to the above link for usage and configuration details.
3.58.2. Maven coordinates
Create a new project with this extension on code.quarkus.redhat.com
Or add the coordinates to your existing project:
<dependency> <groupId>org.apache.camel.quarkus</groupId> <artifactId>camel-quarkus-language</artifactId> </dependency>
3.58.3. Usage
3.58.3.1. Required Dependencies
The Language extension only handles the passing of an Exchange to a script for execution. The extension implementing the language must be added as a dependency. The following list of languages are implemented in Core:
- Constant
- ExchangeProperty
- File
- Header
- Ref
- Simple
- Tokenize
To use any other language, you must add the corresponding dependency. Consult the Languages Guide for details.
3.58.3.2. Native Mode
When loading scripts from the classpath in native mode, the path to the script file must be specified in the quarkus.native.resources.includes
property of the application.properties
file. For example:
quarkus.native.resources.includes=script.txt
3.58.4. allowContextMapAll option in native mode
The allowContextMapAll
option is not supported in native mode as it requires reflective access to security sensitive camel core classes such as CamelContext
& Exchange
. This is considered a security risk and thus access to the feature is not provided by default.
3.59. LDAP
Perform searches on LDAP servers.
3.59.1. What’s inside
-
LDAP component, URI syntax:
ldap:dirContextName
Refer to the above link for usage and configuration details.
3.59.2. Maven coordinates
Create a new project with this extension on code.quarkus.redhat.com
Or add the coordinates to your existing project:
<dependency> <groupId>org.apache.camel.quarkus</groupId> <artifactId>camel-quarkus-ldap</artifactId> </dependency>
3.59.3. Usage
3.59.3.1. Using SSL in Native Mode
When using a custom SSLSocketFactory
in native mode, such as the one in the Configuring SSL section, you need to register the class for reflection otherwise the class will not be made available on the classpath. Add the @RegisterForReflection
annotation above the class definition, as follows:
@RegisterForReflection public class CustomSSLSocketFactory extends SSLSocketFactory { // The class definition is the same as in the above link. }
3.60. LRA
Camel saga binding for Long-Running-Action framework
3.60.1. What’s inside
Refer to the above link for usage and configuration details.
3.60.2. Maven coordinates
Create a new project with this extension on code.quarkus.redhat.com
Or add the coordinates to your existing project:
<dependency> <groupId>org.apache.camel.quarkus</groupId> <artifactId>camel-quarkus-lra</artifactId> </dependency>
3.61. Log
Log messages to the underlying logging mechanism.
3.61.1. What’s inside
-
Log component, URI syntax:
log:loggerName
Refer to the above link for usage and configuration details.
3.61.2. Maven coordinates
Create a new project with this extension on code.quarkus.redhat.com
Or add the coordinates to your existing project:
<dependency> <groupId>org.apache.camel.quarkus</groupId> <artifactId>camel-quarkus-log</artifactId> </dependency>
3.62. Mail
Send and receive emails using imap, pop3 and smtp protocols. Marshal Camel messages with attachments into MIME-Multipart messages and back.
3.62.1. What’s inside
-
IMAP component, URI syntax:
imap:host:port
-
IMAPS (Secure) component, URI syntax:
imaps:host:port
- MIME Multipart data format
-
POP3 component, URI syntax:
pop3:host:port
-
POP3S component, URI syntax:
pop3s:host:port
-
SMTP component, URI syntax:
smtp:host:port
-
SMTPS component, URI syntax:
smtps:host:port
Refer to the above links for usage and configuration details.
3.62.2. Maven coordinates
Create a new project with this extension on code.quarkus.redhat.com
Or add the coordinates to your existing project:
<dependency> <groupId>org.apache.camel.quarkus</groupId> <artifactId>camel-quarkus-mail</artifactId> </dependency>
3.63. Management
JMX management strategy and associated managed resources.
3.63.1. Maven coordinates
Create a new project with this extension on code.quarkus.redhat.com
Or add the coordinates to your existing project:
<dependency> <groupId>org.apache.camel.quarkus</groupId> <artifactId>camel-quarkus-management</artifactId> </dependency>
3.63.2. Usage
For information on using Managed Beans in Camel, consult the JMX section of the Camel Manual.
3.63.2.1. Enabling and Disabling JMX
JMX can be enabled or disabled in Camel-Quarkus by any of the following methods:
-
Adding or removing the
camel-quarkus-management
extension. -
Setting the
camel.main.jmxEnabled
configuration property to a boolean value. -
Setting the system property
-Dorg.apache.camel.jmx.disabled
to a boolean value.
3.63.2.2. Native mode
Experimental JMX support was added for native executables in GraalVM for JDK 17/20 / Mandrel 23.0. You can enable this feature by adding the following configuration property to application.properties
.
quarkus.native.monitoring=jmxserver
If you want the native application to be discoverable by tools such as JConsole and VisualVM, append the jvmstat
option to the above mentioned configuration.
For more information, refer to the Quarkus native guide.
3.64. MapStruct
Type Conversion using Mapstruct
3.64.1. What’s inside
-
MapStruct component, URI syntax:
mapstruct:className
Refer to the above link for usage and configuration details.
3.64.2. Maven coordinates
Create a new project with this extension on code.quarkus.redhat.com
Or add the coordinates to your existing project:
<dependency> <groupId>org.apache.camel.quarkus</groupId> <artifactId>camel-quarkus-mapstruct</artifactId> </dependency>
3.64.3. Usage
3.64.3.1. Annotation Processor
To use MapStruct, you must configure your build to use an annotation processor.
3.64.3.1.1. Maven
<plugins> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-compiler-plugin</artifactId> <configuration> <annotationProcessorPaths> <path> <groupId>org.mapstruct</groupId> <artifactId>mapstruct-processor</artifactId> <version>{mapstruct-version}</version> </path> </annotationProcessorPaths> </configuration> </plugin> </plugins>
3.64.3.1.2. Gradle
dependencies { annotationProcessor 'org.mapstruct:mapstruct-processor:{mapstruct-version}' testAnnotationProcessor 'org.mapstruct:mapstruct-processor:{mapstruct-version}' }
3.64.3.2. Mapper definition discovery
By default, Red Hat build of Apache Camel for Quarkus will automatically discover the package paths of your @Mapper
annotated interfaces or abstract classes and pass them to the Camel MapStruct component.
If you want finer control over the specific packages that are scanned, then you can set a configuration property in application.properties
.
camel.component.mapstruct.mapper-package-name = com.first.package,org.second.package
3.65. Master
Have only a single consumer in a cluster consuming from a given endpoint; with automatic failover if the JVM dies.
3.65.1. What’s inside
-
Master component, URI syntax:
master:namespace:delegateUri
Refer to the above link for usage and configuration details.
3.65.2. Maven coordinates
Create a new project with this extension on code.quarkus.redhat.com
Or add the coordinates to your existing project:
<dependency> <groupId>org.apache.camel.quarkus</groupId> <artifactId>camel-quarkus-master</artifactId> </dependency>
3.65.3. Additional Camel Quarkus configuration
This extension can be used in conjunction with extensions below:
3.66. Micrometer
Collect various metrics directly from Camel routes using the Micrometer library.
3.66.1. What’s inside
-
Micrometer component, URI syntax:
micrometer:metricsType:metricsName
Refer to the above link for usage and configuration details.
3.66.2. Maven coordinates
Create a new project with this extension on code.quarkus.redhat.com
Or add the coordinates to your existing project:
<dependency> <groupId>org.apache.camel.quarkus</groupId> <artifactId>camel-quarkus-micrometer</artifactId> </dependency>
3.66.3. Usage
This extension leverages Quarkus Micrometer. Quarkus supports a variety of Micrometer metric registry implementations.
Your application should declare the following dependency or one of the dependencies listed in the quarkiverse documentation, depending on the monitoring solution you want to work with.
<dependency> <groupId>io.micrometer</groupId> <artifactId>micrometer-registry-prometheus</artifactId> </dependency>
If no dependency is declared, the Micrometer extension creates a SimpleMeterRegistry
instance, suitable mainly for testing.
3.66.4. Camel Quarkus limitations
3.66.4.1. Exposing Micrometer statistics in JMX
Exposing Micrometer statistics in JMX is not available in native mode as quarkus-micrometer-registry-jmx
does not have native support at present.
3.66.4.2. Decrement header for Counter is ignored by Prometheus
Prometheus backend ignores negative values during increment of Counter metrics.
3.66.4.3. Exposing statistics in JMX
In Red Hat build of Apache Camel for Quarkus, registering a JmxMeterRegistry
is simplified. Add a dependency for io.quarkiverse.micrometer.registry:quarkus-micrometer-registry-jmx
and a JmxMeterRegistry
will automatically get created for you.
3.66.5. Additional Camel Quarkus configuration
Configuration property | Type | Default |
---|---|---|
Set whether to enable the MicrometerRoutePolicyFactory for capturing metrics on route processing times. |
|
|
Set whether to enable the MicrometerMessageHistoryFactory for capturing metrics on individual route node processing times. Depending on the number of configured route nodes, there is the potential to create a large volume of metrics. Therefore, this option is disabled by default. |
|
|
Set whether to enable the MicrometerExchangeEventNotifier for capturing metrics on exchange processing times. |
|
|
Set whether to enable the MicrometerRouteEventNotifier for capturing metrics on the total number of routes and total number of routes running. |
|
|
Set whether to gather performance information about Camel Thread Pools by injecting an InstrumentedThreadPoolFactory. |
|
|
Configuration property fixed at build time. All other configuration properties are overridable at runtime.
If you are migrating to micrometer
from smallrye-metrics
, you may need to manually define some beans as scoped.
In smallrye-metrics
, classes that are registered for metrics (for example with @COUNTED
, @METRIC
), but not registered as scoped beans, are registered automatically. This does not happen in micrometer
.
In micrometer
you need to manually register beans accessed via CDI, by for example adding a @Dependent
annotation.
3.67. Microprofile Fault Tolerance
Circuit Breaker EIP using Microprofile Fault Tolerance
3.67.1. What’s inside
Refer to the above link for usage and configuration details.
3.67.2. Maven coordinates
Create a new project with this extension on code.quarkus.redhat.com
Or add the coordinates to your existing project:
<dependency> <groupId>org.apache.camel.quarkus</groupId> <artifactId>camel-quarkus-microprofile-fault-tolerance</artifactId> </dependency>
3.68. MicroProfile Health
Expose Camel health checks via MicroProfile Health
3.68.1. What’s inside
Refer to the above link for usage and configuration details.
3.68.2. Maven coordinates
Create a new project with this extension on code.quarkus.redhat.com
Or add the coordinates to your existing project:
<dependency> <groupId>org.apache.camel.quarkus</groupId> <artifactId>camel-quarkus-microprofile-health</artifactId> </dependency>
3.68.3. Usage
By default, classes extending AbstractHealthCheck
are registered as both liveness and readiness checks. You can override the isReadiness
method to control this behaviour.
Any checks provided by your application are automatically discovered and bound to the Camel registry. They will be available via the Quarkus health endpoints /q/health/live
and /q/health/ready
.
You can also provide custom HealthCheckRepository
implementations and these are also automatically discovered and bound to the Camel registry for you.
Refer to the Quarkus health guide for further information.
3.68.3.1. Provided health checks
Some checks are automatically registered for your application.
3.68.3.1.1. Camel Context Health
Inspects the Camel Context status and causes the health check status to be DOWN
if the status is anything other than 'Started'.
3.68.3.1.2. Camel Route Health
Inspects the status of each route and causes the health check status to be DOWN
if any route status is not 'Started'.
3.68.4. Additional Camel Quarkus configuration
Configuration property | Type | Default |
---|---|---|
Set whether to enable Camel health checks |
|
|
Configuration property fixed at build time. All other configuration properties are overridable at runtime.
3.69. Minio
Store and retrieve objects from Minio Storage Service using Minio SDK.
3.69.1. What’s inside
-
Minio component, URI syntax:
minio:bucketName
Refer to the above link for usage and configuration details.
3.69.2. Maven coordinates
Create a new project with this extension on code.quarkus.redhat.com
Or add the coordinates to your existing project:
<dependency> <groupId>org.apache.camel.quarkus</groupId> <artifactId>camel-quarkus-minio</artifactId> </dependency>
3.69.3. Additional Camel Quarkus configuration
Depending on Minio configuration, this extension may require SSL encryption on its connections. In such cases, you will need to add quarkus.ssl.native=true
to your application.properties
. See also Quarkus native SSL guide and Native mode section of Camel Quarkus user guide.
There are two different configuration approaches:
- Minio client can be defined via quarkus properties leveraging the Quarkiverse Minio (see documentation). Camel will autowire client into the Minio component. This configuration allows definition of only one minio client, therefore it isn’t possible to define several different minio endpoints, which run together.
- Provide client/clients for camel registry (e.g. CDI producer/bean) and reference them from endpoint.
minio:foo?minioClient=#minioClient
3.70. MLLP
Communicate with external systems using the MLLP protocol.
3.70.1. What’s inside
-
MLLP component, URI syntax:
mllp:hostname:port
Refer to the above link for usage and configuration details.
3.70.2. Maven coordinates
Create a new project with this extension on code.quarkus.redhat.com
Or add the coordinates to your existing project:
<dependency> <groupId>org.apache.camel.quarkus</groupId> <artifactId>camel-quarkus-mllp</artifactId> </dependency>
3.70.3. Additional Camel Quarkus configuration
-
Check the Character encodings section of the Native mode guide if you wish to use the
defaultCharset
component option.
3.71. Mock
Test routes and mediation rules using mocks.
3.71.1. What’s inside
-
Mock component, URI syntax:
mock:name
Refer to the above link for usage and configuration details.
3.71.2. Maven coordinates
Create a new project with this extension on code.quarkus.redhat.com
Or add the coordinates to your existing project:
<dependency> <groupId>org.apache.camel.quarkus</groupId> <artifactId>camel-quarkus-mock</artifactId> </dependency>
3.71.3. Usage
To use camel-mock capabilities in tests it is required to get access to MockEndpoint instances.
CDI injection could be used for accessing instances (see Quarkus documentation). You can inject camelContext into test using @Inject
annotation. Camel context can be then used for obtaining mock endpoints. See the following example:
import jakarta.inject.Inject; import org.apache.camel.CamelContext; import org.apache.camel.ProducerTemplate; import org.apache.camel.component.mock.MockEndpoint; import org.junit.jupiter.api.Test; import io.quarkus.test.junit.QuarkusTest; @QuarkusTest public class MockJvmTest { @Inject CamelContext camelContext; @Inject ProducerTemplate producerTemplate; @Test public void test() throws InterruptedException { producerTemplate.sendBody("direct:start", "Hello World"); MockEndpoint mockEndpoint = camelContext.getEndpoint("mock:result", MockEndpoint.class); mockEndpoint.expectedBodiesReceived("Hello World"); mockEndpoint.assertIsSatisfied(); } }
Route used for the example test:
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"); } }
3.71.4. Camel Quarkus limitations
Injection of CDI beans (described in Usage) does not work in native mode.
In the native mode the test and the application under test are running in two different processes and it is not possible to share a mock bean between them (see Quarkus documentation).
3.72. MongoDB
Perform operations on MongoDB documents and collections.
3.72.1. What’s inside
-
MongoDB component, URI syntax:
mongodb:connectionBean
Refer to the above link for usage and configuration details.
3.72.2. Maven coordinates
Create a new project with this extension on code.quarkus.redhat.com
Or add the coordinates to your existing project:
<dependency> <groupId>org.apache.camel.quarkus</groupId> <artifactId>camel-quarkus-mongodb</artifactId> </dependency>
3.72.3. Additional Camel Quarkus configuration
The extension leverages the Quarkus MongoDB Client extension. The Mongo client can be configured via the Quarkus MongoDB Client configuration options.
The Camel Quarkus MongoDB extension automatically registers a MongoDB client bean named camelMongoClient
. This can be referenced in the mongodb endpoint URI connectionBean
path parameter. For example:
from("direct:start") .to("mongodb:camelMongoClient?database=myDb&collection=myCollection&operation=findAll")
If your application needs to work with multiple MongoDB servers, you can create a "named" client and reference in your route by injecting a client and the related configuration as explained in the Quarkus MongoDB extension client injection. For example:
//application.properties quarkus.mongodb.mongoClient1.connection-string = mongodb://root:example@localhost:27017/
//Routes.java @ApplicationScoped public class Routes extends RouteBuilder { @Inject @MongoClientName("mongoClient1") MongoClient mongoClient1; @Override public void configure() throws Exception { from("direct:defaultServer") .to("mongodb:camelMongoClient?database=myDb&collection=myCollection&operation=findAll") from("direct:otherServer") .to("mongodb:mongoClient1?database=myOtherDb&collection=myOtherCollection&operation=findAll"); } }
Note that when using named clients, the "default" camelMongoClient
bean will still be produced. Refer to the Quarkus documentation on Multiple MongoDB Clients for more information.
3.73. MyBatis
Performs a query, poll, insert, update or delete in a relational database using MyBatis.
3.73.1. What’s inside
-
MyBatis component, URI syntax:
mybatis:statement
-
MyBatis Bean component, URI syntax:
mybatis-bean:beanName:methodName
Refer to the above links for usage and configuration details.
3.73.2. Maven coordinates
Create a new project with this extension on code.quarkus.redhat.com
Or add the coordinates to your existing project:
<dependency> <groupId>org.apache.camel.quarkus</groupId> <artifactId>camel-quarkus-mybatis</artifactId> </dependency>
3.73.3. Additional Camel Quarkus configuration
Refer to Quarkus MyBatis for configuration. It must enable the following options.
quarkus.mybatis.xmlconfig.enable=true quarkus.mybatis.xmlconfig.path=SqlMapConfig.xml
quarkus.mybatis.xmlconfig.path
must be the same with configurationUri
param in the mybatis endpoint.
3.74. Netty HTTP
The Netty HTTP extension provides HTTP transport on top of the Netty extension.
3.74.1. What’s inside
-
Netty HTTP component, URI syntax:
netty-http:protocol://host:port/path
Refer to the above link for usage and configuration details.
3.74.2. Maven coordinates
Create a new project with this extension on code.quarkus.redhat.com
Or add the coordinates to your existing project:
<dependency> <groupId>org.apache.camel.quarkus</groupId> <artifactId>camel-quarkus-netty-http</artifactId> </dependency>
3.74.3. transferException option in native mode
To use the transferException
option in native mode, you must enable support for object serialization. Refer to the native mode user guide for more information.
You will also need to enable serialization for the exception classes that you intend to serialize. For example.
@RegisterForReflection(targets = { IllegalStateException.class, MyCustomException.class }, serialization = true)
3.74.4. Additional Camel Quarkus configuration
- Check the Character encodings section of the Native mode guide if you expect your application to send or receive requests using non-default encodings.
3.75. Netty
Socket level networking using TCP or UDP with Netty 4.x.
3.75.1. What’s inside
-
Netty component, URI syntax:
netty:protocol://host:port
Refer to the above link for usage and configuration details.
3.75.2. Maven coordinates
Create a new project with this extension on code.quarkus.redhat.com
Or add the coordinates to your existing project:
<dependency> <groupId>org.apache.camel.quarkus</groupId> <artifactId>camel-quarkus-netty</artifactId> </dependency>
3.76. OpenAPI Java
Expose OpenAPI resources defined in Camel REST DSL
3.76.1. What’s inside
Refer to the above link for usage and configuration details.
3.76.2. Maven coordinates
Create a new project with this extension on code.quarkus.redhat.com
Or add the coordinates to your existing project:
<dependency> <groupId>org.apache.camel.quarkus</groupId> <artifactId>camel-quarkus-openapi-java</artifactId> </dependency>
3.76.3. Usage
You can use this extension to expose REST DSL services to Quarkus OpenAPI. With quarkus-smallrye-openapi
, you can access them by /q/openapi?format=json
.
Refer to the Quarkus OpenAPI guide for further information.
This is an experimental feature. You can enable it by
quarkus.camel.openapi.expose.enabled=true
It’s the user’s responsibility to use @RegisterForReflection
to register all model classes for reflection.
It doesn’t support the rest services used in org.apache.camel.builder.LambdaRouteBuilder
right now. Also, it can not use CDI injection in the RouteBuilder configure()
since we get the rest definitions at build time while CDI is unavailable.
3.77. OpenTelemetry
Distributed tracing using OpenTelemetry
3.77.1. What’s inside
Refer to the above link for usage and configuration details.
3.77.2. Maven coordinates
Create a new project with this extension on code.quarkus.redhat.com
Or add the coordinates to your existing project:
<dependency> <groupId>org.apache.camel.quarkus</groupId> <artifactId>camel-quarkus-opentelemetry</artifactId> </dependency>
3.77.3. Usage
The extension automatically creates a Camel OpenTelemetryTracer
and binds it to the Camel registry.
In order to send the captured traces to a tracing system, you need to configure some properties within application.properties
like those below.
# Identifier for the origin of spans created by the application quarkus.application.name=my-camel-application # OTLP exporter endpoint quarkus.opentelemetry.tracer.exporter.otlp.endpoint=http://localhost:4317
Refer to the Quarkus OpenTelemetry guide for a full list of configuration options.
Route endpoints can be excluded from tracing by configuring a property named quarkus.camel.opentelemetry.exclude-patterns
in application.properties
. For example:
# Exclude all direct & netty-http endpoints from tracing quarkus.camel.opentelemetry.exclude-patterns=direct:*,netty-http:*
3.77.3.1. Exporters
Quarkus OpenTelemetry defaults to the standard OTLP exporter defined in OpenTelemetry. Additional exporters will be available in the Quarkiverse quarkus-opentelemetry-exporter project.
3.77.3.2. Tracing CDI bean method execution
When instrumenting the execution of CDI bean methods from Camel routes, you should annotate such methods with io.opentelemetry.extension.annotations.WithSpan
. Methods annotated with @WithSpan
will create a new Span and establish any required relationships with the current Trace context.
For example, to instrument a CDI bean from a Camel route, first ensure the appropriate methods are annotated with @WithTrace
.
@ApplicationScoped @Named("myBean") public class MyBean { @WithSpan public String greet() { return "Hello World!"; } }
Next, use the bean in your Camel route.
To ensure that the sequence of recorded spans is correct, you must use the full to("bean:")
endpoint URI and not the shortened .bean()
EIP DSL method.
public class MyRoutes extends RouteBuilder { @Override public void configure() throws Exception { from("direct:executeBean") .to("bean:myBean?method=greet"); } }
There is more information about CDI instrumentation in the Quarkus OpenTelemetry guide.
3.77.4. Additional Camel Quarkus configuration
Configuration property | Type | Default |
---|---|---|
Sets whether header names need to be encoded. Can be useful in situations where OpenTelemetry propagators potentially set header name values in formats that are not compatible with the target system. E.g for JMS where the specification mandates header names are valid Java identifiers. |
|
|
Sets whether to disable tracing for endpoint URIs that match the given comma separated patterns. The pattern can take the following forms: 1. An exact match on the endpoint URI. E.g platform-http:/some/path 2. A wildcard match. E.g platform-http:* 3. A regular expression matching the endpoint URI. E.g platform-http:/prefix/.* |
|
Configuration property fixed at build time. All other configuration properties are overridable at runtime.
3.78. Paho MQTT5
Communicate with MQTT message brokers using Eclipse Paho MQTT v5 Client.
3.78.1. What’s inside
-
Paho MQTT 5 component, URI syntax:
paho-mqtt5:topic
Refer to the above link for usage and configuration details.
3.78.2. Maven coordinates
Create a new project with this extension on code.quarkus.redhat.com
Or add the coordinates to your existing project:
<dependency> <groupId>org.apache.camel.quarkus</groupId> <artifactId>camel-quarkus-paho-mqtt5</artifactId> </dependency>
3.79. Paho
Communicate with MQTT message brokers using Eclipse Paho MQTT Client.
3.79.1. What’s inside
-
Paho component, URI syntax:
paho:topic
Refer to the above link for usage and configuration details.
3.79.2. Maven coordinates
Create a new project with this extension on code.quarkus.redhat.com
Or add the coordinates to your existing project:
<dependency> <groupId>org.apache.camel.quarkus</groupId> <artifactId>camel-quarkus-paho</artifactId> </dependency>
3.80. Platform HTTP
This extension allows for creating HTTP endpoints for consuming HTTP requests.
It is built on top of the Eclipse Vert.x HTTP server provided by the quarkus-vertx-http
extension.
3.80.1. What’s inside
-
Platform HTTP component, URI syntax:
platform-http:path
Refer to the above link for usage and configuration details.
3.80.2. Maven coordinates
Create a new project with this extension on code.quarkus.redhat.com
Or add the coordinates to your existing project:
<dependency> <groupId>org.apache.camel.quarkus</groupId> <artifactId>camel-quarkus-platform-http</artifactId> </dependency>
3.80.3. Usage
3.80.3.1. Basic Usage
Serve all HTTP methods on the /hello
endpoint:
from("platform-http:/hello").setBody(simple("Hello ${header.name}"));
Serve only GET requests on the /hello
endpoint:
from("platform-http:/hello?httpMethodRestrict=GET").setBody(simple("Hello ${header.name}"));
3.80.3.2. Using platform-http
via Camel REST DSL
To be able to use Camel REST DSL with the platform-http
component, add camel-quarkus-rest
to your pom.xml
:
<dependency> <groupId>org.apache.camel.quarkus</groupId> <artifactId>camel-quarkus-rest</artifactId> </dependency>
Then you can use the Camel REST DSL:
rest() .get("/my-get-endpoint") .to("direct:handleGetRequest"); .post("/my-post-endpoint") .to("direct:handlePostRequest");
3.80.3.3. Handling multipart/form-data
file uploads
You can restrict the uploads to certain file extensions by white listing them:
from("platform-http:/upload/multipart?fileNameExtWhitelist=html,txt&httpMethodRestrict=POST") .to("log:multipart") .process(e -> { final AttachmentMessage am = e.getMessage(AttachmentMessage.class); if (am.hasAttachments()) { am.getAttachments().forEach((fileName, dataHandler) -> { try (InputStream in = dataHandler.getInputStream()) { // do something with the input stream } catch (IOException ioe) { throw new RuntimeException(ioe); } }); } });
3.80.3.4. Securing platform-http
endpoints
Quarkus provides a variety of security and authentication mechanisms which can be used to secure platform-http
endpoints. Refer to the Quarkus Security documentation for further details.
Within a route, it is possible to obtain the authenticated user and its associated SecurityIdentity
and Principal
:
from("platform-http:/secure") .process(e -> { Message message = e.getMessage(); QuarkusHttpUser user = message.getHeader(VertxPlatformHttpConstants.AUTHENTICATED_USER, QuarkusHttpUser.class); SecurityIdentity securityIdentity = user.getSecurityIdentity(); Principal principal = securityIdentity.getPrincipal(); // Do something useful with SecurityIdentity / Principal. E.g check user roles etc. });
Also check the quarkus.http.body.*
configuration options in Quarkus documentation, esp. quarkus.http.body.handle-file-uploads
, quarkus.http.body.uploads-directory
and quarkus.http.body.delete-uploaded-files-on-end
.
3.80.3.5. Implementing a reverse proxy
Platform HTTP component can act as a reverse proxy, in that case Exchange.HTTP_URI
, Exchange.HTTP_HOST
headers are populated from the absolute URL received on the request line of the HTTP request.
Here’s an example of a HTTP proxy that simply redirects the Exchange to the origin server.
from("platform-http:proxy") .toD("http://" + "${headers." + Exchange.HTTP_HOST + "}");
3.80.4. Additional Camel Quarkus configuration
3.80.4.1. Platform HTTP server configuration
Configuration of the platform HTTP server is managed by Quarkus. Refer to the Quarkus HTTP configuration guide for the full list of configuration options.
To configure SSL for the Platform HTTP server, follow the secure connections with SSL guide. Note that configuring the server for SSL with SSLContextParameters
is not currently supported.
3.80.4.2. Character encodings
Check the Character encodings section of the Native mode guide if you expect your application to send or receive requests using non-default encodings.
3.81. Quartz
Schedule sending of messages using the Quartz 2.x scheduler.
3.81.1. What’s inside
-
Quartz component, URI syntax:
quartz:groupName/triggerName
Refer to the above link for usage and configuration details.
3.81.2. Maven coordinates
Create a new project with this extension on code.quarkus.redhat.com
Or add the coordinates to your existing project:
<dependency> <groupId>org.apache.camel.quarkus</groupId> <artifactId>camel-quarkus-quartz</artifactId> </dependency>
3.81.3. Usage
3.81.3.1. Clustering
Support for Quartz clustering is provided by the Quarkus Quartz extension. The following steps outline how to configure Quarkus Quartz for use with Camel.
Enable Quartz clustered mode and configure a
DataSource
as a persistence Quartz job store. An example configuration is as follows.# 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
Add the correct JDBC driver extension to your application that corresponds to the value of
quarkus.datasource.db-kind
. In the above examplepostgresql
is used, therefore the following JDBC dependency would be required. Adjust as necessary for your needs. Agroal is also required forDataSource
support.<dependency> <groupId>io.quarkus</groupId> <artifactId>quarkus-jdbc-postgresql</artifactId> </dependency> <dependency> <groupId>io.quarkus</groupId> <artifactId>quarkus-agroal</artifactId> </dependency>
Quarkus Flyway can automatically create the necessary Quartz database tables for you. Add
quarkus-flyway
to your application (optional).<dependency> <groupId>io.quarkus</groupId> <artifactId>quarkus-flyway</artifactId> </dependency>
Also add a Quartz database creation script for your chosen database kind. The Quartz project provides ready made scripts that can be copied from here. Add the SQL script to
src/main/resources/db/migration/V1.0.0__QuarkusQuartz.sql
. Quarkus Flyway will detect it on startup and will proceed to create the Quartz database tables.Configure the Camel Quartz component to use the Quarkus Quartz scheduler.
@Produces @Singleton @Named("quartz") public QuartzComponent quartzComponent(Scheduler scheduler) { QuartzComponent component = new QuartzComponent(); component.setScheduler(scheduler); return component; }
Further customization of the Quartz scheduler can be done via various configuration properties. Refer to to the Quarkus Quartz Configuration guide for more information.
3.82. Ref
Route messages to an endpoint looked up dynamically by name in the Camel Registry.
3.82.1. What’s inside
-
Ref component, URI syntax:
ref:name
Refer to the above link for usage and configuration details.
3.82.2. Maven coordinates
Create a new project with this extension on code.quarkus.redhat.com
Or add the coordinates to your existing project:
<dependency> <groupId>org.apache.camel.quarkus</groupId> <artifactId>camel-quarkus-ref</artifactId> </dependency>
3.82.3. Usage
CDI producer methods can be harnessed to bind endpoints to the Camel registry, so that they can be resolved using the ref
URI scheme in Camel routes.
For example, to produce endpoint beans:
@ApplicationScoped public class MyEndpointProducers { @Inject CamelContext context; @Singleton @Produces @Named("endpoint1") public Endpoint directStart() { return context.getEndpoint("direct:start"); } @Singleton @Produces @Named("endpoint2") public Endpoint logEnd() { return context.getEndpoint("log:end"); } }
Use ref:
to refer to the names of the CDI beans that were bound to the Camel registry:
public class MyRefRoutes extends RouteBuilder { @Override public void configure() { // direct:start -> log:end from("ref:endpoint1") .to("ref:endpoint2"); } }
3.83. REST OpenApi
Configure REST producers based on an OpenAPI specification document delegating to a component implementing the RestProducerFactory interface.
3.83.1. What’s inside
-
REST OpenApi component, URI syntax:
rest-openapi:specificationUri#operationId
Refer to the above link for usage and configuration details.
3.83.2. Maven coordinates
Create a new project with this extension on code.quarkus.redhat.com
Or add the coordinates to your existing project:
<dependency> <groupId>org.apache.camel.quarkus</groupId> <artifactId>camel-quarkus-rest-openapi</artifactId> </dependency>
3.83.3. Usage
3.83.3.1. Required Dependencies
A RestProducerFactory
implementation must be available when using the rest-openapi extension. The currently known extensions are:
- camel-quarkus-http
- camel-quarkus-netty-http
Maven users will need to add one of these dependencies to their pom.xml
, for example:
<dependency> <groupId>org.apache.camel.quarkus</groupId> <artifactId>camel-quarkus-http</artifactId> </dependency>
Depending on which mechanism is used to load the OpenApi specification, additional dependencies may be required. When using the file
resource locator, the org.apache.camel.quarkus:camel-quarkus-file
extension must be added as a project dependency. When using ref
or bean
to load the specification, not only must the org.apache.camel.quarkus:camel-quarkus-bean
dependency be added, but the bean itself must be annotated with @RegisterForReflection
.
When using the classpath
resource locator with native code, the path to the OpenAPI specification must be specified in the quarkus.native.resources.includes
property of the application.properties
file. For example:
quarkus.native.resources.includes=openapi.json
3.84. Rest
Expose REST services and their OpenAPI Specification or call external REST services.
3.84.1. What’s inside
-
REST component, URI syntax:
rest:method:path:uriTemplate
-
REST API component, URI syntax:
rest-api:path
Refer to the above links for usage and configuration details.
3.84.2. Maven coordinates
Create a new project with this extension on code.quarkus.redhat.com
Or add the coordinates to your existing project:
<dependency> <groupId>org.apache.camel.quarkus</groupId> <artifactId>camel-quarkus-rest</artifactId> </dependency>
3.84.3. Additional Camel Quarkus configuration
This extension depends on the Platform HTTP extension and configures it as the component that provides the REST transport.
3.84.3.1. Path parameters containing special characters with platform-http
When using the platform-http
REST transport, some characters are not allowed within path parameter names. This includes the '-' and '$' characters.
In order to make the below example REST /dashed/param
route work correctly, a system property is required io.vertx.web.route.param.extended-pattern=true
.
import org.apache.camel.builder.RouteBuilder; public class CamelRoute extends RouteBuilder { @Override public void configure() { rest("/api") // Dash '-' is not allowed by default .get("/dashed/param/{my-param}") .to("direct:greet") // The non-dashed path parameter works by default .get("/undashed/param/{myParam}") .to("direct:greet"); from("direct:greet") .setBody(constant("Hello World")); } }
There is some more background to this in the Vert.x Web documentation.
3.84.3.2. Configuring alternate REST transport providers
To use another REST transport provider, such as netty-http
or servlet
, you need to add the respective extension as a dependency to your project and set the provider in your RouteBuilder
. E.g. for servlet
, you’d have to add the org.apache.camel.quarkus:camel-quarkus-servlet
dependency and the set the provider as follows:
import org.apache.camel.builder.RouteBuilder; public class CamelRoute extends RouteBuilder { @Override public void configure() { restConfiguration() .component("servlet"); ... } }
3.85. Salesforce
Communicate with Salesforce using Java DTOs.
3.85.1. What’s inside
-
Salesforce component, URI syntax:
salesforce:operationName:topicName
Refer to the above link for usage and configuration details.
3.85.2. Maven coordinates
Create a new project with this extension on code.quarkus.redhat.com
Or add the coordinates to your existing project:
<dependency> <groupId>org.apache.camel.quarkus</groupId> <artifactId>camel-quarkus-salesforce</artifactId> </dependency>
3.85.3. Usage
3.85.3.1. Generating Salesforce DTOs with the salesforce-maven-plugin
Test content.
To generate Salesforce DTOs for your project, use the salesforce-maven-plugin
. The example code snippet below creates a single DTO for the Account
object.
<plugin> <groupId>org.apache.camel.maven</groupId> <artifactId>camel-salesforce-maven-plugin</artifactId> <version>{camel-version}</version> <executions> <execution> <goals> <goal>generate</goal> </goals> <configuration> <clientId>${env.SALESFORCE_CLIENTID}</clientId> <clientSecret>${env.SALESFORCE_CLIENTSECRET}</clientSecret> <userName>${env.SALESFORCE_USERNAME}</userName> <password>${env.SALESFORCE_PASSWORD}</password> <loginUrl>https://login.salesforce.com</loginUrl> <packageName>org.apache.camel.quarkus.component.salesforce.generated</packageName> <outputDirectory>src/main/java</outputDirectory> <includes> <include>Account</include> </includes> </configuration> </execution> </executions> </plugin>
3.85.3.2. Native mode support for Pub / Sub API with POJO pubSubDeserializeType
When using the Camel Salesforce Pub / Sub API and pubSubDeserializeType
is configured as POJO
, you must register any classes configured on the pubSubPojoClass
option for reflection.
For example, given the following route.
from("salesforce:pubSubSubscribe:/event/TestEvent__e?pubSubDeserializeType=POJO&pubSubPojoClass=org.foo.TestEvent") .log("Received Salesforce POJO topic message: ${body}");
Class org.foo.TestEvent
would need to be registered for reflection.
package org.foo; import io.quarkus.runtime.annotations.RegisterForReflection; @RegisterForReflection public class TestEvent { // Getters / setters etc }
Refer to the Native mode user guide for more information.
3.85.4. SSL in native mode
This extension auto-enables SSL support in native mode. Hence you do not need to add quarkus.ssl.native=true
to your application.properties
yourself. See also Quarkus SSL guide.
3.86. Saga
Execute custom actions within a route using the Saga EIP.
3.86.1. What’s inside
-
Saga component, URI syntax:
saga:action
Refer to the above link for usage and configuration details.
3.86.2. Maven coordinates
Create a new project with this extension on code.quarkus.redhat.com
Or add the coordinates to your existing project:
<dependency> <groupId>org.apache.camel.quarkus</groupId> <artifactId>camel-quarkus-saga</artifactId> </dependency>
3.87. SAP
Provides SAP Camel Component
3.87.1. What’s inside
The SAP extension is a package consisting of ten different SAP components. There are remote function call (RFC) components that support the sRFC, tRFC, and qRFC protocols and there are IDoc components that facilitate communication using messages in IDoc format. The component uses the SAP Java Connector (SAP JCo) library to facilitate bidirectional communication with SAP and the SAP IDoc library to transmit the documents in the Intermediate Document (IDoc) format.
See below for details.
3.87.2. Maven coordinates
<dependency> <groupId>org.apache.camel.quarkus</groupId> <artifactId>camel-quarkus-sap</artifactId> </dependency>
3.87.2.1. SAP Extension Camel Quarkus limitations
The SAP extension does not support the packaging type uber-jar
, which causes the application to throw a runtime exception similar to this:
Caused by: java.lang.ExceptionInInitializerError: JCo initialization failed with java.lang.ExceptionInInitializerError: Illegal JCo archive "sap-1.0.0-SNAPSHOT-runner.jar". It is not allowed to rename or repackage the original archive "sapjco3.jar".
3.87.2.2. Additional platform restrictions for the SAP component
Because the SAP component depends on the third-party JCo 3 and IDoc 3 libraries, it can only be installed on the platforms that these libraries support.
3.87.2.3. SAP JCo and SAP IDoc libraries
A prerequisite for using the SAP component is that the SAP Java Connector (SAP JCo) libraries and the SAP IDoc library are installed into the lib/
directory of the Java runtime. You must make sure that you download the appropriate set of SAP libraries for your target operating system from the SAP Service Marketplace.
The names of the library files vary depending on the target operating system, as shown below.
SAP Component | Linux and UNIX | Windows |
---|---|---|
SAP JCo 3 |
|
|
SAP IDoc |
|
|
In order to pull the correct SAP libraries, you must include the following dependencies in your pom.xml
<dependency> <groupId>com.sap.conn.jco</groupId> <artifactId>sapjco3</artifactId> <version>3.1.4</version> <scope>system</scope> <systemPath>${basedir}/lib/sapjco3.jar</systemPath> </dependency> <dependency> <groupId>com.sap.conn.idoc</groupId> <artifactId>sapidoc3</artifactId> <version>3.1.1</version> <scope>system</scope> <systemPath>${basedir}/lib/sapidoc3.jar</systemPath> </dependency>
3.87.3. URI format
There are two different kinds of endpoint provided by the SAP component: the Remote Function Call (RFC) endpoints, and the Intermediate Document (IDoc) endpoints.
The URI formats for the RFC endpoints are as follows:
sap-srfc-destination:destinationName:rfcName sap-trfc-destination:destinationName:rfcName sap-qrfc-destination:destinationName:queueName:rfcName sap-srfc-server:serverName:rfcName[?options] sap-trfc-server:serverName:rfcName[?options]
The URI formats for the IDoc endpoints are as follows:
sap-idoc-destination:destinationName:idocType[:idocTypeExtension[:systemRelease[:applicationRelease]]] sap-idoclist-destination:destinationName:idocType[:idocTypeExtension[:systemRelease[:applicationRelease]]] sap-qidoc-destination:destinationName:queueName:idocType[:idocTypeExtension[:systemRelease[:applicationRelease]]] sap-qidoclist-destination:destinationName:queueName:idocType[:idocTypeExtension[:systemRelease[:applicationRelease]]] sap-idoclist-server:serverName:idocType[:idocTypeExtension[:systemRelease[:applicationRelease]]][?options]
The URI formats prefixed by sap-endpointKind-destination are used to define destination endpoints (in other words, Camel producer endpoints) and destinationName is the name of a specific outbound connection to an SAP instance. Outbound connections are named and configured at the component level.
The URI formats prefixed by sap-endpointKind-server are used to define server endpoints (in other words, Camel consumer endpoints) and serverName is the name of a specific inbound connection from an SAP instance. Inbound connections are named and configured at the component level.
The other components of an RFC endpoint URI are as follows:
- rfcName
- (Required) In a destination endpoint URI, is the name of the RFC invoked by the endpoint in the connected SAP instance. In a server endpoint URI, is the name of the RFC handled by the endpoint when invoked from the connected SAP instance.
- queueName
- Specifies the queue this endpoint sends an SAP request to.
The other components of an IDoc endpoint URI are as follows:
- idocType
- (Required) Specifies the Basic IDoc Type of an IDoc produced by this endpoint.
- idocTypeExtension
- Specifies the IDoc Type Extension, if any, of an IDoc produced by this endpoint.
- systemRelease
- Specifies the associated SAP Basis Release, if any, of an IDoc produced by this endpoint.
- applicationRelease
- Specifies the associated Application Release, if any, of an IDoc produced by this endpoint.
- queueName
- Specifies the queue this endpoint sends an SAP request to.
3.87.3.1. Options for RFC destination endpoints
The RFC destination endpoints (sap-srfc-destination
, sap-trfc-destination
, and sap-qrfc-destination
) support the following URI options:
Name | Default | Description |
---|---|---|
|
|
If |
|
|
If |
3.87.3.2. Options for RFC server endpoints
The SAP RFC server endpoints (sap-srfc-server
and sap-trfc-server
) support the following URI options:
Name | Default | Description |
---|---|---|
|
|
If |
|
|
(sap-trfc-server endpoint only) If |
3.87.3.3. Options for the IDoc List Server endpoint
The SAP IDoc List Server endpoint (sap-idoclist-server
) supports the following URI options:
Name | Default | Description |
---|---|---|
|
|
If |
|
|
If |
3.87.3.4. Summary of the RFC and IDoc endpoints
The SAP component package provides the following RFC and IDoc endpoints:
sap-srfc-destination
Camel SAP Synchronous Remote Function Call Destination Camel component. This endpoint should be used in cases where Camel routes require synchronous delivery of requests to and responses from an SAP system.
NoteThe sRFC protocol used by this component delivers requests and responses to and from an SAP system, using best effort. In case of a communication error while sending a request, the completion status of a remote function call in the receiving SAP system remains in doubt.
sap-trfc-destination
Camel SAP Transactional Remote Function Call Destination Camel component. This endpoint should be used in cases where requests must be delivered to the receiving SAP system at most once. To accomplish this, the component generates a transaction ID,
tid
, which accompanies every request sent through the component in a route’s exchange. The receiving SAP system records thetid
accompanying a request before delivering the request; if the SAP system receives the request again with the sametid
it will not deliver the request. Thus if a route encounters a communication error when sending a request through an endpoint of this component, it can retry sending the request within the same exchange knowing it will be delivered and executed only once.NoteThe tRFC protocol used by this component is asynchronous and does not return a response. Thus the endpoints of this component do not return a response message.
NoteThis component does not guarantee the order of a series of requests through its endpoints, and the delivery and execution order of these requests may differ on the receiving SAP system due to communication errors and resends of a request. For guaranteed delivery order, please see the Camel SAP Queued Remote Function Call Destination Camel component.
sap-qrfc-destination
Camel SAP Queued Remote Function Call Destination Camel component. This component extends the capabilities of the Transactional Remote Function Call Destination camel component by adding in order delivery guarantees to the delivery of requests through its endpoints. This endpoint should be used in cases where a series of requests depend on each other and must be delivered to the receiving SAP system at most once and in order. The component accomplishes the at most once delivery guarantees using the same mechanisms as the Camel SAP Transactional Remote Function Call Destination Camel component. The ordering guarantee is accomplished by serializing the requests in the order they are received by the SAP system to an inbound queue. Inbound queues are processed by the QIN scheduler within SAP. When the inbound queue is activated, the QIN Scheduler will execute the queue requests in order.
NoteThe qRFC protocol used by this component is asynchronous and does not return a response. Thus the endpoints of this component do not return a response message.
sap-srfc-server
- Camel SAP Synchronous Remote Function Call Server Camel component. This component and its endpoints should be used in cases where a Camel route is required to synchronously handle requests from and responses to an SAP system.
sap-trfc-server
-
Camel SAP Transactional Remote Function Call Server Camel component. This endpoint should be used in cases where the sending SAP system requires at most once delivery of its requests to a Camel route. To accomplish this, the sending SAP system generates a transaction ID,
tid
, which accompanies every request it sends to the component’s endpoints. The sending SAP system will first check with the component whether a giventid
has been received by it before sending a series of requests associated with thetid
. The component will check the list of receivedtid
s it maintains, record the senttid
if it is not in that list, and then respond to the sending SAP system, indicating whether or not thetid
has already been recorded. The sending SAP system will only then send the series of requests, if thetid
has not been previously recorded. This enables a sending SAP system to reliably send a series of requests once to a camel route. sap-idoc-destination
- Camel SAP IDoc Destination Camel component. This endpoint should be used in cases where a Camel route sends a list of Intermediate Documents (IDocs) to an SAP system.
sap-idoclist-destination
- Camel SAP IDoc List Destination Camel component. This endpoint should be used in cases where a Camel route sends a list of Intermediate documents (IDocs) list to an SAP system.
sap-qidoc-destination
- Camel SAP Queued IDoc Destination Camel component. This component and its endpoints should be used in cases where a Camel route is required to send a list of Intermediate documents (IDocs) to an SAP system in order.
sap-qidoclist-destination
- Camel SAP Queued IDoc List Destination Camel component. This component and its endpoints are used in cases where a camel route sends the Intermediate documents (IDocs) list to an SAP system in order.
sap-idoclist-server
-
Camel SAP IDoc List Server Camel component. This endpoint should be used in cases where a sending SAP system requires delivery of Intermediate Document lists to a Camel route. This component uses the tRFC protocol to communicate with SAP as described in the
sap-trfc-server-standalone
quick start.
3.87.3.5. SAP RFC destination endpoint
An RFC destination endpoint supports outbound communication to SAP, which enable these endpoints to make RFC calls out to ABAP function modules in SAP. An RFC destination endpoint is configured to make an RFC call to a specific ABAP function over a specific connection to an SAP instance. An RFC destination is a logical designation for an outbound connection and has a unique name. An RFC destination is specified by a set of connection parameters called destination data.
An RFC destination endpoint will extract an RFC request from the input message of the IN-OUT exchanges it receives and dispatch that request in a function call to SAP. The response from the function call will be returned in the output message of the exchange. Since SAP RFC destination endpoints only support outbound communication, an RFC destination endpoint only supports the creation of producers.
3.87.3.6. SAP RFC server endpoint
An RFC server endpoint supports inbound communication from SAP, which enables ABAP applications in SAP to make RFC calls into server endpoints. An ABAP application interacts with an RFC server endpoint as if it were a remote function module. An RFC server endpoint is configured to receive an RFC call to a specific RFC function over a specific connection from an SAP instance. An RFC server is a logical designation for an inbound connection and has a unique name. An RFC server is specified by a set of connection parameters called server data.
An RFC server endpoint will handle an incoming RFC request and dispatch it as the input message of an IN-OUT exchange. The output message of the exchange will be returned as the response of the RFC call. Since SAP RFC server endpoints only support inbound communication, an RFC server endpoint only supports the creation of consumers.
3.87.3.7. SAP IDoc and IDoc list destination endpoints
An IDoc destination endpoint supports outbound communication to SAP, which can then perform further processing on the IDoc message. An IDoc document represents a business transaction, which can easily be exchanged with non-SAP systems. An IDoc destination is specified by a set of connection parameters called destination data.
An IDoc list destination endpoint is similar to an IDoc destination endpoint, except that the messages it handles consist of a list of IDoc documents.
3.87.3.8. SAP IDoc list server endpoint
An IDoc list server endpoint supports inbound communication from SAP, enabling a Camel route to receive a list of IDoc documents from an SAP system. An IDoc list server is specified by a set of connection parameters called server data.
3.87.3.9. Metadata repositories
A metadata repository is used to store the following kinds of metadata:
- Interface descriptions of function modules
- This metadata is used by the JCo and ABAP runtimes to check RFC calls to ensure the type-safe transfer of data between communication partners before dispatching those calls. A repository is populated with repository data. Repository data is a map of named function templates. A function template contains the metadata describing all the parameters and their typing information passed to and from a function module and has the unique name of the function module it describes.
- IDoc type descriptions
- This metadata is used by the IDoc runtime to ensure that the IDoc documents are correctly formatted before being sent to a communication partner. A basic IDoc type consists of a name, a list of permitted segments, and a description of the hierarchical relationship between the segments. Some additional constraints can be imposed on the segments: a segment can be mandatory or optional; and it is possible to specify a minimum/maximum range for each segment (defining the number of allowed repetitions of that segment).
SAP destination and server endpoints thus require access to a repository, in order to send and receive RFC calls and in order to send and receive IDoc documents. For RFC calls, the metadata for all function modules invoked and handled by the endpoints must reside within the repository; and for IDoc endpoints, the metadata for all IDoc types and IDoc type extensions handled by the endpoints must reside within the repository. The location of the repository used by a destination and server endpoint is specified in the destination data and the server data of their respective connections.
In the case of an SAP destination endpoint, the repository it uses typically resides in an SAP system, and it defaults to the SAP system it is connected to. This default requires no explicit configuration in the destination data. Furthermore, the metadata for the remote function call that a destination endpoint makes will already exist in a repository for any existing function module that it calls. The metadata for calls made by destination endpoints thus require no configuration in the SAP component.
On the other hand, the metadata for function calls handled by server endpoints do not typically reside in the repository of an SAP system and must instead be provided by a repository residing in the SAP component. The SAP component maintains a map of named metadata repositories. The name of a repository corresponds to the name of the server to which it provides metadata.
3.87.4. Configuration
The SAP component maintains three maps to store destination data, server data, and repository data. The destination data store and the server data store are configured on a special configuration object, SapConnectionConfiguration
, which automatically gets injected into the SAP component. The repository data store must be configured directly on the relevant SAP component.
3.87.4.1. Configuration Overview
The SAP component maintains three maps to store destination data, server data, and repository data. The component’s property, destinationDataStore
, stores destination data keyed by destination name, the property, serverDataStore
, stores server data keyed by server name and the property, repositoryDataStore
, stores repository data keyed by repository name. These configurations must be passed to the component during its initialization.
Example
The following example shows how to configure a sample destination data store and a sample server data store. The sap-configuration
bean (of type SapConnectionConfiguration
) will be automatically injected into any SAP component that is used in this application.
public class SAPRouteBuilder extends RouteBuilder { @BindToRegistry("sap-configuration") public SapConnectionConfiguration sapConfiguration() { SapConnectionConfiguration configuration = new SapConnectionConfiguration(); configuration.setDestinationDataStore(destinationData()); configuration.setServerDataStore(serverData()); return configuration; } /** * Configures an Inbound SAP Connection * Please enter the connection property values for your environment */ private Map<String, ServerData> serverData() { ServerData data = new ServerDataImpl(); data.setGwhost("example.com"); data.setGwserv("3300"); data.setProgid("QUICKSTART"); data.setRepositoryDestination("quickstartDest"); data.setConnectionCount("2"); return Map.of("quickstartServer", data); } /** * Configures an Outbound SAP Connection * Please enter the connection property values for your environment */ private Map<String, DestinationData> destinationData() { DestinationData data = new DestinationDataImpl(); data.setAshost("example.com"); data.setSysnr("00"); data.setClient("000"); data.setUser("username"); data.setPasswd("password"); data.setLang("en"); return Map.of("quickstartDest", data); } @Override public void configure() throws Exception { // Routes definitions } }
The values can be supplied from the application.properties
file. In that case, you can use the property name instead of the hardcoded value.
For example:
ConfigProvider.getConfig().getValue("<property name>", String.class)
3.87.4.2. Destination Configuration
The configurations for destinations are maintained in the destinationDataStore
property of the SAP component. Each entry in this map configures a distinct outbound connection to an SAP instance. The key for each entry is the name of the outbound connection and is used in the destinationName component of a destination endpoint URI as described in the URI format section.
The value for each entry is a destination data configuration object - org.fusesource.camel.component.sap.model.rfc.impl.DestinationDataImpl
- that specifies the configuration of an outbound SAP connection.
Sample destination configuration
The following code shows how to configure a sample destination with the name, quickstartDest
:
@BindToRegistry("sap-configuration") public SapConnectionConfiguration sapConfiguration() { SapConnectionConfiguration configuration = new SapConnectionConfiguration(); configuration.setDestinationDataStore(destinationData()); return configuration; } private Map<String, DestinationData> destinationData() { DestinationData data = new DestinationDataImpl(); data.setAshost("example.com"); data.setSysnr("00"); data.setClient("000"); data.setUser("username"); data.setPasswd("password"); data.setLang("en"); return Map.of("quickstartDest", data); } @Override public void configure() throws Exception { ((DefaultCamelContext) getCamelContext()).addInterceptStrategy(new CurrentProcessorDefinitionInterceptStrategy()); // Routes definitions }
After configuring the destination as shown above, you can invoke the BAPI_FLCUST_GETLIST
remote function call on the quickstartDest
destination with the following URI:
sap-srfc-destination:quickstartDest:BAPI_FLCUST_GETLIST
3.87.4.2.1. Interceptor for tRFC and qRFC destinations
The preceding sample destination configuration shows the instantiation of a CurrentProcessorDefinitionInterceptStrategy
object. This object installs an interceptor in the Camel runtime, which enables the Camel SAP component to keep track of its position within a Camel route while it is handling RFC transactions.
This interceptor is critically important for transactional RFC destination endpoints (such as sap-trfc-destination
and sap-qrfc-destination
) and must be installed in the Camel runtime for outbound transactional RFC communication to be properly managed. The Destination RFC Transaction Handlers issues warnings into the Camel log if the strategy is not found at runtime. In this situation the Camel runtime will need to be re-provisioned and restarted to properly manage outbound transactional RFC communication.
3.87.4.2.2. Log on and authentication options
The following table lists the log on and authentication options for configuring a destination in the SAP destination data store:
Name | Default Value | Description |
| SAP client, mandatory log on parameter. | |
| log on user, log on parameter for password based authentication. | |
| log on user alias, can be used instead of log on user. | |
| User identity used for log on to the ABAP AS. Used by the JCo runtime, if the destination configuration uses SSO/assertion ticket, certificate, current user ,or SNC environment for authentication. The user ID is mandatory, if neither user nor user alias is set. This ID will never be sent to the SAP backend, it will be used by the JCo runtime locally. | |
| log on password, log on parameter for password based authentication. | |
| log on language, if not defined, the default user language is used. | |
| Use the specified SAP Cookie Version 2 as a log on ticket for SSO based authentication. | |
| Use the specified X509 certificate for certificate based authentication. | |
| Postpone the authentication until the first call - 1 (enable). Used in special cases only. | |
| Use a visible, hidden, or do not use SAP GUI | |
| Additional log on parameter to define the codepage used to convert the log on parameters. Used in special cases only. | |
| Order an SSO ticket after log on, the obtained ticket is available in the destination attributes. | |
|
If set to |
3.87.4.2.3. Connection options
The following table lists the connection options for configuring a destination in the SAP destination data store:
Name | Default Value | Description |
|
SAP Router string for connection to systems behind a SAP Router. SAP Router string contains the chain of SAP Routers and theirs port numbers and has the form: | |
| System number of the SAP ABAP application server, mandatory for a direct connection. | |
| SAP ABAP application server, mandatory for a direct connection. | |
| SAP message server, mandatory property for a load balancing connection. | |
|
SAP message server port, optional property for a load balancing connection. In order to resolve the service names sapmsXXX a lookup in | |
| Allows specifying a concrete gateway, which should be used for establishing the connection to an application server. If not specified, the gateway on the application server is used. | |
| Should be set, when using gwhost. Allows specifying the port used on that gateway. If not specified, the port of the gateway on the application server is used. In order to resolve the service names sapgwXXX a lookup in etc/services is performed by the network layer of the operating system. If using port numbers instead of symbolic service names, no lookups are performed and no additional entries are needed. | |
| System ID of the SAP system, mandatory property for a load balancing connection. | |
| Group of SAP application servers, mandatory property for a load balancing connection. | |
|
|
Set this value depending on the network quality between JCo and your target system to optimize performance. The valid values are |
|
|
The valid values are |
3.87.4.2.4. Connection pool options
The following table lists the connection pool options for configuring a destination in the SAP destination data store:
Name | Default Value | Description |
|
|
Maximum number of active outbound connections that can be created for a destination simultaneously. A value of |
|
|
Maximum number of idle outbound connections kept open by the destination. A value of |
| Time in milliseconds after which a free connection held internally by the destination can be closed. | |
| Period in milliseconds after which the destination checks the released connections for expiration. | |
| Maximum time in milliseconds to wait for a connection, if the maximum allowed number of connections has already been allocated by the application. |
3.87.4.2.5. Secure network connection options
The following table lists the secure network options for configuring a destination in the SAP destination data store:
Name | Default Value | Description |
|
Secure network connection (SNC) mode, | |
|
SNC partner, for example: | |
|
SNC level of security: | |
| Own SNC name. Overrides the environment settings. | |
| Path to the library that provides the SNC service. |
3.87.4.2.6. Repository options
The following table lists the repository options for configuring a destination in the SAP destination data store:
Name | Default Value | Description |
| Specifies the destination which is used as a repository. | |
| If a repository destination is not set, and this property is set, it is used as user for repository calls. This enables you to use a different user for repository lookups. | |
| The password for a repository user. Mandatory, if a repository user is used. | |
|
(Optional) If SNC is used for this destination, it is possible to turn it off for repository connections, if this property is set to | |
|
Enable the
If the property is not set, the destination initially does a remote call to check whether Note: If the repository is already initialized (for example, because it is used by some other destination), this property does not have any effect. Generally, this property is related to the ABAP System, and should have the same value on all destinations pointing to the same ABAP System. See note 1456826 for backend prerequisites. |
3.87.4.2.7. Trace configuration options
The following table lists the trace configuration options for configuring a destination in the SAP destination data store:
Name | Default Value | Description |
|
Enable/disable RFC trace ( | |
|
Enable/disable CPIC trace |
3.87.4.3. Server Configuration
The configurations for servers are maintained in the serverDataStore
property of the SAP component. Each entry in this map configures a distinct inbound connection from an SAP instance. The key for each entry is the name of the outbound connection and is used in the serverName
component of a server endpoint URI as described in the URI format section.
The value for each entry is a server data configuration object, org.fusesource.camel.component.sap.model.rfc.impl.ServerDataImpl
, which defines the configuration of an inbound SAP connection.
Sample server configuration
The following code shows how to create a sample server configuration with the name, quickstartServer
.
@BindToRegistry("sap-configuration") public SapConnectionConfiguration sapConfiguration() { SapConnectionConfiguration configuration = new SapConnectionConfiguration(); configuration.setDestinationDataStore(destinationData()); configuration.setServerDataStore(serverData()); return configuration; } /** * Configures an Inbound SAP Connection * Please enter the connection property values for your environment */ private Map<String, ServerData> serverData() { ServerData data = new ServerDataImpl(); data.setGwhost("example.com"); data.setGwserv("3300"); data.setProgid("QUICKSTART"); data.setRepositoryDestination("quickstartDest"); data.setConnectionCount("2"); return Map.of("quickstartServer", data); } /** * Configures an Outbound SAP Connection * Please enter the connection property values for your environment */ private Map<String, DestinationData> destinationData() { DestinationData data = new DestinationDataImpl(); data.setAshost("example.com"); data.setSysnr("00"); data.setClient("000"); data.setUser("username"); data.setPasswd("password"); data.setLang("en"); return Map.of("quickstartDest", data); }
This example also configures a destination connection, quickstartDest
, which the server uses to retrieve metadata from a remote SAP instance. This destination is configured in the server data through the repositoryDestination
option. If you do not configure this option, you must create a local metadata repository instead.
After configuring the destination as shown above, you can handle the BAPI_FLCUST_GETLIST
remote function call on the quickstartDest
remote function call from an invoking client, using the following URI:
sap-srfc-server:quickstartServer:BAPI_FLCUST_GETLIST
3.87.4.3.1. Required options
The required options for the server data configuration object are, as follows:
Name | Default Value | Description |
| Gateway host on which the server connection should be registered. | |
|
Gateway service, which is the port on which a registration can be done. In order to resolve the service names | |
| The program ID with which the registration is done. Serves as an identifier on the gateway and in the destination in the ABAP system. | |
| Specifies a destination name that the server can use in order to retrieve metadata from a metadata repository hosted in a remote SAP server. | |
| The number of connections that should be registered at the gateway. |
3.87.4.3.2. Secure network connection options
The secure network connection options for the server data configuration object are as follows:
Name | Default Value | Description |
|
Secure network connection (SNC) mode, | |
|
SNC level of security, | |
|
SNC name of your server. Overrides the default SNC name. Typically something like | |
|
Path to library which provides SNC service. If this property is not provided, the value of the |
3.87.4.3.3. Other options
The other options for the server data configuration object are, as follows:
Name | Default Value | Description |
|
SAP router string to use for a system protected by a firewall, which can therefore only be reached through a SAProuter, when registering the server at the gateway of that ABAP System. A typical router string is | |
| The maximum time (in seconds) between two start-up attempts in case of failures. The waiting time is doubled from initially 1 second after each start-up failure until either the maximum value is reached or the server could be started successfully. | |
|
Enable/disable RFC trace ( | |
|
The maximum number of threads used by the server connection. If not set, the value for the | |
|
The minimum number of threads used by server connection. If not set, the value for |
3.87.4.4. Repository Configuration
The configurations for repositories are maintained in the repositoryDataStore
property of the SAP Component. Each entry in this map configures a distinct repository. The key for each entry is the name of the repository and this key also corresponds to the name of the server to which this repository is attached.
The value of each entry is a repository data configuration object, org.fusesource.camel.component.sap.model.rfc.impl.RepositoryDataImpl
, that defines the contents of a metadata repository. A repository data object is a map of function template configuration objects, org.fuesource.camel.component.sap.model.rfc.impl.FunctionTemplateImpl
. Each entry in this map specifies the interface of a function module and the key for each entry is the name of the function module specified.
Repository data example
The following code shows a simple example of configuring a metadata repository:
@BindToRegistry("sap-configuration") public SapConnectionConfiguration sapConfiguration() { SapConnectionConfiguration configuration = new SapConnectionConfiguration(); configuration.setRepositoryDataStore(repositoryData()); return configuration; } private Map<String, RepositoryData> repositoryData() { RepositoryData data = new RepositoryDataImpl(); FunctionTemplate bookFlightFunctionTemplate = new FunctionTemplateImpl(); data.setFunctionTemplates(Map.of("BOOK_FLIGHT", bookFlightFunctionTemplate)); return Map.of("nplServer", data); }
3.87.4.4.1. Function template properties
The interface of a function module consists of four parameter lists by which data is transferred back and forth to the function module in an RFC call. Each parameter list consists of one or more fields, each of which is a named parameter transferred in an RFC call. The following parameter lists and exception list are supported:
- The import parameter list contains parameter values sent to a function module in an RFC call;
- The export parameter list contains parameter values that are returned by a function module in an RFC call;
- The changing parameter list contains parameter values sent to and returned by a function module in an RFC call;
- The table parameter list contains internal table values sent to and returned by a function module in an RFC call.
- The interface of a function module also consists of an exception list of ABAP exceptions that may be raised when the module is invoked in an RFC call.
A function template describes the name and type of parameters in each parameter list of a function interface and the ABAP exceptions thrown by the function. A function template object maintains five property lists of metadata objects, as described in the following table.
Property | Description |
|
A list of list field metadata objects, |
|
A list of list field metadata objects, |
|
A list of list field metadata objects, |
|
A list of list field metadata objects, |
|
A list of ABAP exception metadata objects, |
Function template example
The following example shows an outline of how to configure a function template:
FunctionTemplate bookFlightFunctionTemplate = new FunctionTemplateImpl(); List<ListFieldMetaData> metaDataList = new ArrayList<>(); ListFieldMetaData metaData = new ListFieldMetaDataImpl(); // configure values metaData.setName("example"); metaDataList.add(metaData); bookFlightFunctionTemplate.setImportParameterList(metaDataList); // in the same way you can configure other parameters bookFlightFunctionTemplate.setExportParameterList(...); bookFlightFunctionTemplate.setChangingParameterList(...); bookFlightFunctionTemplate.setExceptionList(...); bookFlightFunctionTemplate.setTableParameterList(...);
3.87.4.4.2. List field metadata properties
A list field metadata object, org.fusesource.camel.component.sap.model.rfc.impl.ListFieldMeataDataImpl
, specifies the name and type of a field in a parameter list. For an elementary parameter field (CHAR
, DATE
, BCD
, TIME
, BYTE
, NUM
, FLOAT
, INT
, INT1
, INT2
, DECF16
, DECF34
, STRING
, XSTRING
), the following table lists the configuration properties that may be set on a list field metadata object:
Name | Default Value | Description |
| - | The name of the parameter field. |
| - | The parameter type of the field. |
| - | The field length in bytes for a non-Unicode layout. This value depends on the parameter type. |
| - | The field length in bytes for a Unicode layout. This value depends on the parameter type. |
|
| The number of decimals in field value. Required for parameter types BCD and FLOAT. |
|
|
If |
Note that all elementary parameter fields require that the name
, type
, byteLength
, and unicodeByteLength
properties be specified in the field metadata object. In addition, the BCD
, FLOAT
, DECF16
, and DECF34
fields require the decimal property to be specified in the field metadata object.
For a complex parameter field of type TABLE
or STRUCTURE
, the following table lists the configuration properties that may be set on a list field metadata object:
Name | Default Value | Description |
| - | The name of the parameter field. |
| - | The parameter type of the field. |
| - |
The metadata for the structure or table. A record metadata object, |
|
|
If |
All complex parameter fields require that the name
, type
, and recordMetaData
properties be specified in the field metadata object. The value of the recordMetaData
property is a record field metadata object, org.fusesource.camel.component.sap.model.rfc.impl.RecordMetaDataImpl
, which specifies the structure of a nested structure or the structure of a table row.
Elementary list field metadata example
The following metadata configuration specifies an optional, 24-digit packed BCD number parameter with two decimal places named TICKET_PRICE
:
ListFieldMetaData metaData = new ListFieldMetaDataImpl(); metaData.setName("TICKET_PRICE"); metaData.setType(DataType.BCD); metaData.setByteLength(12); metaData.setUnicodeByteLength(24); metaData.setDecimals(2); metaData.setOptional(true);
Complex list field metadata example
The following metadata configuration specifies a required TABLE
parameter named CONNINFO
with a row structure specified by the connectionInfo
record metadata object:
ListFieldMetaData metaData = new ListFieldMetaDataImpl(); metaData.setName("CONNINFO"); metaData.setType(DataType.TABLE); RecordMetaData connectionInfo = new RecordMetaDataImpl(); metaData.setRecordMetaData(connectionInfo);
3.87.4.4.3. Record metadata properties
A record metadata object, org.fusesource.camel.component.sap.model.rfc.impl.RecordMetaDataImpl
, specifies the name and contents of a nested STRUCTURE
or the row of a TABLE
parameter. A record metadata object maintains a list of record field metadata objects, org.fusesource.camel.component.sap.model.rfc.impl.FieldMetaDataImpl
, which specifies the parameters that reside in the nested structure or table row.
The following table lists configuration properties that may be set on a record metadata object:
Name | Default Value | Description |
| - | The name of the record. |
| - |
The list of record field metadata objects, |
All properties of the record metadata object are required.
Record metadata example
The following example shows how to configure a record metadata object:
RecordMetaData connectionInfo = new RecordMetaDataImpl(); connectionInfo.setName("CONNECTION_INFO"); connectionInfo.setRecordFieldMetaData(...);
3.87.4.4.4. Record field metadata properties
A record field metadata object, org.fusesource.camel.component.sap.model.rfc.impl.FieldMetaDataImpl
, specifies the name and type of a parameter field within a structure.
A record field metadata object is similar to a parameter field metadata object, except that the offsets of the individual field locations within the nested structure or table row must be additionally specified. The non-Unicode and Unicode offsets of an individual field must be calculated and specified from the sum of non-Unicode and Unicode byte lengths of the preceding fields in the structure or row.
The failure to properly specify the offsets of fields in nested structures and table rows will cause the field storage of parameters in the underlying JCo and ABAP runtimes to overlap and prevent the proper transfer of values in RFC calls.
For an elementary parameter field (CHAR
, DATE
, BCD
, TIME
, BYTE
, NUM
, FLOAT
, INT
, INT1
, INT2
, DECF16
, DECF34
, STRING
, XSTRING
), the following table lists the configuration properties that may be set on a record field metadata object:
Name | Default Value | Description |
| - | The name of the parameter field. |
| - | The parameter type of the field. |
| - | The field length in bytes for a non-Unicode layout. This value depends on the parameter type. |
| - | The field length in bytes for a Unicode layout. This value depends on the parameter type. |
| - | The field offset in bytes for non-Unicode layout. This offset is the byte location of the field within the enclosing structure. |
| - | The field offset in bytes for Unicode layout. This offset is the byte location of the field within the enclosing structure. |
|
|
The number of decimals in field value; only required for parameter types |
For a complex parameter field of type TABLE
or STRUCTURE
, the following table lists the configuration properties that may be set on a record field metadata object:
Name | Default Value | Description |
| - | The name of the parameter field. |
| - | The parameter type of the field. |
| - | The field offset in bytes for non-Unicode layout. This offset is the byte location of the field within the enclosing structure. |
| - | The field offset in bytes for Unicode layout. This offset is the byte location of the field within the enclosing structure. |
| - |
The metadata for the structure or table. A record metadata object, |
Elementary record field metadata example
The following metadata configuration specifies a DATE
field parameter named ARRDATE
located 85 bytes into the enclosing structure in the case of a non-Unicode layout and located 170 bytes into the enclosing structure in the case of a Unicode layout.
FieldMetaData fieldMetaData = new FieldMetaDataImpl(); fieldMetaData.setName("FLTINFO"); fieldMetaData.setType(DataType.STRUCTURE); fieldMetaData.setByteOffset(0); fieldMetaData.setUnicodeByteOffset(0); RecordMetaData flightInfo = new RecordMetaDataImpl(); fieldMetaData.setRecordMetaData(flightInfo);
Complex record field metadata example
The following metadata configuration specifies a STRUCTURE
field parameter named FLTINFO
with a structure specified by the flightInfo
record metadata object. The parameter is located at the beginning of the enclosing structure in both the case of a non-Unicode and Unicode layout.
FieldMetaData fieldMetaData = new FieldMetaDataImpl(); fieldMetaData.setName("FLTINFO"); fieldMetaData.setType(DataType.STRUCTURE); fieldMetaData.setByteOffset(0); fieldMetaData.setUnicodeByteOffset(0); RecordMetaData flightInfo = new RecordMetaDataImpl(); fieldMetaData.setRecordMetaData(flightInfo);
3.87.5. Message Headers
The SAP component supports the following message headers:
Header | Description |
|
The URI scheme of the last endpoint to process the message. Use one of the following values:
|
| The destination name of the last destination endpoint to process the message. |
| The server name of the last server endpoint to process the message. |
| The queue name of the last queuing endpoint to process the message. |
| The RFC name of the last RFC endpoint to process the message. |
| The IDoc type of the last IDoc endpoint to process the message. |
| The IDoc type extension, if any, of the last IDoc endpoint to process the message. |
| The system release, if any, of the last IDoc endpoint to process the message. |
| The application release, if any, of the last IDoc endpoint to process the message. |
3.87.6. Exchange Properties
The SAP component adds the following exchange properties:
Property | Description |
|
A map containing the properties of each SAP destination encountered by the exchange. The map is keyed by destination name and each entry is a |
|
A map containing the properties of each SAP server encountered by the exchange. The map is keyed by server name and each entry is a |
3.87.7. Message Body for RFC
3.87.7.1. Request and response objects
An SAP endpoint expects to receive a message with a message body containing an SAP request object and will return a message with a message body containing an SAP response object. SAP requests and responses are fixed map data structures containing named fields with each field having a predefined data type.
Note that the named fields in an SAP request and response are specific to an SAP endpoint, with each endpoint defining the parameters in the SAP request and response it will accept. An SAP endpoint provides factory methods to create the request and response objects that are specific to it.
public class SAPEndpoint ... { ... public Structure getRequest() throws Exception; public Structure getResponse() throws Exception; ... }
3.87.7.2. Structure objects
Both SAP request and response objects are represented in Java as a structure object which supports the org.fusesource.camel.component.sap.model.rfc.Structure
interface. This interface extends both the java.util.Map
and org.eclipse.emf.ecore.EObject
interfaces.
public interface Structure extends org.eclipse.emf.ecore.EObject, java.util.Map<String, Object> { <T> T get(Object key, Class<T> type); }
The field values in a structure object are accessed through the field’s getter methods in the map interface. In addition, the structure interface provides a type-restricted method to retrieve field values.
Structure objects are implemented in the component runtime using the Eclipse Modeling Framework (EMF) and support that framework’s EObject
interface. Instances of a structure object have attached metadata which define and restrict the structure and contents of the map of fields it provides. This metadata can be accessed and introspected using the standard methods provided by EMF. Refer to the EMF documentation for further details.
Attempts to get a parameter not defined on a structure object will return null. Attempts to set a parameter not defined on a structure will throw an exception as well as attempts to set the value of a parameter with an incorrect type.
As discussed in the following sections, structure objects can contain fields that contain values of the complex field types, STRUCTURE
, and TABLE
.
It is unnecessary to create instances of these types and add them to the structure. Instances of these field values are created on demand if necessary when accessed in the enclosing structure.
3.87.7.3. Field types
The fields that reside within the structure object of an SAP request or response may be either elementary or complex. An elementary field contains a single scalar value, whereas a complex field will contain one or more fields of either an elementary or complex type.
3.87.7.3.1. Elementary field types
An elementary field may be a character, numeric, hexadecimal or string field type. The following table summarizes the types of elementary fields that may reside in a structure object:
Field Type | Corresponding Java Type | Byte Length | Unicode Byte Length | Number Decimals Digits | Description |
|
| 1 to 65535 | 1 to 65535 | - | ABAP Type ‘C’: Fixed sized character string |
|
| 8 | 16 | - | ABAP Type ‘D’: Date (format: YYYYMMDD) |
|
| 1 to 16 | 1 to 16 | 0 to 14 | ABAP Type ‘P’: Packed BCD number. A BCD number contains two digits per byte. |
|
| 6 | 12 | - | ABAP Type ‘T’: Time (format: HHMMSS) |
|
| 1 to 65535 | 1 to 65535 | - | ABAP Type ‘X’:Fixed sized byte array |
|
| 1 to 65535 | 1 to 65535 | - | ABAP Type ‘N’: Fixed sized numeric character string |
|
| 8 | 8 | 0 to 15 | ABAP Type ‘F’: Floating point number |
|
| 4 | 4 | - | ABAP Type ‘I’: 4-byte Integer |
|
| 2 | 2 | - | ABAP Type ‘S’: 2-byte Integer |
|
| 1 | 1 | - | ABAP Type ‘B’: 1-byte Integer |
|
| 8 | 8 | 16 | ABAP Type ‘decfloat16’: 8 -byte Decimal Floating Point Number |
|
| 16 | 16 | 34 | ABAP Type ‘decfloat34’: 16-byte Decimal Floating Point Number |
|
| 8 | 8 | - | ABAP Type ‘G’: Variable length character string |
|
| 8 | 8 | - | ABAP Type ‘Y’: Variable length byte array |
3.87.7.3.2. Character field types
A character field contains a fixed sized character string that may use either a non-Unicode or Unicode character encoding in the underlying JCo and ABAP runtimes. Non-Unicode character strings encode one character per byte. Unicode character strings are encoded in two bytes using UTF-16 encoding. Character field values are represented in Java as java.lang.String
objects and the underlying JCo runtime is responsible for the conversion to their ABAP representation.
A character field declares its field length in its associated byteLength
and unicodeByteLength
properties, which determine the length of the field’s character string in each encoding system.
CHAR
-
A
CHAR
character field is a text field containing alphanumeric characters and corresponds to the ABAP type C. NUM
-
A
NUM
character field is a numeric text field containing numeric characters only and corresponds to the ABAP type N. DATE
-
A
DATE
character field is an 8 character date field with the year, month and day formatted asYYYYMMDD
and corresponds to the ABAP type D. TIME
-
A
TIME
character field is a 6 character time field with the hours, minutes and seconds formatted asHHMMSS
and corresponds to the ABAP type T.
3.87.7.3.3. Numeric field types
A numeric field contains a number. The following numeric field types are supported:
INT
-
An
INT
numeric field is an integer field stored as a 4-byte integer value in the underlying JCo and ABAP runtimes and corresponds to the ABAP type I. AnINT
field value is represented in Java as ajava.lang.Integer
object. INT2
-
An
INT2
numeric field is an integer field stored as a 2-byte integer value in the underlying JCo and ABAP runtimes and corresponds to the ABAP type S. AnINT2
field value is represented in Java as ajava.lang.Integer
object. INT1
-
An
INT1
field is an integer field stored as a 1-byte integer value in the underlying JCo and ABAP runtimes value and corresponds to the ABAP type B. AnINT1
field value is represented in Java as ajava.lang.Integer
object. FLOAT
-
A
FLOAT
field is a binary floating point number field stored as an 8-byte double value in the underlying JCo and ABAP runtimes and corresponds to the ABAP type F. AFLOAT
field declares the number of decimal digits that the field’s value contains in its associated decimal property. In the case of aFLOAT
field, this decimal property can have a value between 1 and 15 digits. AFLOAT
field value is represented in Java as ajava.lang.Double
object. BCD
-
A
BCD
field is a binary coded decimal field stored as a 1 to 16 byte packed number in the underlying JCo and ABAP runtimes and corresponds to the ABAP type P. A packed number stores two decimal digits per byte. ABCD
field declares its field length in its associatedbyteLength
andunicodeByteLength
properties. In the case of aBCD
field, these properties can have a value between 1 and 16 bytes, and both properties will have the same value. ABCD
field declares the number of decimal digits that the field’s value contains in its associated decimal property. In the case of aBCD
field, this decimal property can have a value between 1 and 14 digits. ABCD
field value is represented in Java as ajava.math.BigDecimal
. DECF16
-
A
DECF16
field is a decimal floating point stored as an 8-byte IEEE 754 decimal64 floating point value in the underlying JCo and ABAP runtimes and corresponds to the ABAP typedecfloat16
. The value of aDECF16
field has 16 decimal digits. The value of aDECF16
field is represented in Java asjava.math.BigDecimal
. DECF34
-
A
DECF34
field is a decimal floating point stored as a 16-byte IEEE 754 decimal128 floating point value in the underlying JCo and ABAP runtimes and corresponds to the ABAP typedecfloat34
. The value of aDECF34
field has 34 decimal digits. The value of aDECF34
field is represented in Java asjava.math.BigDecimal
.
3.87.7.3.4. Hexadecimal field types
A hexadecimal field contains raw binary data. The following hexadecimal field types are supported:
BYTE
-
A
BYTE
field is a fixed sized byte string stored as a byte array in the underlying JCo and ABAP runtimes and corresponds to the ABAP type X. ABYTE
field declares its field length in its associatedbyteLength
andunicodeByteLength
properties. In the case of aBYTE
field, these properties can have a value between 1 and 65535 bytes and both properties will have the same value. The value of aBYTE
field is represented in Java as abyte[]
object.
3.87.7.3.5. String field types
A string field references a variable length string value. The length of that string value is not fixed until runtime. The storage for the string value is dynamically created in the underlying JCo and ABAP runtimes. The storage for the string field itself is fixed and contains only a string header.
STRING
-
A
STRING
field refers to a character string stored in the underlying JCo and ABAP runtimes as an 8-byte value. It corresponds to the ABAP type G. The value of theSTRING
field is represented in Java as ajava.lang.String
object. XSTRING
-
An
XSTRING
field refers to a byte string stored in the underlying JCo and ABAP runtimes as an 8-byte value. It corresponds to the ABAP type Y. The value of theSTRING
field is represented in Java as abyte[]
object.
3.87.7.3.6. Complex field types
A complex field may be either a structure or table field type. The following table summarizes these complex field types.
Field Type | Corresponding Java Type | Byte Length | Unicode Byte Length | Number Decimals Digits | Description |
|
| Total of individual field byte lengths | Total of individual field Unicode byte lengths | - | ABAP Type ‘u’ & ‘v’: Heterogeneous Structure |
|
| Byte length of row structure | Unicode byte length of row structure | - | ABAP Type ‘h’: Table |
3.87.7.3.7. Structure field types
A STRUCTURE
field contains a structure object and is stored in the underlying JCo and ABAP runtimes as an ABAP structure record. It corresponds to either an ABAP type u
or v
. The value of a STRUCTURE
field is represented in Java as a structure object with the interface org.fusesource.camel.component.sap.model.rfc.Structure
.
3.87.7.3.8. Table field types
A TABLE
field contains a table object and is stored in the underlying JCo and ABAP runtimes as an ABAP internal table. It corresponds to the ABAP type h
. The value of the field is represented in Java by a table object with the interface org.fusesource.camel.component.sap.model.rfc.Table
.
3.87.7.3.9. Table objects
A table object is a homogeneous list data structure containing rows of structure objects with the same structure. This interface extends both the java.util.List
and org.eclipse.emf.ecore.EObject
interfaces.
public interface Table<S extends Structure> extends org.eclipse.emf.ecore.EObject, java.util.List<S> { /** * Creates and adds a table row at the end of the row list */ S add(); /** * Creates and adds a table row at the index in the row list */ S add(int index); }
The list of rows in a table object is accessed and managed using the standard methods defined in the list interface. In addition, the table interface provides two factory methods for creating and adding structure objects to the row list.
Table objects are implemented in the component runtime using the Eclipse Modeling Framework (EMF) and support that framework’s EObject interface. Instances of a table object have attached metadata which define and restrict the structure and contents of the rows it provides. This metadata can be accessed and introspected using the standard methods provided by EMF. Refer to the EMF documentation for further details.
Attempts to add or set a row structure value of the wrong type will throw an exception.
3.87.8. Message Body for IDoc
3.87.8.1. IDoc message type
When using one of the IDoc Camel SAP endpoints, the type of the message body depends on which particular endpoint you are using.
For a sap-idoc-destination
endpoint or a sap-qidoc-destination
endpoint, the message body is of Document
type:
org.fusesource.camel.component.sap.model.idoc.Document
For a sap-idoclist-destination
endpoint, a sap-qidoclist-destination
endpoint, or a sap-idoclist-server
endpoint, the message body is of DocumentList
type:
org.fusesource.camel.component.sap.model.idoc.DocumentList
3.87.8.2. The IDoc document model
For the Camel SAP component, an IDoc document is modeled using the Eclipse Modeling Framework (EMF), which provides a wrapper API around the underlying SAP IDoc API. The most important types in this model are:
org.fusesource.camel.component.sap.model.idoc.Document org.fusesource.camel.component.sap.model.idoc.Segment
The Document
type represents an IDoc document instance. In outline, the Document
interface exposes the following methods:
// Java package org.fusesource.camel.component.sap.model.idoc; ... public interface Document extends EObject { // Access the field values from the IDoc control record String getArchiveKey(); void setArchiveKey(String value); String getClient(); void setClient(String value); ... // Access the IDoc document contents Segment getRootSegment(); }
The following kinds of method are exposed by the Document
interface:
- Methods for accessing the control record
- Most of the methods are for accessing or modifying field values of the IDoc control record. These methods are of the form AttributeName, where AttributeName is the name of a field value.
- Method for accessing the document contents
The
getRootSegment
method provides access to the document contents (IDoc data records), returning the contents as aSegment
object. EachSegment
object can contain an arbitrary number of child segments, and the segments can be nested to an arbitrary degree.Note, however, that the precise layout of the segment hierarchy is defined by the particular IDoc type of the document. When creating (or reading) a segment hierarchy, therefore, you must be sure to follow the exact structure as defined by the IDoc type.
The Segment
type is used to access the data records of the IDoc document, where the segments are laid out in accordance with the structure defined by the document’s IDoc type. In outline, the Segment
interface exposes the following methods:
// Java package org.fusesource.camel.component.sap.model.idoc; ... public interface Segment extends EObject, java.util.Map<String, Object> { // Returns the value of the '<em><b>Parent</b></em>' reference. Segment getParent(); // Return an immutable list of all child segments <S extends Segment> EList<S> getChildren(); // Returns a list of child segments of the specified segment type. <S extends Segment> SegmentList<S> getChildren(String segmentType); EList<String> getTypes(); Document getDocument(); String getDescription(); String getType(); String getDefinition(); int getHierarchyLevel(); String getIdocType(); String getIdocTypeExtension(); String getSystemRelease(); String getApplicationRelease(); int getNumFields(); long getMaxOccurrence(); long getMinOccurrence(); boolean isMandatory(); boolean isQualified(); int getRecordLength(); <T> T get(Object key, Class<T> type); }
The getChildren(String segmentType)
method is particularly useful for adding new (nested) children to a segment. It returns an object of type, SegmentList
, which is defined as follows:
// Java package org.fusesource.camel.component.sap.model.idoc; ... public interface SegmentList<S extends Segment> extends EObject, EList<S> { S add(); S add(int index); }
Hence, to create a data record of E1SCU_CRE
type, you could use Java code like the following:
Segment rootSegment = document.getRootSegment(); Segment E1SCU_CRE_Segment = rootSegment.getChildren("E1SCU_CRE").add();
3.87.9. Document attributes
IDoc Document Attributes table shows the control record attributes that you can set on the Document
object.
Attribute | Length | SAP Field | Description |
---|---|---|---|
| 70 |
| EDI archive key |
| 3 |
| Client |
| 8 |
| Date IDoc was created |
| 6 |
| Time IDoc was created |
| 1 |
| Direction |
| 14 |
| Reference to message |
| 14 |
| Reference to message group |
| 6 |
| EDI message type |
| 1 |
| EDI standard |
| 6 |
| Version of EDI standard |
| 14 |
| Reference to interchange file |
| 8 |
| IDoc type |
| 16 |
| IDoc number |
| 4 |
| SAP Release of IDoc |
| 30 |
| Name of basic IDoc type |
| 30 |
| Name of extension type |
| 3 |
| Logical message code |
| 3 |
| Logical message function |
| 30 |
| Logical message type |
| 1 |
| Output mode |
| 10 |
| Receiver address (SADR) |
| 70 |
| Logical address of receiver |
| 2 |
| Partner function of receiver |
| 10 |
| Partner number of receiver |
| 2 |
| Partner type of receiver |
| 10 |
| Receiver port (SAP System, EDI subsystem) |
|
| Sender address (SADR) | |
| 70 |
| Logical address of sender |
| 2 |
| Partner function of sender |
| 10 |
| Partner number of sender |
| 2 |
| Partner type of sender |
| 10 |
| Sender port (SAP System, EDI subsystem) |
| 20 |
| EDI/ALE: Serialization field |
| 2 |
| Status of IDoc |
| 1 |
| Test flag |
3.87.9.1. Setting document attributes in Java
When setting the control record attributes in Java, the usual convention for Java bean properties is followed. That is, a name
attribute can be accessed through the getName
and setName
methods, for getting and setting the attribute value. For example, the iDocType
, iDocTypeExtension
, and messageType
attributes can be set as follows on a Document
object:
// Java document.setIDocType("FLCUSTOMER_CREATEFROMDATA01"); document.setIDocTypeExtension(""); document.setMessageType("FLCUSTOMER_CREATEFROMDATA");
3.87.9.2. Setting document attributes in XML
When setting the control record attributes in XML, the attributes must be set on the idoc:Document
element. For example, the iDocType
, iDocTypeExtension
, and messageType
attributes can be set as follows:
<?xml version="1.0" encoding="ASCII"?> <idoc:Document ... iDocType="FLCUSTOMER_CREATEFROMDATA01" iDocTypeExtension="" messageType="FLCUSTOMER_CREATEFROMDATA" ... > ... </idoc:Document>
3.87.10. Transaction Support
3.87.10.1. BAPI transaction model
The SAP Component supports the BAPI transaction model for outbound communication with SAP. A destination endpoint with a URL containing the transacted option set to true
will, if necessary, initiate a stateful session on the outbound connection of the endpoint and register a Camel Synchronization object with the exchange. This synchronization object will call the BAPI service method BAPI_TRANSACTION_COMMIT
and end the stateful session when the processing of the message exchange is complete. If the processing of the message exchange fails, the synchronization object will call the BAPI server method BAPI_TRANSACTION_ROLLBACK
and end the stateful session.
3.87.10.2. RFC transaction model
The tRFC protocol accomplishes an AT-MOST-ONCE delivery and processing guarantee by identifying each transactional request with a unique transaction identifier (TID). A TID accompanies each request sent in the protocol. A sending application using the tRFC protocol must identify each instance of a request with a unique TID when sending the request. An application may send a request with a given TID multiple times, but the protocol ensures that the request is delivered and processed in the receiving system at most once. An application may choose to resend a request with a given TID when encountering a communication or system error when sending the request, and is thus in doubt whether that request was delivered and processed in the receiving system. By resending a request when encountering a communication error, a client application using the tRFC protocol can thus ensure EXACTLY-ONCE delivery and processing guarantees for its request.
3.87.10.3. Which transaction model to use?
A BAPI transaction is an application level transaction, in the sense that it imposes ACID guarantees on the persistent data changes performed by a BAPI method or RFC function in the SAP database. An RFC transaction is a communication transaction, in the sense that it imposes delivery guarantees (AT-MOST-ONCE, EXACTLY-ONCE, EXACTLY-ONCE-IN-ORDER) on requests to a BAPI method and/or RFC function.
3.87.10.4. Transactional RFC destination endpoints
The following destination endpoints support RFC transactions:
-
sap-trfc-destination
-
sap-qrfc-destination
A single Camel route can include multiple transactional RFC destination endpoints, sending messages to multiple RFC destinations and even sending messages to the same RFC destination multiple times. This implies that the Camel SAP component potentially needs to keep track of many transaction IDs (TIDs) for each Exchange
object passing along a route. Now if the route processing fails and must be retried, the situation gets quite complicated. The RFC transaction semantics demand that each RFC destination along the route must be invoked using the same TID that was used the first time around (and where the TIDs for each destination are distinct from each other). In other words, the Camel SAP component must keep track of which TID was used at which point along the route, and remember this information, so that the TIDs can be replayed in the correct order.
By default, Camel does not provide a mechanism that enables an Exchange
to know where it is in a route. To provide such a mechanism, it is necessary to install the CurrentProcessorDefinitionInterceptStrategy
interceptor into the Camel runtime. This interceptor must be installed into the Camel runtime, in order for the Camel SAP component to keep track of the TIDs in a route.
3.87.10.5. Transactional RFC server endpoints
The following server endpoints support RFC transactions:
-
sap-trfc-server
When a Camel exchange processing a transactional request encounters a processing error, Camel handles the processing error through its standard error handling mechanisms. If the Camel route processing the exchange is configured to propagate the error back to the caller, the SAP server endpoint that initiated the exchange takes note of the failure and the sending SAP system is notified of the error. The sending SAP system can then respond by sending another transaction request with the same TID to process the request again.
3.87.11. XML Serialization for RFC
SAP request and response objects support an XML serialization format which enable these objects to be serialized to and from an XML document.
3.87.11.1. XML namespace
Each RFC in a repository defines a specific XML namespace for the elements which compose the serialized forms of its Request and Response objects. The form of this namespace URL is as follows:
http://sap.fusesource.org/rfc>/<Repository Name>/<RFC Name>
RFC namespace URLs have a common http://sap.fusesource.org/rfc
prefix followed by the name of the repository in which the RFC’s metadata is defined. The final component in the URL is the name of the RFC itself.
3.87.11.2. Request and response XML documents
An SAP request object will be serialized into an XML document with the root element of that document named Request and scoped by the namespace of the request’s RFC.
<?xml version="1.0" encoding="ASCII"?> <BOOK_FLIGHT:Request xmlns:BOOK_FLIGHT="http://sap.fusesource.org/rfc/nplServer/BOOK_FLIGHT"> ... </BOOK_FLIGHT:Request>
An SAP response object will be serialized into an XML document with the root element of that document named Response and scoped by the namespace of the response’s RFC.
<?xml version="1.0" encoding="ASCII"?> <BOOK_FLIGHT:Response xmlns:BOOK_FLIGHT="http://sap.fusesource.org/rfc/nplServer/BOOK_FLIGHT"> ... </BOOK_FLIGHT:Response>
3.87.11.3. Structure fields
Structure fields in parameter lists or nested structures are serialized as elements. The element name of the serialized structure corresponds to the field name of the structure within the enclosing parameter list, structure or table row entry it resides.
<BOOK_FLIGHT:FLTINFO xmlns:BOOK_FLIGHT="http://sap.fusesource.org/rfc/nplServer/BOOK_FLIGHT"> ... </BOOK_FLIGHT:FLTINFO>
Note that the type name of the structure element in the RFC namespace will correspond to the name of the record metadata object which defines the structure, as in the following example:
<xs:schema targetNamespace="http://sap.fusesource.org/rfc/nplServer/BOOK_FLIGHT"> xmlns:xs="http://www.w3.org/2001/XMLSchema"> ... <xs:complexType name="FLTINFO_STRUCTURE”> ... </xs:complexType> ... </xs:schema>
This distinction will be important when specifying a JAXB bean to marshal and unmarshal the structure.
3.87.11.4. Table fields
Table fields in parameter lists or nested structures are serialized as elements. The element name of the serialized structure will correspond to the field name of the table within the enclosing parameter list, structure, or table row entry it resides. The table element will contain a series of row elements to hold the serialized values of the table’s row entries.
<BOOK_FLIGHT:CONNINFO xmlns:BOOK_FLIGHT="http://sap.fusesource.org/rfc/nplServer/BOOK_FLIGHT"> <row ... > ... </row> ... <row ... > ... </row> </BOOK_FLIGHT:CONNINFO>
Note that the type name of the table element in the RFC namespace corresponds to the name of the record metadata object which defines the row structure of the table suffixed by _TABLE
. The type name of the table row element in the RFC name corresponds to the name of the record metadata object which defines the row structure of the table, as in the following example:
<xs:schema targetNamespace="http://sap.fusesource.org/rfc/nplServer/BOOK_FLIGHT" xmlns:xs="http://www.w3.org/2001/XMLSchema"> ... <xs:complextType name="CONNECTION_INFO_STRUCTURE_TABLE”> <xs:sequence> <xs:element name="row” minOccures="0” maxOccurs="unbounded” type="CONNECTION_INFO_STRUCTURE”/> ... <xs:sequence> </xs:sequence> </xs:complexType> <xs:complextType name="CONNECTION_INFO_STRUCTURE”> ... </xs:complexType> ... </xs:schema>
This distinction will be important when specifying a JAXB bean to marshal and unmarshal the structure.
3.87.11.5. Elementary fields
Elementary fields in parameter lists or nested structures are serialized as attributes on the element of the enclosing parameter list or structure. The attribute name of the serialized field corresponds to the field name of the field within the enclosing parameter list, structure, or table row entry it resides, as in the following example:
<?xml version="1.0" encoding="ASCII"?> <BOOK_FLIGHT:Request xmlns:BOOK_FLIGHT="http://sap.fusesource.org/rfc/nplServer/BOOK_FLIGHT" CUSTNAME="James Legrand" PASSFORM="Mr" PASSNAME="Travelin Joe" PASSBIRTH="1990-03-17T00:00:00.000-0500" FLIGHTDATE="2014-03-19T00:00:00.000-0400" TRAVELAGENCYNUMBER="00000110" DESTINATION_FROM="SFO" DESTINATION_TO="FRA"/>
3.87.11.6. Date and time formats
Date and Time fields are serialized into attribute values using the following format:
yyyy-MM-dd'T'HH:mm:ss.SSSZ
Date fields will be serialized with only the year, month, day and timezone components set:
DEPDATE="2014-03-19T00:00:00.000-0400"
Time fields will be serialized with only the hour, minute, second, millisecond and timezone components set:
DEPTIME="1970-01-01T16:00:00.000-0500"
3.87.12. XML Serialization for IDoc
An IDoc message body can be serialized into an XML string format, with the help of a built-in type converter.
3.87.12.1. XML namespace
Each serialized IDoc is associated with an XML namespace, which has the following general format:
http://sap.fusesource.org/idoc/repositoryName/idocType/idocTypeExtension/systemRelease/applicationRelease
Both the repositoryName (name of the remote SAP metadata repository) and the idocType (IDoc document type) are mandatory, but the other components of the namespace can be left blank. For example, you could have an XML namespace like the following:
http://sap.fusesource.org/idoc/MY_REPO/FLCUSTOMER_CREATEFROMDATA01///
3.87.12.2. Built-in type converter
The Camel SAP component has a built-in type converter, which is capable of converting a Document
object or a DocumentList
object to and from a String
type.
For example, to serialize a Document
object to an XML string, you can simply add the following line to a route in XML DSL:
<convertBodyTo type="java.lang.String">;
You can also use this approach to a serialized XML message into a Document
object. For example, given that the current message body is a serialized XML string, you can convert it back into a Document
object by adding the following line to a route in XML DSL:
<convertBodyTo type="org.fusesource.camel.component.sap.model.idoc.Document">
3.87.12.3. Sample IDoc message body in XML format
When you convert an IDoc message to a String
, it is serialized into an XML document, where the root element is either idoc:Document
(for a single document) or idoc:DocumentList
(for a list of documents). It shows that a single IDoc document that has been serialized to an idoc:Document
element.
Example 3.2. IDoc Message Body in XML
<?xml version="1.0" encoding="ASCII"?> <idoc:Document xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:FLCUSTOMER_CREATEFROMDATA01---="http://sap.fusesource.org/idoc/XXX/FLCUSTOMER_CREATEFROMDATA01///" xmlns:idoc="http://sap.fusesource.org/idoc" creationDate="2015-01-28T12:39:13.980-0500" creationTime="2015-01-28T12:39:13.980-0500" iDocType="FLCUSTOMER_CREATEFROMDATA01" iDocTypeExtension="" messageType="FLCUSTOMER_CREATEFROMDATA" recipientPartnerNumber="QUICKCLNT" recipientPartnerType="LS" senderPartnerNumber="QUICKSTART" senderPartnerType="LS"> <rootSegment xsi:type="FLCUSTOMER_CREATEFROMDATA01---:ROOT" document="/"> <segmentChildren parent="//@rootSegment"> <E1SCU_CRE parent="//@rootSegment" document="/"> <segmentChildren parent="//@rootSegment/@segmentChildren/@E1SCU_CRE.0"> <E1BPSCUNEW parent="//@rootSegment/@segmentChildren/@E1SCU_CRE.0" document="/" CUSTNAME="Fred Flintstone" FORM="Mr." STREET="123 Rubble Lane" POSTCODE="01234" CITY="Bedrock" COUNTR="US" PHONE="800-555-1212" EMAIL="fred@bedrock.com" CUSTTYPE="P" DISCOUNT="005" LANGU="E"/> </segmentChildren> </E1SCU_CRE> </segmentChildren> </rootSegment> </idoc:Document>
3.87.13. Example 1: Reading Data from SAP
This example demonstrates a route that reads FlightCustomer
business object data from SAP. The route invokes the FlightCustomer
BAPI method, BAPI_FLCUST_GETLIST
, using an SAP synchronous RFC destination endpoint to retrieve the data.
3.87.13.1. Java DSL for route
The Java DSL for the example route is as follows:
from("direct:getFlightCustomerInfo") .to("bean:createFlightCustomerGetListRequest") .to("sap-srfc-destination:nplDest:BAPI_FLCUST_GETLIST") .to("bean:returnFlightCustomerInfo");
3.87.13.2. XML DSL for route
And the Spring DSL for the same route is as follows:
<route> <from uri="direct:getFlightCustomerInfo"/> <to uri="bean:createFlightCustomerGetListRequest"/> <to uri="sap-srfc-destination:nplDest:BAPI_FLCUST_GETLIST"/> <to uri="bean:returnFlightCustomerInfo"/> </route>
3.87.13.3. createFlightCustomerGetListRequest
bean
The createFlightCustomerGetListRequest
bean is responsible for building an SAP request object in its exchange method that is used in the RFC call of the subsequent SAP endpoint. The following code snippet demonstrates the sequence of operations to build the request object:
public void create(Exchange exchange) throws Exception { // Get SAP Endpoint to be called from context. SapSynchronousRfcDestinationEndpoint endpoint = exchange.getContext().getEndpoint("sap-srfc-destination:nplDest:BAPI_FLCUST_GETLIST", SapSynchronousRfcDestinationEndpoint.class); // Retrieve bean from message containing Flight Customer name to // look up. BookFlightRequest bookFlightRequest = exchange.getIn().getBody(BookFlightRequest.class); // Create SAP Request object from target endpoint. Structure request = endpoint.getRequest(); // Add Customer Name to request if set if (bookFlightRequest.getCustomerName() != null && bookFlightRequest.getCustomerName().length() > 0) { request.put("CUSTOMER_NAME", bookFlightRequest.getCustomerName()); } } else { throw new Exception("No Customer Name"); } // Put request object into body of exchange message. exchange.getIn().setBody(request); }
3.87.13.4. returnFlightCustomerInfo
bean
The returnFlightCustomerInfo
bean is responsible for extracting data from the SAP response object in its exchange method that it receives from the previous SAP endpoint. The following code snippet demonstrates the sequence of operations to extract the data from the response object:
public void createFlightCustomerInfo(Exchange exchange) throws Exception { // Retrieve SAP response object from body of exchange message. Structure flightCustomerGetListResponse = exchange.getIn().getBody(Structure.class); if (flightCustomerGetListResponse == null) { throw new Exception("No Flight Customer Get List Response"); } // Check BAPI return parameter for errors @SuppressWarnings("unchecked") Table<Structure> bapiReturn = flightCustomerGetListResponse.get("RETURN", Table.class); Structure bapiReturnEntry = bapiReturn.get(0); if (bapiReturnEntry.get("TYPE", String.class) != "S") { String message = bapiReturnEntry.get("MESSAGE", String.class); throw new Exception("BAPI call failed: " + message); } // Get customer list table from response object. @SuppressWarnings("unchecked") Table<? extends Structure> customerList = flightCustomerGetListResponse.get("CUSTOMER_LIST", Table.class); if (customerList == null || customerList.size() == 0) { throw new Exception("No Customer Info."); } // Get Flight Customer data from first row of table. Structure customer = customerList.get(0); // Create bean to hold Flight Customer data. FlightCustomerInfo flightCustomerInfo = new FlightCustomerInfo(); // Get customer id from Flight Customer data and add to bean. String customerId = customer.get("CUSTOMERID", String.class); if (customerId != null) { flightCustomerInfo.setCustomerNumber(customerId); } ... // Put bean into body of exchange message. exchange.getIn().setHeader("flightCustomerInfo", flightCustomerInfo); }
3.87.14. Example 2: Writing Data to SAP
This example demonstrates a route that creates a FlightTrip
business object instance in SAP. The route invokes the FlightTrip
BAPI method, BAPI_FLTRIP_CREATE
, using a destination endpoint to create the object.
3.87.14.1. Java DSL for route
The Java DSL for the example route is as follows:
from("direct:createFlightTrip") .to("bean:createFlightTripRequest") .to("sap-srfc-destination:nplDest:BAPI_FLTRIP_CREATE?transacted=true") .to("bean:returnFlightTripResponse");
3.87.14.2. XML DSL for route
And the Spring DSL for the same route is as follows:
<route> <from uri="direct:createFlightTrip"/> <to uri="bean:createFlightTripRequest"/> <to uri="sap-srfc-destination:nplDest:BAPI_FLTRIP_CREATE?transacted=true"/> <to uri="bean:returnFlightTripResponse"/> </route>
3.87.14.3. Transaction support
Note that the URL for the SAP endpoint has the transacted
option set to true
. When this option is enabled, the endpoint ensures that an SAP transaction session has been initiated before invoking the RFC call. Because this endpoint’s RFC creates new data in SAP, this option is necessary to make the route’s changes permanent in SAP.
3.87.14.4. Populating request parameters
The createFlightTripRequest
and returnFlightTripResponse
beans are responsible for populating request parameters into the SAP request and extracting response parameters from the SAP response respectively, following the same sequence of operations as demonstrated in the previous example.
3.87.15. Example 3: Handling Requests from SAP
This example demonstrates a route which handles a request from SAP to the BOOK_FLIGHT
RFC, which is implemented by the route. In addition, it demonstrates the component’s XML serialization support, using JAXB to unmarshal and marshal SAP request objects and response objects to custom beans.
This route creates a FlightTrip
business object on behalf of a travel agent, FlightCustomer
. The route first unmarshals the SAP request object received by the SAP server endpoint into a custom JAXB bean. This custom bean is then multicasted in the exchange to three sub-routes, which gather the travel agent, flight connection, and passenger information required to create the flight trip. The final sub-route creates the flight trip object in SAP, as demonstrated in the previous example. The final sub-route also creates and returns a custom JAXB bean which is marshaled into an SAP response object and returned by the server endpoint.
3.87.15.1. Java DSL for route
The Java DSL for the example route is as follows:
DataFormat jaxb = new JaxbDataFormat("org.fusesource.sap.example.jaxb"); from("sap-srfc-server:nplserver:BOOK_FLIGHT") .unmarshal(jaxb) .multicast() .to("direct:getFlightConnectionInfo", "direct:getFlightCustomerInfo", "direct:getPassengerInfo") .end() .to("direct:createFlightTrip") .marshal(jaxb);
3.87.15.2. XML DSL for route
And the XML DSL for the same route is as follows:
<route> <from uri="sap-srfc-server:nplserver:BOOK_FLIGHT"/> <unmarshal> <jaxb contextPath="org.fusesource.sap.example.jaxb"/> </unmarshal> <multicast> <to uri="direct:getFlightConnectionInfo"/> <to uri="direct:getFlightCustomerInfo"/> <to uri="direct:getPassengerInfo"/> </multicast> <to uri="direct:createFlightTrip"/> <marshal> <jaxb contextPath="org.fusesource.sap.example.jaxb"/> </marshal> </route>
3.87.15.3. BookFlightRequest bean
The following listing illustrates a JAXB bean which unmarshals from the serialized form of an SAP BOOK_FLIGHT
request object:
@XmlRootElement(name="Request", namespace="http://sap.fusesource.org/rfc/nplServer/BOOK_FLIGHT") @XmlAccessorType(XmlAccessType.FIELD) public class BookFlightRequest { @XmlAttribute(name="CUSTNAME") private String customerName; @XmlAttribute(name="FLIGHTDATE") @XmlJavaTypeAdapter(DateAdapter.class) private Date flightDate; @XmlAttribute(name="TRAVELAGENCYNUMBER") private String travelAgencyNumber; @XmlAttribute(name="DESTINATION_FROM") private String startAirportCode; @XmlAttribute(name="DESTINATION_TO") private String endAirportCode; @XmlAttribute(name="PASSFORM") private String passengerFormOfAddress; @XmlAttribute(name="PASSNAME") private String passengerName; @XmlAttribute(name="PASSBIRTH") @XmlJavaTypeAdapter(DateAdapter.class) private Date passengerDateOfBirth; @XmlAttribute(name="CLASS") private String flightClass; ... }
3.87.15.4. BookFlightResponse bean
The following listing illustrates a JAXB bean which marshals to the serialized form of an SAP BOOK_FLIGHT
response object:
@XmlRootElement(name="Response", namespace="http://sap.fusesource.org/rfc/nplServer/BOOK_FLIGHT") @XmlAccessorType(XmlAccessType.FIELD) public class BookFlightResponse { @XmlAttribute(name="TRIPNUMBER") private String tripNumber; @XmlAttribute(name="TICKET_PRICE") private BigDecimal ticketPrice; @XmlAttribute(name="TICKET_TAX") private BigDecimal ticketTax; @XmlAttribute(name="CURRENCY") private String currency; @XmlAttribute(name="PASSFORM") private String passengerFormOfAddress; @XmlAttribute(name="PASSNAME") private String passengerName; @XmlAttribute(name="PASSBIRTH") @XmlJavaTypeAdapter(DateAdapter.class) private Date passengerDateOfBirth; @XmlElement(name="FLTINFO") private FlightInfo flightInfo; @XmlElement(name="CONNINFO") private ConnectionInfoTable connectionInfo; ... }
The complex parameter fields of the response object are serialized as child elements of the response.
3.87.15.5. FlightInfo bean
The following listing illustrates a JAXB bean which marshals to the serialized form of the complex structure parameter FLTINFO
:
@XmlRootElement(name="FLTINFO", namespace="http://sap.fusesource.org/rfc/nplServer/BOOK_FLIGHT") @XmlAccessorType(XmlAccessType.FIELD) public class FlightInfo { @XmlAttribute(name="FLIGHTTIME") private String flightTime; @XmlAttribute(name="CITYFROM") private String cityFrom; @XmlAttribute(name="DEPDATE") @XmlJavaTypeAdapter(DateAdapter.class) private Date departureDate; @XmlAttribute(name="DEPTIME") @XmlJavaTypeAdapter(DateAdapter.class) private Date departureTime; @XmlAttribute(name="CITYTO") private String cityTo; @XmlAttribute(name="ARRDATE") @XmlJavaTypeAdapter(DateAdapter.class) private Date arrivalDate; @XmlAttribute(name="ARRTIME") @XmlJavaTypeAdapter(DateAdapter.class) private Date arrivalTime; ... }
3.87.15.6. ConnectionInfoTable bean
The following listing illustrates a JAXB bean which marshals to the serialized form of the complex table parameter, CONNINFO
. Note that the name of the root element type of the JAXB bean corresponds to the name of the row structure type suffixed with _TABLE
and the bean contains a list of row elements.
@XmlRootElement(name="CONNINFO_TABLE", namespace="http://sap.fusesource.org/rfc/nplServer/BOOK_FLIGHT") @XmlAccessorType(XmlAccessType.FIELD) public class ConnectionInfoTable { @XmlElement(name="row") List<ConnectionInfo> rows; ... }
3.87.15.7. ConnectionInfo
bean
The following listing illustrates a JAXB bean, which marshals to the serialized form of the above tables row elements:
@XmlRootElement(name="CONNINFO", namespace="http://sap.fusesource.org/rfc/nplServer/BOOK_FLIGHT") @XmlAccessorType(XmlAccessType.FIELD) public class ConnectionInfo { @XmlAttribute(name="CONNID") String connectionId; @XmlAttribute(name="AIRLINE") String airline; @XmlAttribute(name="PLANETYPE") String planeType; @XmlAttribute(name="CITYFROM") String cityFrom; @XmlAttribute(name="DEPDATE") @XmlJavaTypeAdapter(DateAdapter.class) Date departureDate; @XmlAttribute(name="DEPTIME") @XmlJavaTypeAdapter(DateAdapter.class) Date departureTime; @XmlAttribute(name="CITYTO") String cityTo; @XmlAttribute(name="ARRDATE") @XmlJavaTypeAdapter(DateAdapter.class) Date arrivalDate; @XmlAttribute(name="ARRTIME") @XmlJavaTypeAdapter(DateAdapter.class) Date arrivalTime; ... }
3.88. XQuery
Query and/or transform XML payloads using XQuery and Saxon.
3.88.1. What’s inside
-
XQuery component, URI syntax:
xquery:resourceUri
- XQuery language
Refer to the above links for usage and configuration details.
3.88.2. Maven coordinates
Create a new project with this extension on code.quarkus.redhat.com
Or add the coordinates to your existing project:
<dependency> <groupId>org.apache.camel.quarkus</groupId> <artifactId>camel-quarkus-saxon</artifactId> </dependency>
3.88.3. Additional Camel Quarkus configuration
This component is able to load XQuery definitions from classpath. To make it work also in native mode, you need to explicitly embed the queries in the native executable by using the quarkus.native.resources.includes
property.
For instance, the two routes below load an XQuery script from two classpath resources named myxquery.txt
and another-xquery.txt
respectively:
from("direct:start").transform().xquery("resource:classpath:myxquery.txt", String.class); from("direct:start").to("xquery:another-xquery.txt");
To include these (an possibly other queries stored in .txt
files) in the native image, you would have to add something like the following to your application.properties
file:
quarkus.native.resources.includes = *.txt
3.89. Scheduler
Generate messages in specified intervals using java.util.concurrent.ScheduledExecutorService.
3.89.1. What’s inside
-
Scheduler component, URI syntax:
scheduler:name
Refer to the above link for usage and configuration details.
3.89.2. Maven coordinates
Create a new project with this extension on code.quarkus.redhat.com
Or add the coordinates to your existing project:
<dependency> <groupId>org.apache.camel.quarkus</groupId> <artifactId>camel-quarkus-scheduler</artifactId> </dependency>
3.90. SEDA
Asynchronously call another endpoint from any Camel Context in the same JVM.
3.90.1. What’s inside
-
SEDA component, URI syntax:
seda:name
Refer to the above link for usage and configuration details.
3.90.2. Maven coordinates
Create a new project with this extension on code.quarkus.redhat.com
Or add the coordinates to your existing project:
<dependency> <groupId>org.apache.camel.quarkus</groupId> <artifactId>camel-quarkus-seda</artifactId> </dependency>
3.91. Servlet
Serve HTTP requests by a Servlet.
3.91.1. What’s inside
-
Servlet component, URI syntax:
servlet:contextPath
Refer to the above link for usage and configuration details.
3.91.2. Maven coordinates
Create a new project with this extension on code.quarkus.redhat.com
Or add the coordinates to your existing project:
<dependency> <groupId>org.apache.camel.quarkus</groupId> <artifactId>camel-quarkus-servlet</artifactId> </dependency>
3.91.3. transferException option in native mode
To use the transferException
option in native mode, you must enable support for object serialization. Refer to the native mode user guide for more information.
You will also need to enable serialization for the exception classes that you intend to serialize. For example.
@RegisterForReflection(targets = { IllegalStateException.class, MyCustomException.class }, serialization = true)
3.91.4. Additional Camel Quarkus configuration
Configuration property | Type | Default |
---|---|---|
A comma separated list of path patterns under which the CamelServlet should be accessible. Example path patterns: |
| |
A fully qualified name of a servlet class to serve paths that match |
|
|
A servletName as it would be defined in a |
|
|
A comma separated list of path patterns under which the CamelServlet should be accessible. Example path patterns: |
| |
A fully qualified name of a servlet class to serve paths that match |
|
|
A servletName as it would be defined in a |
|
|
Configuration property fixed at build time. All other configuration properties are overridable at runtime.
3.92. Slack
Send and receive messages to/from Slack.
3.92.1. What’s inside
-
Slack component, URI syntax:
slack:channel
Refer to the above link for usage and configuration details.
3.92.2. Maven coordinates
Create a new project with this extension on code.quarkus.redhat.com
Or add the coordinates to your existing project:
<dependency> <groupId>org.apache.camel.quarkus</groupId> <artifactId>camel-quarkus-slack</artifactId> </dependency>
3.92.3. SSL in native mode
This extension auto-enables SSL support in native mode. Hence you do not need to add quarkus.ssl.native=true
to your application.properties
yourself. See also Quarkus SSL guide.
3.93. SNMP
Receive traps and poll SNMP (Simple Network Management Protocol) capable devices.
3.93.1. What’s inside
-
SNMP component, URI syntax:
snmp:host:port
Refer to the above link for usage and configuration details.
3.93.2. Maven coordinates
<dependency> <groupId>org.apache.camel.quarkus</groupId> <artifactId>camel-quarkus-snmp</artifactId> </dependency>
3.94. SOAP dataformat
Marshal Java objects to SOAP messages and back.
3.94.1. What’s inside
Refer to the above link for usage and configuration details.
3.94.2. Maven coordinates
Create a new project with this extension on code.quarkus.redhat.com
Or add the coordinates to your existing project:
<dependency> <groupId>org.apache.camel.quarkus</groupId> <artifactId>camel-quarkus-soap</artifactId> </dependency>
3.95. Splunk
Publish or search for events in Splunk.
3.95.1. What’s inside
-
Splunk component, URI syntax:
splunk:name
Refer to the above link for usage and configuration details.
3.95.2. Maven coordinates
Create a new project with this extension on code.quarkus.redhat.com
Or add the coordinates to your existing project:
<dependency> <groupId>org.apache.camel.quarkus</groupId> <artifactId>camel-quarkus-splunk</artifactId> </dependency>
3.95.3. SSL in native mode
This extension auto-enables SSL support in native mode. Hence you do not need to add quarkus.ssl.native=true
to your application.properties
yourself. See also Quarkus SSL guide.
3.96. Splunk HEC
The splunk component allows to publish events in Splunk using the HTTP Event Collector.
3.96.1. What’s inside
-
Splunk HEC component, URI syntax:
splunk-hec:splunkURL/token
Refer to the above link for usage and configuration details.
3.96.2. Maven coordinates
<dependency> <groupId>org.apache.camel.quarkus</groupId> <artifactId>camel-quarkus-splunk-hec</artifactId> </dependency>
3.97. SQL
Perform SQL queries.
3.97.1. What’s inside
-
SQL component, URI syntax:
sql:query
-
SQL Stored Procedure component, URI syntax:
sql-stored:template
Refer to the above links for usage and configuration details.
3.97.2. Maven coordinates
Create a new project with this extension on code.quarkus.redhat.com
Or add the coordinates to your existing project:
<dependency> <groupId>org.apache.camel.quarkus</groupId> <artifactId>camel-quarkus-sql</artifactId> </dependency>
3.97.3. Additional Camel Quarkus configuration
3.97.3.1. Configuring a DataSource
This extension leverages Quarkus Agroal for DataSource
support. Setting up a DataSource
can be achieved via configuration properties.
quarkus.datasource.db-kind=postgresql quarkus.datasource.username=your-username quarkus.datasource.password=your-password quarkus.datasource.jdbc.url=jdbc:postgresql://localhost:5432/your-database quarkus.datasource.jdbc.max-size=16
The Camel SQL component will automatically resolve the DataSource
bean from the registry. When configuring multiple datasources, you can specify which one is to be used on an SQL endpoint via the URI options datasource
or dataSourceRef
. Refer to the SQL component documentation for more details.
3.97.3.1.1. Zero configuration with Quarkus Dev Services
In dev and test mode you can take advantage of Configuration Free Databases. The Camel SQL component will be automatically configured to use a DataSource
that points to a local containerized instance of the database matching the JDBC driver type that you have selected.
3.97.3.2. SQL scripts
When configuring sql
or sql-stored
endpoints to reference script files from the classpath, set the following configuration property to ensure that they are available in native mode.
quarkus.native.resources.includes = queries.sql, sql/*.sql
3.97.3.3. SQL aggregation repository in native mode
In order to use SQL aggregation repositories like JdbcAggregationRepository
in native mode, you must enable native serialization support.
In addition, if your exchange bodies are custom types, they must be registered for serialization by annotating their class declaration with @RegisterForReflection(serialization = true)
.
3.98. Telegram
Send and receive messages acting as a Telegram Bot Telegram Bot API.
3.98.1. What’s inside
-
Telegram component, URI syntax:
telegram:type
Refer to the above link for usage and configuration details.
3.98.2. Maven coordinates
Create a new project with this extension on code.quarkus.redhat.com
Or add the coordinates to your existing project:
<dependency> <groupId>org.apache.camel.quarkus</groupId> <artifactId>camel-quarkus-telegram</artifactId> </dependency>
3.98.3. Usage
3.98.4. Webhook Mode
The Telegram extension supports usage in the webhook mode.
In order to enable webhook mode, you must add a REST implementation to your application. Maven users, for example, can add the camel-quarkus-rest extension to their pom.xml
file:
<dependency> <groupId>org.apache.camel.quarkus</groupId> <artifactId>camel-quarkus-rest</artifactId> </dependency>
3.98.4.1. Webhook
In this release of Red Hat build of Apache Camel for Quarkus, webhook mode is not supported.
3.98.5. SSL in native mode
This extension auto-enables SSL support in native mode. Hence you do not need to add quarkus.ssl.native=true
to your application.properties
yourself. See also Quarkus SSL guide.
3.99. Timer
Generate messages in specified intervals using java.util.Timer.
3.99.1. What’s inside
-
Timer component, URI syntax:
timer:timerName
Refer to the above link for usage and configuration details.
3.99.2. Maven coordinates
Create a new project with this extension on code.quarkus.redhat.com
Or add the coordinates to your existing project:
<dependency> <groupId>org.apache.camel.quarkus</groupId> <artifactId>camel-quarkus-timer</artifactId> </dependency>
3.100. Validator
Validate the payload using XML Schema and JAXP Validation.
3.100.1. What’s inside
-
Validator component, URI syntax:
validator:resourceUri
Refer to the above link for usage and configuration details.
3.100.2. Maven coordinates
Create a new project with this extension on code.quarkus.redhat.com
Or add the coordinates to your existing project:
<dependency> <groupId>org.apache.camel.quarkus</groupId> <artifactId>camel-quarkus-validator</artifactId> </dependency>
3.101. Velocity
Transform messages using a Velocity template.
3.101.1. What’s inside
-
Velocity component, URI syntax:
velocity:resourceUri
Refer to the above link for usage and configuration details.
3.101.2. Maven coordinates
Create a new project with this extension on code.quarkus.redhat.com
Or add the coordinates to your existing project:
<dependency> <groupId>org.apache.camel.quarkus</groupId> <artifactId>camel-quarkus-velocity</artifactId> </dependency>
3.101.3. Usage
3.101.3.1. Custom body as domain object in the native mode
When using a custom object as message body and referencing its properties in the template in the native mode, all the classes need to be registered for reflection (see the documentation).
Example:
@RegisterForReflection public interface CustomBody { }
3.101.4. allowContextMapAll option in native mode
The allowContextMapAll
option is not supported in native mode as it requires reflective access to security sensitive camel core classes such as CamelContext
& Exchange
. This is considered a security risk and thus access to the feature is not provided by default.
3.101.5. Additional Camel Quarkus configuration
This component typically loads Velocity templates from classpath. To make it work also in native mode, you need to explicitly embed the templates in the native executable by using the quarkus.native.resources.includes
property.
For instance, the route below would load the Velocity template from a classpath resource named template/simple.vm
:
from("direct:start").to("velocity://template/simple.vm");
To include this (an possibly other templates stored in .vm
files in the template
directory) in the native image, you would have to add something like the following to your application.properties
file:
quarkus.native.resources.includes = template/*.vm
3.102. Vert.x HTTP Client
Camel HTTP client support with Vert.x
3.102.1. What’s inside
-
Vert.x HTTP Client component, URI syntax:
vertx-http:httpUri
Refer to the above link for usage and configuration details.
3.102.2. Maven coordinates
Create a new project with this extension on code.quarkus.redhat.com
Or add the coordinates to your existing project:
<dependency> <groupId>org.apache.camel.quarkus</groupId> <artifactId>camel-quarkus-vertx-http</artifactId> </dependency>
3.102.3. transferException option in native mode
To use the transferException
option in native mode, you must enable support for object serialization. Refer to the native mode user guide for more information.
You will also need to enable serialization for the exception classes that you intend to serialize. For example.
@RegisterForReflection(targets = { IllegalStateException.class, MyCustomException.class }, serialization = true)
3.102.4. Additional Camel Quarkus configuration
3.102.5. allowJavaSerializedObject option in native mode
When using the allowJavaSerializedObject
option in native mode, the support of serialization might need to be enabled. Please, refer to the native mode user guide for more information.
3.102.5.1. Character encodings
Check the Character encodings section of the Native mode guide if the application is expected to send and receive requests using non-default encodings.
3.103. Vert.x WebSocket
This extension enables you to create WebSocket endpoints to that act as either a WebSocket server, or as a client to connect an existing WebSocket .
It is built on top of the Eclipse Vert.x HTTP server provided by the quarkus-vertx-http
extension.
3.103.1. What’s inside
-
Vert.x WebSocket component, URI syntax:
vertx-websocket:host:port/path
Refer to the above link for usage and configuration details.
3.103.2. Maven coordinates
Create a new project with this extension on code.quarkus.redhat.com
Or add the coordinates to your existing project:
<dependency> <groupId>org.apache.camel.quarkus</groupId> <artifactId>camel-quarkus-vertx-websocket</artifactId> </dependency>
3.103.3. Usage
3.103.3.1. Vert.x WebSocket consumers
When you create a Vert.x WebSocket consumer (E.g with from("vertx-websocket")
), the host and port configuration in the URI are redundant since the WebSocket will always be hosted on the Quarkus HTTP server.
The configuration of the consumer can be simplified to only include the resource path of the WebSocket. For example.
from("vertx-websocket:/my-websocket-path") .setBody().constant("Hello World");
While you do not need to explicitly configure the host/port on the vertx-websocket consumer. If you choose to, the host & port must exactly match the value of the Quarkus HTTP server configuration values for quarkus.http.host
and quarkus.http.port
. Otherwise an exception will be thrown at runtime.
3.103.3.2. Vert.x WebSocket producers
Similar to above, if you want to produce messages to the internal Vert.x WebSocket consumer, then you can omit the host and port from the endpoint URI.
from("vertx-websocket:/my-websocket-path") .log("Got body: ${body}"); from("direct:sendToWebSocket") .log("vertx-websocket:/my-websocket-path");
Or alternatively, you can refer to the full host & port configuration for the Quarkus HTTP server.
from("direct:sendToWebSocket") .log("vertx-websocket:{{quarkus.http.host}}:{{quarkus.http.port}}/my-websocket-path");
When producing messages to an external WebSocket server, then you must always provide the host name and port (if required).
3.103.4. Additional Camel Quarkus configuration
3.103.4.1. Vert.x WebSocket server configuration
Configuration of the Vert.x WebSocket server is managed by Quarkus. Refer to the Quarkus HTTP configuration guide for the full list of configuration options.
To configure SSL for the Vert.x WebSocket server, follow the secure connections with SSL guide. Note that configuring the server for SSL with SSLContextParameters
is not currently supported.
3.103.4.2. Character encodings
Check the Character encodings section of the Native mode guide if you expect your application to send or receive requests using non-default encodings.
3.104. XJ
Transform JSON and XML message using a XSLT.
3.104.1. What’s inside
-
XJ component, URI syntax:
xj:resourceUri
Refer to the above link for usage and configuration details.
3.104.2. Maven coordinates
Create a new project with this extension on code.quarkus.redhat.com
Or add the coordinates to your existing project:
<dependency> <groupId>org.apache.camel.quarkus</groupId> <artifactId>camel-quarkus-xj</artifactId> </dependency>
3.105. XML IO DSL
An XML stack for parsing XML route definitions
3.105.1. What’s inside
Refer to the above link for usage and configuration details.
3.105.2. Maven coordinates
Create a new project with this extension on code.quarkus.redhat.com
Or add the coordinates to your existing project:
<dependency> <groupId>org.apache.camel.quarkus</groupId> <artifactId>camel-quarkus-xml-io-dsl</artifactId> </dependency>
3.105.3. Additional Camel Quarkus configuration
3.105.3.1. XML file encodings
By default, some XML file encodings may not work out of the box in native mode. Please, check the Character encodings section to learn how to fix.
3.106. XML JAXP
XML JAXP type converters and parsers
3.106.1. Maven coordinates
Create a new project with this extension on code.quarkus.redhat.com
Or add the coordinates to your existing project:
<dependency> <groupId>org.apache.camel.quarkus</groupId> <artifactId>camel-quarkus-xml-jaxp</artifactId> </dependency>
3.107. XPath
Evaluates an XPath expression against an XML payload
3.107.1. What’s inside
Refer to the above link for usage and configuration details.
3.107.2. Maven coordinates
Create a new project with this extension on code.quarkus.redhat.com
Or add the coordinates to your existing project:
<dependency> <groupId>org.apache.camel.quarkus</groupId> <artifactId>camel-quarkus-xpath</artifactId> </dependency>
3.107.3. Additional Camel Quarkus configuration
This component is able to load xpath expressions from classpath resources. To make it work also in native mode, you need to explicitly embed the expression files in the native executable by using the quarkus.native.resources.includes
property.
For instance, the route below would load an XPath expression from a classpath resource named myxpath.txt
:
from("direct:start").transform().xpath("resource:classpath:myxpath.txt");
To include this (an possibly other expressions stored in .txt
files) in the native image, you would have to add something like the following to your application.properties
file:
quarkus.native.resources.includes = *.txt
3.108. XSLT Saxon
Transform XML payloads using an XSLT template using Saxon.
3.108.1. What’s inside
-
XSLT Saxon component, URI syntax:
xslt-saxon:resourceUri
Refer to the above link for usage and configuration details.
3.108.2. Maven coordinates
Create a new project with this extension on code.quarkus.redhat.com
Or add the coordinates to your existing project:
<dependency> <groupId>org.apache.camel.quarkus</groupId> <artifactId>camel-quarkus-xslt-saxon</artifactId> </dependency>
3.109. XSLT
Transforms XML payload using an XSLT template.
3.109.1. What’s inside
-
XSLT component, URI syntax:
xslt:resourceUri
Refer to the above link for usage and configuration details.
3.109.2. Maven coordinates
Create a new project with this extension on code.quarkus.redhat.com
Or add the coordinates to your existing project:
<dependency> <groupId>org.apache.camel.quarkus</groupId> <artifactId>camel-quarkus-xslt</artifactId> </dependency>
3.109.3. Additional Camel Quarkus configuration
To optimize XSLT processing, the extension needs to know the locations of the XSLT templates at build time. The XSLT source URIs have to be passed via the quarkus.camel.xslt.sources
property. Multiple URIs can be separated by comma.
quarkus.camel.xslt.sources = transform.xsl, classpath:path/to/my/file.xsl
Scheme-less URIs are interpreted as classpath:
URIs.
Only classpath:
URIs are supported on Quarkus native mode. file:
, http:
and other kinds of URIs can be used on JVM mode only.
<xsl:include>
and <xsl:messaging>
XSLT elements are also supported in JVM mode only right now.
If aggregate
DSL is used, XsltSaxonAggregationStrategy
has to be used such as
from("file:src/test/resources?noop=true&sortBy=file:name&antInclude=*.xml") .routeId("aggregate").noAutoStartup() .aggregate(new XsltSaxonAggregationStrategy("xslt/aggregate.xsl")) .constant(true) .completionFromBatchConsumer() .log("after aggregate body: ${body}") .to("mock:transformed");
Also, it’s only supported on JVM mode.
3.109.3.1. Configuration
TransformerFactory features can be configured using following property:
quarkus.camel.xslt.features."http\://javax.xml.XMLConstants/feature/secure-processing"=false
3.109.3.2. Extension functions support
Xalan’s extension functions do work properly only when:
- Secure-processing is disabled
- Functions are defined in a separate jar
- Functions are augmented during native build phase. For example, they can be registered for reflection:
@RegisterForReflection(targets = { my.Functions.class }) public class FunctionsConfiguration { }
The content of the XSLT source URIs is parsed and compiled into Java classes at build time. These Java classes are the only source of XSLT information at runtime. The XSLT source files may not be included in the application archive at all.
Configuration property | Type | Default |
---|---|---|
A comma separated list of templates to compile. |
| |
The package name for the generated classes. |
|
|
TransformerFactory features. |
|
Configuration property fixed at build time. All other configuration properties are overridable at runtime.
3.110. YAML DSL
An YAML stack for parsing YAML route definitions
3.110.1. What’s inside
Refer to the above link for usage and configuration details.
3.110.2. Maven coordinates
Create a new project with this extension on code.quarkus.redhat.com
Or add the coordinates to your existing project:
<dependency> <groupId>org.apache.camel.quarkus</groupId> <artifactId>camel-quarkus-yaml-dsl</artifactId> </dependency>
3.110.3. Usage
3.110.3.1. Native mode
The following constructs when defined within Camel YAML DSL markup, require you to register classes for reflection. Refer to the Native mode guide for details.
3.110.3.1.1. Bean definitions
The YAML DSL provides the capability to define beans as follows.
- beans: - name: "greetingBean" type: "org.acme.GreetingBean" properties: greeting: "Hello World!" - route: id: "my-yaml-route" from: uri: "timer:from-yaml?period=1000" steps: - to: "bean:greetingBean"
In this example, the GreetingBean
class needs to be registered for reflection. This applies to any types that you refer to under the beans
key in your YAML routes.
@RegisterForReflection public class GreetingBean { }
3.110.3.1.2. Exception handling
Camel provides various methods of handling exceptions. Some of these require that any exception classes referenced in their DSL definitions are registered for reflection.
on-exception
- on-exception: handled: constant: "true" exception: - "org.acme.MyHandledException" steps: - transform: constant: "Sorry something went wrong"
@RegisterForReflection public class MyHandledException { }
throw-exception
- 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"
@RegisterForReflection public class ForcedException { }
do-catch
- route: id: "my-yaml-route2" from: uri: "direct:tryCatch" steps: - do-try: steps: - to: "direct:readFile" do-catch: - exception: - "java.io.FileNotFoundException" steps: - transform: constant: "do-catch caught an exception"
@RegisterForReflection(targets = FileNotFoundException.class) public class MyClass { }
3.111. Zip Deflate Compression
Compress and decompress streams using java.util.zip.Deflater, java.util.zip.Inflater or java.util.zip.GZIPStream.
3.111.1. What’s inside
Refer to the above links for usage and configuration details.
3.111.2. Maven coordinates
Create a new project with this extension on code.quarkus.redhat.com
Or add the coordinates to your existing project:
<dependency> <groupId>org.apache.camel.quarkus</groupId> <artifactId>camel-quarkus-zip-deflater</artifactId> </dependency>
3.112. Zip File
Compression and decompress streams using java.util.zip.ZipStream.
3.112.1. What’s inside
Refer to the above link for usage and configuration details.
3.112.2. Maven coordinates
Create a new project with this extension on code.quarkus.redhat.com
Or add the coordinates to your existing project:
<dependency> <groupId>org.apache.camel.quarkus</groupId> <artifactId>camel-quarkus-zipfile</artifactId> </dependency>