Skip to content
Philip Helger edited this page Feb 23, 2023 · 4 revisions

This page quickly elaborates on the overall architecture of as2-lib.

The goal is to be able to handle as many different AS2 scenarios as possible, ideally in a declarative manner.

AS2 Session

The outermost concept is the "AS2 Session" (that has nothing to do with an HTTP Session). An AS2 session encapsulates message processor, handling modules, certificate management and partnership management together. Usually an application uses exactly one AS2 Session but you may operate multiple of them in parallel.

The configuration of the AS2 Session can be done via a Configuration file or can also be done programmatically. See https://github.com/phax/as2-lib/blob/master/as2-servlet/src/test/java/com/helger/as2servlet/example/AS2ReceiveXServletHandlerCodeConfig.java for an example how to initialize the session programmatically.

Message Processor

The main concept for dealing with incoming message is the "Message Processor". It is specified in the interface IMessageProcessor and comes with two different implementations:

  • com.helger.as2lib.processor.DefaultMessageProcessor - handles all incoming messages synchronously
  • com.helger.as2lib.processor.AsyncMessageProcessor - handles all incoming messages asynchronously. That may only be needed in case of the as2-server. When using the Servlet based approach, the application server usually already deals with the separation of one thread per request.

An application must have at least one Message Processor. Usually exactly one MP is needed. The MP is uniquely assigned to an "AS2 Session".

Each MP has a list of modules. Each module must implement the IProcessorModule interface. Some processor modules are so called "active" modules. These active modules must implement the IProcessorActiveModule interface. Active modules usually work asynchronously in the background and have a respective start and stop method. An MP can have multiple instances of the same module with different configuration.

The following MP modules are available, grouped by their use case:

Receiving AS2 messages

  • com.helger.as2lib.processor.receiver.AS2ReceiverModule - the active main module in as2-lib. Uses the AS2ReceiverHandler for the main actions.
    • May trigger the actions sendmdn, storemdn, validate-before-store, store, validate-after-store
  • com.helger.as2servlet.util.AS2ServletReceiverModule - a specialized version to be used only in Servlet-based environments in as2-servlet (made "non-active)
    • May trigger the same actions as AS2ReceiverModule
  • com.helger.as2.webapp.module.ConfigurableAS2ServletReceiverModule - example code showing how the AS2ReceiverHandler can easily be customized in as2-demo-webapp.
    • May trigger the same actions as AS2ReceiverModule

Receiving asynchronous MDN messages

  • com.helger.as2lib.processor.receiver.AS2MDNReceiverModule - the active main module in as2-lib. Uses the AS2MDNReceiverHandler for the main actions.
    • May trigger the action storemdn
  • com.helger.as2servlet.util.AS2ServletMDNReceiverModule - a specialized version to be used only in Servlet-based environments in as2-servlet (made "non-active)
    • May trigger the same actions as AS2MDNReceiverModule
  • com.helger.as2.webapp.module.ConfigurableAS2MDNServletReceiverModule - example code showing how the AS2MDNReceiverHandler can easily be customized in as2-demo-webapp.
    • May trigger the same actions as AS2MDNReceiverModule

Send AS2 messages

  • com.helger.as2lib.processor.sender.AS2SenderModule - the main module in as2-lib for sending AS2 message. It also deals with the reception of synchronous MDN messages.
    • Handles the action send for AS2Message objects
    • May trigger the actions storemdn, resend
  • com.helger.as2lib.processor.receiver.AS2DirectoryPollingModule - An active module that checks for updates in a file system directory and then triggers the sending of a message. Note: yes, the namespace name of this class is wrong - should be sending instead of receiving.
    • May trigger the actions send

The sending of AS2 messages may be achieved via such modules, if e.g. polling is activated. Alternatively the sending of AS2 messages can also be triggered on the fly as described in page sending AS2 messages.

Send asynchronous MDN messages

  • com.helger.as2lib.processor.sender.AsynchMDNSenderModule - the main modules in as2-lib to send asynchronous MDN messages.
    • Handles the action sendmdn for AS2Message objects
    • May trigger the actions storemdn, resend

Resending of AS2 messages in case previous transmissions failed

  • com.helger.as2lib.processor.resender.DirectoryResenderModule - An active module that checks for updates in a file system directory and tries to re-send an AS2 message from there
    • Handles the action resend
    • May trigger the action send or a customizable action
  • com.helger.as2lib.processor.resender.InMemoryResenderModule - An active module that keeps failed message in memory and tries to resend them
    • Handles the action resend
    • May trigger the action send or a customizable action
  • com.helger.as2lib.processor.resender.ImmediateResenderModule - A module that immediately tries to resend the message without any delay
    • Handles the action resend
    • May trigger the action send or a customizable action

Storing AS2 messages

  • com.helger.as2lib.processor.storage.MessageFileModule - stores AS2 messages and optionally the header data to disk in as2-lib
    • Handles the action store
  • com.helger.as2lib.processor.storage.MDNFileModule - stores MDN messages and header data to disk in as2-lib
    • Handles the action storemdn

Custom MP modules handling custom actions may be implemented.