[[as2-component]]
= AS2 Component
//THIS FILE IS COPIED: EDIT THE SOURCE FILE:
:page-source: components/camel-as2/camel-as2-component/src/main/docs/as2-component.adoc
:docTitle: AS2
:artifactId: camel-as2
:description: Transfer data securely and reliably using the AS2 protocol (RFC4130).
:since: 2.22
:supportLevel: Stable
:component-header: Both producer and consumer are supported

*Since Camel {since}*

*{component-header}*

The AS2 component provides transport of EDI messages using the HTTP transfer protocol
as specified in https://tools.ietf.org/html/rfc4130[RFC4130]. 

[NOTE]
====
This component is currently a work in progress. Expect URI options and path and query parameters to change in future versions of this component.
==== 

Maven users will need to add the following dependency to their pom.xml
for this component:

[source,xml]
----
<dependency>
    <groupId>org.apache.camel</groupId>
    <artifactId>camel-as2</artifactId>
    <version>x.x.x</version>
    <!-- use the same version as your Camel core version -->
</dependency>
----

== URI format

[source]
----
as2://apiName/methodName
----

apiName can be one of:

* client
* server


== AS2 Options


// component options: START
The AS2 component supports 4 options, which are listed below.



[width="100%",cols="2,5,^1,2",options="header"]
|===
| Name | Description | Default | Type
| *bridgeErrorHandler* (consumer) | Allows for bridging the consumer to the Camel routing Error Handler, which mean any exceptions occurred while the consumer is trying to pickup incoming messages, or the likes, will now be processed as a message and handled by the routing Error Handler. By default the consumer will use the org.apache.camel.spi.ExceptionHandler to deal with exceptions, that will be logged at WARN or ERROR level and ignored. | false | boolean
| *lazyStartProducer* (producer) | Whether the producer should be started lazy (on the first message). By starting lazy you can use this to allow CamelContext and routes to startup in situations where a producer may otherwise fail during starting and cause the route to fail being started. By deferring this startup to be lazy then the startup failure can be handled during routing messages via Camel's routing error handlers. Beware that when the first message is processed then creating and starting the producer may take a little time and prolong the total processing time of the processing. | false | boolean
| *basicPropertyBinding* (advanced) | Whether the component should use basic property binding (Camel 2.x) or the newer property binding with additional capabilities | false | boolean
| *configuration* (advanced) | Component configuration |  | AS2Configuration
|===
// component options: END


// endpoint options: START
The AS2 endpoint is configured using URI syntax:

----
as2:apiName/methodName
----

with the following path and query parameters:

=== Path Parameters (2 parameters):


[width="100%",cols="2,5,^1,2",options="header"]
|===
| Name | Description | Default | Type
| *apiName* | *Required* What kind of operation to perform. The value can be one of: CLIENT, SERVER |  | AS2ApiName
| *methodName* | *Required* What sub operation to use for the selected operation |  | String
|===


=== Query Parameters (49 parameters):


