AS2 Component

Since Camel 2.22

Both producer and consumer is supported

The AS2 component provides transport of EDI messages using the HTTP transfer protocol as specified in RFC4130.

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:

<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

as2://apiName/methodName

apiName can be one of:

  • client

  • server

AS2 Options

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

Name Description Default Type

configuration (common)

To use the shared configuration

AS2Configuration

basicPropertyBinding (advanced)

Whether the component should use basic property binding (Camel 2.x) or the newer property binding with additional capabilities

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

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

The AS2 endpoint is configured using URI syntax:

as2:apiName/methodName

with the following path and query parameters:

Path Parameters (2 parameters):

Name Description Default Type

apiName

Required What kind of operation to perform

AS2ApiName

methodName

Required What sub operation to use for the selected operation

String

Query Parameters (49 parameters):

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

AS2MessageStructure

as2To (common)

The value of the AS2To header of AS2 message.

String

as2Version (common)

The version of the AS2 protocol.

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.

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.

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.

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.

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. You can also specify time values using units, such as 60s (60 seconds), 5m30s (5 minutes and 30 seconds), and 1h (1 hour).

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. You can also specify time values using units, such as 60s (60 seconds), 5m30s (5 minutes and 30 seconds), and 1h (1 hour).

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.

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

none

String

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.

MILLISECONDS

TimeUnit

useFixedDelay (scheduler)

Controls if fixed delay or fixed rate is used. See ScheduledExecutorService in JDK for details.

true

boolean

Spring Boot Auto-Configuration

When using Spring Boot make sure to use the following Maven dependency to have support for auto configuration:

<dependency>
  <groupId>org.apache.camel.springboot</groupId>
  <artifactId>camel-as2-starter</artifactId>
  <version>x.x.x</version>
  <!-- use the same version as your Camel core version -->
</dependency>

The component supports 32 options, which are listed below.

Name Description Default Type

camel.component.as2.basic-property-binding

Whether the component should use basic property binding (Camel 2.x) or the newer property binding with additional capabilities

false

Boolean

camel.component.as2.bridge-error-handler

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

camel.component.as2.configuration.api-name

What kind of operation to perform

AS2ApiName

camel.component.as2.configuration.as2-from

The value of the AS2From header of AS2 message.

String

camel.component.as2.configuration.as2-message-structure

The structure of AS2 Message. One of: PLAIN - No encryption, no signature, SIGNED - No encryption, signature, ENCRYPTED - Encryption, no signature, ENCRYPTED_SIGNED - Encryption, signature

AS2MessageStructure

camel.component.as2.configuration.as2-to

The value of the AS2To header of AS2 message.

String

camel.component.as2.configuration.as2-version

The version of the AS2 protocol.

1.1

String

camel.component.as2.configuration.client-fqdn

The Client Fully Qualified Domain Name (FQDN). Used in message ids sent by endpoint.

camel.apache.org

String

camel.component.as2.configuration.compression-algorithm

The algorithm used to compress EDI message.

AS2CompressionAlgorithm

camel.component.as2.configuration.decrypting-private-key

The key used to encrypt the EDI message.

PrivateKey

camel.component.as2.configuration.disposition-notification-to

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

camel.component.as2.configuration.edi-message-transfer-encoding

The transfer encoding of EDI message.

String

camel.component.as2.configuration.edi-message-type

The content type of EDI message. One of application/edifact, application/edi-x12, application/edi-consent

ContentType

camel.component.as2.configuration.encrypting-algorithm

The algorithm used to encrypt EDI message.

AS2EncryptionAlgorithm

camel.component.as2.configuration.encrypting-certificate-chain

The chain of certificates used to encrypt EDI message.

Certificate[]

camel.component.as2.configuration.from

The value of the From header of AS2 message.

String

camel.component.as2.configuration.mdn-message-template

The template used to format MDN message

String

camel.component.as2.configuration.method-name

What sub operation to use for the selected operation

String

camel.component.as2.configuration.request-uri

The request URI of EDI message.

/

String

camel.component.as2.configuration.server

The value included in the Server message header identifying the AS2 Server.

Camel AS2 Server Endpoint

String

camel.component.as2.configuration.server-fqdn

The Server Fully Qualified Domain Name (FQDN). Used in message ids sent by endpoint.

camel.apache.org

String

camel.component.as2.configuration.server-port-number

The port number of server.

Integer

camel.component.as2.configuration.signed-receipt-mic-algorithms

The list of algorithms, in order of preference, requested to generate a message integrity check (MIC) returned in message dispostion notification (MDN)

String[]

camel.component.as2.configuration.signing-algorithm

The algorithm used to sign EDI message.

AS2SignatureAlgorithm

camel.component.as2.configuration.signing-certificate-chain

The chain of certificates used to sign EDI message.

Certificate[]

camel.component.as2.configuration.signing-private-key

The key used to sign the EDI message.

PrivateKey

camel.component.as2.configuration.subject

The value of Subject header of AS2 message.

String

camel.component.as2.configuration.target-hostname

The host name (IP or DNS name) of target host.

String

camel.component.as2.configuration.target-port-number

The port number of target host. -1 indicates the scheme default port.

Integer

camel.component.as2.configuration.user-agent

The value included in the User-Agent message header identifying the AS2 user agent.

Camel AS2 Client Endpoint

String

camel.component.as2.enabled

Whether to enable auto configuration of the as2 component. This is enabled by default.

Boolean

camel.component.as2.lazy-start-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

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.

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.

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

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.

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.

Method Options Result Body Type

listen

requestUriPattern

org.apache.http.protocol.HttpCoreContext

URI Options for server

Name Type

requestUriPattern

String