Skip to content

Sending Process

Philip Helger edited this page Feb 24, 2026 · 18 revisions

Sending Process

Overview

The sending process handles outbound Peppol document transmission from the Sender Backend (within C2) through the AP to the remote receiving AP (C3).

Process Steps

  1. Receive document via API - The Sender Backend provides data via the REST API (raw document + metadata, or pre-built SBD).
  2. Store in database - The document and metadata are persisted to PostgreSQL.
  3. Optional verification - Configurable validation of the document. May lead to rejection (status updated in DB, notification triggered).
  4. AS4 sending via phase4 - SMP lookup, SBDH creation (if needed), AS4 message construction, signing, and transmission. The synchronous AS4 receipt is checked.
  5. Store attempt result in DB - A new row is created for each sending attempt, recording the AS4 Message ID, Receipt Message ID, HTTP status code, and timestamp. All attempts for the same document are correlated by the SBDH Instance ID.
  6. On success: trigger outbound reporting - The onSuccessfulAS4Sending callback triggers Peppol reporting for the outbound transaction.
  7. On failure: schedule retry - The transaction is marked for retry. The retry strategy (max attempts, backoff) is defined via customizable Java interfaces.
  8. On permanent failure: notify - When max retries are exhausted, the generic notification interface is invoked.

Sequence Diagram

┌────────┐        ┌──────────┐        ┌────────┐        ┌────────┐        ┌──────────┐
│Sender  │        │    AP    │        │   DB   │        │ phase4 │        │ Remote   │
│Backend │        │   API    │        │        │        │        │        │  AP (C3) │
└───┬────┘        └────┬─────┘        └───┬────┘        └───┬────┘        └────┬─────┘
    │                  │                  │                  │                  │
    │ 1. Submit doc    │                  │                  │                  │
    │ (raw+meta or SBD)│                  │                  │                  │
    │─────────────────>│                  │                  │                  │
    │                  │                  │                  │                  │
    │                  │ 2. Store document│                  │                  │
    │                  │   + metadata     │                  │                  │
    │                  │─────────────────>│                  │                  │
    │                  │   stored OK      │                  │                  │
    │                  │<─────────────────│                  │                  │
    │                  │                  │                  │                  │
    │                  │ 3. Verify doc    │                  │                  │
    │                  │   (optional)     │                  │                  │
    │                  │──────┐           │                  │                  │
    │                  │      │ validate  │                  │                  │
    │                  │<─────┘           │                  │                  │
    │                  │                  │                  │                  │
    │                  │   [if rejected: update DB, notify, return error]      │
    │                  │                  │                  │                  │
    │                  │ 4. Trigger AS4   │                  │                  │
    │                  │    send          │                  │                  │
    │                  │─────────────────────────────────── >│                  │
    │                  │                  │                  │                  │
    │                  │                  │                  │ AS4 UserMessage  │
    │                  │                  │                  │────────────────>│
    │                  │                  │                  │                  │
    │                  │                  │                  │ AS4 Receipt      │
    │                  │                  │                  │<────────────────│
    │                  │                  │                  │                  │
    │                  │ AS4 result       │                  │                  │
    │                  │ (Receipt MsgID,  │                  │                  │
    │                  │  HTTP status)    │                  │                  │
    │                  │<──────────────────────────────────-│                  │
    │                  │                  │                  │                  │
    │                  │ 5. Insert new    │                  │                  │
    │                  │  attempt row     │                  │                  │
    │                  │  (AS4 MsgID,     │                  │                  │
    │                  │   Receipt MsgID, │                  │                  │
    │                  │   HTTP status,   │                  │                  │
    │                  │   timestamp)     │                  │                  │
    │                  │─────────────────>│                  │                  │
    │                  │                  │                  │                  │
    │ API response     │                  │                  │                  │
    │ (success/fail)   │                  │                  │                  │
    │<─────────────────│                  │                  │                  │
    │                  │                  │                  │                  │
    │                  │ 6. [on success]  │                  │                  │
    │                  │  Trigger outbound│                  │                  │
    │                  │  reporting       │                  │                  │
    │                  │  callback        │                  │                  │
    │                  │──────┐           │                  │                  │
    │                  │      │ report    │                  │                  │
    │                  │<─────┘           │                  │                  │
    │                  │                  │                  │                  │
    │                  │ Store reporting  │                  │                  │
    │                  │ record           │                  │                  │
    │                  │─────────────────>│                  │                  │
    │                  │                  │                  │                  │

Retry Flow (asynchronous, triggered by scheduler)

┌──────────┐          ┌────────┐          ┌────────┐          ┌──────────┐
│Scheduler │          │   DB   │          │ phase4 │          │ Remote   │
│          │          │        │          │        │          │  AP (C3) │
└────┬─────┘          └───┬────┘          └───┬────┘          └────┬─────┘
     │                    │                   │                    │
     │ Query transactions │                   │                    │
     │ eligible for retry │                   │                    │
     │───────────────────>│                   │                    │
     │                    │                   │                    │
     │ list of pending    │                   │                    │
     │<───────────────────│                   │                    │
     │                    │                   │                    │
     │ For each:          │                   │                    │
     │                    │                   │                    │
     │  Trigger AS4 send  │                   │                    │
     │───────────────────────────────────────>│                    │
     │                    │                   │  AS4 UserMessage   │
     │                    │                   │───────────────────>│
     │                    │                   │  AS4 Receipt/Error │
     │                    │                   │<───────────────────│
     │  AS4 result        │                   │                    │
     │<───────────────────────────────────────│                    │
     │                    │                   │                    │
     │ Insert new attempt │                   │                    │
     │ row in DB          │                   │                    │
     │───────────────────>│                   │                    │
     │                    │                   │                    │
     │ [on success:       │                   │                    │
     │  trigger reporting │                   │                    │
     │  callback]         │                   │                    │
     │                    │                   │                    │
     │ [if max retries    │                   │                    │
     │  exhausted: notify]│                   │                    │
     │                    │                   │                    │

Outbound Message Metadata (one row per sending attempt)

Field Description
Sending timestamp Date and time of this specific sending attempt
AS4 Message ID The AS4 Message ID used for this attempt
SBDH Instance ID The Peppol SBDH Instance Identifier (correlates all attempts for the same document)
Business Document ID Optional: the ID from the business document itself
Receipt Message ID The AS4 Message ID from the synchronous receipt (null on failure)
HTTP Status Code The HTTP status code from the AS4 response
Attempt Status Outcome of this specific attempt (success, failed)
Document bytes The raw document payload
C1 Country Code Country of the sender (C1), provided via API or extracted from SBDH

Clone this wiki locally