How dk2k/camel-as2-usage works
Project type and purpose
– This is a Java-based integration/demo project using Apache Camel to illustrate AS2 (Applicability Statement 2) messaging: sending, receiving, and processing MDNs against either Mendelson’s public test server or a local stub. There is no database or UI; it’s a messaging middleware/service.
File structure
– Top-level:
• pom.xml (Maven build)
• src/main/java/ru/outofrange/as2/config (CamelConfig)
• src/main/java/ru/outofrange/as2/route (three RouteBuilders)
• src/main/java/ru/outofrange/cert (two CertLoader implementations)
• src/main/resources (application.properties + certificates)
– Test harness via a single JUnit ContextTest – boots Spring Boot/CamelContext, then you POST to HTTP endpoints to drive the routes.
README for additional insights
– Two modes:
A) Send to Mendelson testserver (external AS2 endpoint) on HTTP →3400/link.
B) Send/receive locally via self-signed cert on port 3500.
– Boolean flag NEED_SIGNED_ENCRYPTED toggles plain vs. signed/encrypted AS2.
– MDN response template is hardcoded by Camel’s AS2 component.
1. Spring Boot App (MyApplication)
2. Camel Context (instantiated by CamelConfig)
3. Route 1: AS2 Server (AS2ServerRouteBuilder)
4. Route 2: Mendelson AS2 Client (MendelsonAs2ClientRouteBuilder)
5. Route 3: Localhost Stub AS2 Client (LocalhostStubAS2ClientRouteBuilder)
6. Cert Loader Services (MendelsonCertLoader, SelfSignedCertLoader)
7. External Services:
• Mendelson Test Server (https://testas2.mendelson-e-c.com)
• (Optional) Local stub server
b. Relationships & interactions:
– Data flow starts when a user issues an HTTP POST (e.g., via Postman) to either http://localhost:3400/link or http://localhost:3500/link.
– The HTTP endpoint is exposed by one of the Camel routes.
– Incoming message is wrapped in an AS2Request by the Camel AS2 component.
– The route picks up certificate(s) from the CertLoader (depending on mode).
– The AS2 producer sends the AS2 request to the target (Mendelson’s endpoint or the stub).
– On receipt, AS2ServerRouteBuilder acts as the HTTP listener on port 3500, processes incoming AS2, and returns an MDN.
– MDN flows back to the client route and is logged or further processed using JavaMail multipart utilities.
c. Architectural patterns & principles:
– Dependency Injection: @Configuration class wires CamelContext, routes, and certificate loaders.
– Modular routes: each AS2 flow is encapsulated in its own RouteBuilder.
– Strategy pattern: two implementations of CertLoader toggle between Mendelson cert and self-signed cert.
d. Key technologies & frameworks:
– Apache Camel (core, camel-as2 component)
– Spring Boot (auto-configuration, dependency injection)
– JavaMail (for multipart MDN processing)
– OpenSSL-generated certificates (X.509, PKCS#12)
Detail without overthinking
– Capture each Java package/module as a functional block.
– Don’t just show “Camel” – break out each RouteBuilder and CertLoader.