-
Notifications
You must be signed in to change notification settings - Fork 44
Architecture
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.
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.
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 theas2-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:
-
com.helger.as2lib.processor.receiver.AS2ReceiverModule
- the active main module inas2-lib
. Uses theAS2ReceiverHandler
for the main actions.- May trigger the actions
sendmdn
,storemdn
,validate-before-store
,store
,validate-after-store
- May trigger the actions
-
com.helger.as2servlet.util.AS2ServletReceiverModule
- a specialized version to be used only in Servlet-based environments inas2-servlet
(made "non-active)- May trigger the same actions as
AS2ReceiverModule
- May trigger the same actions as
-
com.helger.as2.webapp.module.ConfigurableAS2ServletReceiverModule
- example code showing how theAS2ReceiverHandler
can easily be customized inas2-demo-webapp
.- May trigger the same actions as
AS2ReceiverModule
- May trigger the same actions as
-
com.helger.as2lib.processor.receiver.AS2MDNReceiverModule
- the active main module inas2-lib
. Uses theAS2MDNReceiverHandler
for the main actions.- May trigger the action
storemdn
- May trigger the action
-
com.helger.as2servlet.util.AS2ServletMDNReceiverModule
- a specialized version to be used only in Servlet-based environments inas2-servlet
(made "non-active)- May trigger the same actions as
AS2MDNReceiverModule
- May trigger the same actions as
-
com.helger.as2.webapp.module.ConfigurableAS2MDNServletReceiverModule
- example code showing how theAS2MDNReceiverHandler
can easily be customized inas2-demo-webapp
.- May trigger the same actions as
AS2MDNReceiverModule
- May trigger the same actions as
-
com.helger.as2lib.processor.sender.AS2SenderModule
- the main module inas2-lib
for sending AS2 message. It also deals with the reception of synchronous MDN messages.- Handles the action
send
forAS2Message
objects - May trigger the actions
storemdn
,resend
- Handles the action
-
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 besending
instead ofreceiving
.- May trigger the actions
send
- May trigger the actions
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.
-
com.helger.as2lib.processor.sender.AsynchMDNSenderModule
- the main modules inas2-lib
to send asynchronous MDN messages.- Handles the action
sendmdn
forAS2Message
objects - May trigger the actions
storemdn
,resend
- Handles the action
-
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
- Handles the 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
- Handles the 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
- Handles the action
-
com.helger.as2lib.processor.storage.MessageFileModule
- stores AS2 messages and optionally the header data to disk inas2-lib
- Handles the action
store
- Handles the action
-
com.helger.as2lib.processor.storage.MDNFileModule
- stores MDN messages and header data to disk inas2-lib
- Handles the action
storemdn
- Handles the action
Custom MP modules handling custom actions may be implemented.