Reception awareness is configured per-PMode via PModeReceptionAwareness. It governs the AS4 reliability layer: whether the sender should retry delivery when no receipt is received.
import com.helger.phase4.messaging.http.HttpRetrySettings;import java.time.Duration;import java.math.BigDecimal;// Configure 3 transport retries with exponential backoffHttpRetrySettings retrySettings = new HttpRetrySettings() .setMaxRetries(3) // retry up to 3 times .setDurationBeforeRetry(Duration.ofSeconds(5)) // wait 5s before first retry .setRetryIncreaseFactor(new BigDecimal("2.0"));// double the wait time each retry
The retry increase factor works as follows:
Retry 1: 5 seconds
Retry 2: 10 seconds
Retry 3: 20 seconds
A factor of 1.0 (the default) means no increase – fixed-interval retries.
When duplicateDetection is enabled in the PMode, phase4 automatically records incoming message IDs and rejects duplicates. This interacts with retries: if a message is successfully delivered but the receipt was lost, the sender may retry – and the duplicate detection on the receiver side will correctly identify and suppress the duplicate.
// Duplicate detection is enabled in the default PMode for all built-in profiles:// ETriState eDuplicateDetection = ETriState.TRUE;
When sending messages, phase4 evaluates whether a retry is feasible based on the exception type. Transport errors (e.g. connection refused, timeout) are retryable. AS4 application-level errors (e.g. a received error signal message) are not.