[width="100%",cols="2,5,^1,2",options="header"]
|===
| Name | Description | Default | Type
| *as2From* (common) | The value of the AS2From header of AS2 message. |  | String
| *as2MessageStructure* (common) | The structure of AS2 Message. One of: PLAIN - No encryption, no signature, SIGNED - No encryption, signature, ENCRYPTED - Encryption, no signature, ENCRYPTED_SIGNED - Encryption, signature. The value can be one of: PLAIN, SIGNED, ENCRYPTED, SIGNED_ENCRYPTED, PLAIN_COMPRESSED, SIGNED_COMPRESSED, ENCRYPTED_COMPRESSED, ENCRYPTED_COMPRESSED_SIGNED |  | AS2MessageStructure
| *as2To* (common) | The value of the AS2To header of AS2 message. |  | String
| *as2Version* (common) | The version of the AS2 protocol. The value can be one of: 1.0, 1.1 | 1.1 | String
| *clientFqdn* (common) | The Client Fully Qualified Domain Name (FQDN). Used in message ids sent by endpoint. | camel.apache.org | String
| *compressionAlgorithm* (common) | The algorithm used to compress EDI message. The value can be one of: ZLIB |  | AS2CompressionAlgorithm
| *decryptingPrivateKey* (common) | The key used to encrypt the EDI message. |  | PrivateKey
| *dispositionNotificationTo* (common) | The value of the Disposition-Notification-To header. Assigning a value to this parameter requests a message disposition notification (MDN) for the AS2 message. |  | String
| *ediMessageTransferEncoding* (common) | The transfer encoding of EDI message. |  | String
| *ediMessageType* (common) | The content type of EDI message. One of application/edifact, application/edi-x12, application/edi-consent |  | ContentType
| *encryptingAlgorithm* (common) | The algorithm used to encrypt EDI message. The value can be one of: AES128_CBC, AES192_CBC, AES256_CBC, AES128_CCM, AES192_CCM, AES256_CCM, AES128_GCM, AES192_GCM, AES256_GCM, CAMELLIA128_CBC, CAMELLIA192_CBC, CAMELLIA256_CBC, CAST5_CBC, DES_CBC, DES_EDE3_CBC, GOST28147_GCFB, IDEA_CBC, RC2_CBC, RC4, SEED_CBC |  | AS2EncryptionAlgorithm
| *encryptingCertificateChain* (common) | The chain of certificates used to encrypt EDI message. |  | Certificate[]
| *from* (common) | The value of the From header of AS2 message. |  | String
| *inBody* (common) | Sets the name of a parameter to be passed in the exchange In Body |  | String
| *mdnMessageTemplate* (common) | The template used to format MDN message |  | String
| *requestUri* (common) | The request URI of EDI message. | / | String
| *server* (common) | The value included in the Server message header identifying the AS2 Server. | Camel AS2 Server Endpoint | String
| *serverFqdn* (common) | The Server Fully Qualified Domain Name (FQDN). Used in message ids sent by endpoint. | camel.apache.org | String
| *serverPortNumber* (common) | The port number of server. |  | Integer
| *signedReceiptMicAlgorithms* (common) | The list of algorithms, in order of preference, requested to generate a message integrity check (MIC) returned in message dispostion notification (MDN) |  | String[]
| *signingAlgorithm* (common) | The algorithm used to sign EDI message. The value can be one of: SHA3_224WITHRSA, SHA3_256WITHRSA, SHA3_384withRSA, SHA3_512WITHRSA, MD5WITHRSA, SHA1WITHRSA, MD2WITHRSA, SHA224WITHRSA, SHA256WITHRSA, SHA384WITHRSA, SHA512WITHRSA, RIPEMD128WITHRSA, RIPEMD160WITHRSA, RIPEMD256WITHRSA, SHA224WITHDSA, SHA256WITHDSA, SHA384WITHDSA, SHA512WITHDSA, SHA3_224WITHDSA, SHA3_256WITHDSA, SHA3_384WITHDSA, SHA3_512WITHDSA, SHA1WITHDSA, SHA3_224WITHECDSA, SHA3_256WITHECDSA, SHA3_384WITHECDSA, SHA3_512WITHECDSA, SHA1WITHECDSA, SHA224WITHECDSA, SHA256WITHECDSA, SHA384WITHECDSA, SHA512WITHECDSA, SHA1WITHPLAIN_ECDSA, SHA224WITHPLAIN_ECDSA, SHA256WITHPLAIN_ECDSA, SHA384WITHPLAIN_ECDSA, SHA512WITHPLAIN_ECDSA, RIPEMD160WITHPLAIN_ECDSA, SHA1WITHRSAANDMGF1, SHA224WITHRSAANDMGF1, SHA256WITHRSAANDMGF1, SHA384WITHRSAANDMGF1, SHA512WITHRSAANDMGF1, SHA3_224WITHRSAANDMGF1, SHA3_256WITHRSAANDMGF1, SHA3_384WITHRSAANDMGF1, SHA3_512WITHRSAANDMGF1 |  | AS2SignatureAlgorithm
| *signingCertificateChain* (common) | The chain of certificates used to sign EDI message. |  | Certificate[]
| *signingPrivateKey* (common) | The key used to sign the EDI message. |  | PrivateKey
| *subject* (common) | The value of Subject header of AS2 message. |  | String
| *targetHostname* (common) | The host name (IP or DNS name) of target host. |  | String
| *targetPortNumber* (common) | The port number of target host. -1 indicates the scheme default port. |  | Integer
| *userAgent* (common) | The value included in the User-Agent message header identifying the AS2 user agent. | Camel AS2 Client Endpoint | String
| *bridgeErrorHandler* (consumer) | Allows for bridging the consumer to the Camel routing Error Handler, which mean any exceptions occurred while the consumer is trying to pickup incoming messages, or the likes, will now be processed as a message and handled by the routing Error Handler. By default the consumer will use the org.apache.camel.spi.ExceptionHandler to deal with exceptions, that will be logged at WARN or ERROR level and ignored. | false | boolean
| *sendEmptyMessageWhenIdle* (consumer) | If the polling consumer did not poll any files, you can enable this option to send an empty message (no body) instead. | false | boolean
| *exceptionHandler* (consumer) | To let the consumer use a custom ExceptionHandler. Notice if the option bridgeErrorHandler is enabled then this option is not in use. By default the consumer will deal with exceptions, that will be logged at WARN or ERROR level and ignored. |  | ExceptionHandler
| *exchangePattern* (consumer) | Sets the exchange pattern when the consumer creates an exchange. The value can be one of: InOnly, InOut, InOptionalOut |  | ExchangePattern
| *pollStrategy* (consumer) | A pluggable org.apache.camel.PollingConsumerPollingStrategy allowing you to provide your custom implementation to control error handling usually occurred during the poll operation before an Exchange have been created and being routed in Camel. |  | PollingConsumerPollStrategy
| *lazyStartProducer* (producer) | Whether the producer should be started lazy (on the first message). By starting lazy you can use this to allow CamelContext and routes to startup in situations where a producer may otherwise fail during starting and cause the route to fail being started. By deferring this startup to be lazy then the startup failure can be handled during routing messages via Camel's routing error handlers. Beware that when the first message is processed then creating and starting the producer may take a little time and prolong the total processing time of the processing. | false | boolean
| *basicPropertyBinding* (advanced) | Whether the endpoint should use basic property binding (Camel 2.x) or the newer property binding with additional capabilities | false | boolean
| *synchronous* (advanced) | Sets whether synchronous processing should be strictly used, or Camel is allowed to use asynchronous processing (if supported). | false | boolean
| *backoffErrorThreshold* (scheduler) | The number of subsequent error polls (failed due some error) that should happen before the backoffMultipler should kick-in. |  | int
| *backoffIdleThreshold* (scheduler) | The number of subsequent idle polls that should happen before the backoffMultipler should kick-in. |  | int
| *backoffMultiplier* (scheduler) | To let the scheduled polling consumer backoff if there has been a number of subsequent idles/errors in a row. The multiplier is then the number of polls that will be skipped before the next actual attempt is happening again. When this option is in use then backoffIdleThreshold and/or backoffErrorThreshold must also be configured. |  | int
| *delay* (scheduler) | Milliseconds before the next poll. | 500 | long
| *greedy* (scheduler) | If greedy is enabled, then the ScheduledPollConsumer will run immediately again, if the previous run polled 1 or more messages. | false | boolean
| *initialDelay* (scheduler) | Milliseconds before the first poll starts. | 1000 | long
| *repeatCount* (scheduler) | Specifies a maximum limit of number of fires. So if you set it to 1, the scheduler will only fire once. If you set it to 5, it will only fire five times. A value of zero or negative means fire forever. | 0 | long
| *runLoggingLevel* (scheduler) | The consumer logs a start/complete log line when it polls. This option allows you to configure the logging level for that. The value can be one of: TRACE, DEBUG, INFO, WARN, ERROR, OFF | TRACE | LoggingLevel
| *scheduledExecutorService* (scheduler) | Allows for configuring a custom/shared thread pool to use for the consumer. By default each consumer has its own single threaded thread pool. |  | ScheduledExecutorService
| *scheduler* (scheduler) | To use a cron scheduler from either camel-spring or camel-quartz component. Use value spring or quartz for built in scheduler | none | Object
| *schedulerProperties* (scheduler) | To configure additional properties when using a custom scheduler or any of the Quartz, Spring based scheduler. |  | Map
| *startScheduler* (scheduler) | Whether the scheduler should be auto started. | true | boolean
| *timeUnit* (scheduler) | Time unit for initialDelay and delay options. The value can be one of: NANOSECONDS, MICROSECONDS, MILLISECONDS, SECONDS, MINUTES, HOURS, DAYS | MILLISECONDS | TimeUnit
| *useFixedDelay* (scheduler) | Controls if fixed delay or fixed rate is used. See ScheduledExecutorService in JDK for details. | true | boolean
|===
// endpoint options: END


== Client Endpoints:

Client endpoints use the endpoint prefix *`client`* followed by the name of a method
and associated options described next. The endpoint URI MUST contain the prefix *`client`*.

[source]
----
as2://client/method?[options]
----

Endpoint options that are not mandatory are denoted by *[]*. When there
are no mandatory options for an endpoint, one of the set of *[]* options
MUST be provided. Producer endpoints can also use a special
option *`inBody`* that in turn should contain the name of the endpoint
option whose value will be contained in the Camel Exchange In message.

Any of the endpoint options can be provided in either the endpoint URI,
or dynamically in a message header. The message header name must be of
the format *`CamelAS2.<option>`*. Note that the *`inBody`* option
overrides message header, i.e. the endpoint
option *`inBody=option`* would override a *`CamelAS2.option`* header.

If a value is not provided for the option *defaultRequest* either in the
endpoint URI or in a message header, it will be assumed to be `null`.
Note that the `null` value will only be used if other options do not
satisfy matching endpoints.

In case of AS2 API errors the endpoint will throw a
RuntimeCamelException with a
*org.apache.http.HttpException* derived exception
cause.

[width="100%",cols="10%,10%,70%",options="header"]
|===
|Method |Options |Result Body Type

|send |ediMessage, requestUri, subject, from, as2From, as2To, as2MessageStructure, ediMessageContentType, ediMessageTransferEncoding, dispositionNotificationTo, signedReceiptMicAlgorithms |org.apache.http.protocol.HttpCoreContext
|===

URI Options for _client_


[width="100%",cols="10%,90%",options="header"]
|===
|Name |Type

|ediMessage |String

|requestUri |String

|subject |String

|from |String

|as2From |String

|as2To |String

|as2MessageStructure |org.apache.camel.component.as2.api.AS2MessageStructure

|ediMessageContentType |String

|ediMessageTransferEncoding |String

|dispositionNotificationTo |String

|signedReceiptMicAlgorithms |String[]
|===


== Server Endpoints:

Server endpoints use the endpoint prefix *`server`* followed by the name of a method
and associated options described next. The endpoint URI MUST contain the prefix *`server`*.

[source]
----
as2://server/method?[options]
----

Endpoint options that are not mandatory are denoted by *[]*. When there
are no mandatory options for an endpoint, one of the set of *[]* options
MUST be provided. Producer endpoints can also use a special
option *`inBody`* that in turn should contain the name of the endpoint
option whose value will be contained in the Camel Exchange In message.

Any of the endpoint options can be provided in either the endpoint URI,
or dynamically in a message header. The message header name must be of
the format *`CamelAS2.<option>`*. Note that the *`inBody`* option
overrides message header, i.e. the endpoint
option *`inBody=option`* would override a *`CamelAS2.option`* header.

If a value is not provided for the option *defaultRequest* either in the
endpoint URI or in a message header, it will be assumed to be `null`.
Note that the `null` value will only be used if other options do not
satisfy matching endpoints.

In case of AS2 API errors the endpoint will throw a
RuntimeCamelException with a
*org.apache.http.HttpException* derived exception
cause.

[width="100%",cols="10%,10%,70%",options="header"]
|===
|Method |Options |Result Body Type

|listen |requestUriPattern |org.apache.http.protocol.HttpCoreContext
|===

URI Options for _server_


[width="100%",cols="10%,90%",options="header"]
|===
|Name |Type

|requestUriPattern |String
|===

include::camel-spring-boot::page$as2-starter.adoc[]
