Overview
pn-national-registries is an aggregation gateway that routes address resolution requests to Italian public registries — primarily ANPR (Anagrafe Nazionale della Popolazione Residente) for physical persons and InfoCamere for legal entities. Paper Channel consults National Registries during the prepare phase when no valid delivery address is available for a recipient. The integration is asynchronous: Paper Channel fires a lookup request and immediately transitions the delivery request to theNATIONAL_REGISTRY_WAITING status. National Registries delivers the result later via a callback on the SQS queue pn.paper-channel.queue-national-registries.
Outbound: HTTP POST
NationalRegistryClient.finderAddress(...) submits an address lookup for a given fiscal code.Inbound: SQS
National Registries pushes the resolved address (or a not-found indicator) back to the Paper Channel queue.
Prepare-phase lookup flow
Client interface
Implementation — NationalRegistryClientImpl
The client calls the AddressApi.getAddresses operation:
- Endpoint:
POST /national-registries-private/{recipient-type}/addresses - Header:
pn-national-registries-cx-idset frompnPaperChannelConfig.getNationalRegistryCxId()
Request body built by the client
Correlation identifier used to match the asynchronous callback. Built by
Utility.buildNationalRegistriesCorrelationId(requestId).Recipient fiscal code (or VAT number for legal entities).
Always
PHYSICAL — Paper Channel only requests physical postal addresses.ISO-8601 timestamp representing the reference date for the address lookup.
Response — AddressOKDto
The synchronous HTTP response acknowledges receipt of the request. The actual resolved address arrives asynchronously via SQS. The SQS payload is mapped to an AddressOKDto by the queue consumer and then used to resume the prepare flow.
Service layer — NationalRegistryServiceImpl
NationalRegistryServiceImpl implements NationalRegistryService and orchestrates the full lookup lifecycle:
- Stores the
correlationIdon thePnDeliveryRequestentity. - Transitions the request status to
NATIONAL_REGISTRY_WAITING.
finderAddress):
- Builds a
NationalRegistryErrorobject carryingiun,requestId,relatedRequestId,fiscalCode, andreceiverType. - Persists the error and transitions status to
NATIONAL_REGISTRY_ERROR. - Schedules a re-drive via
PrepareFlowStarter.redrivePreparePhaseOneAfterNationalRegistryError(payload, attempt).
Configuration
| Property | Description | Example |
|---|---|---|
pn.paper-channel.client-national-registries-basepath | Base URL of the National Registries service | http://localhost:1080 |
pn.paper-channel.national-registry-cx-id | Client identity header sent on every request | pn-paper-channel |
pn.paper-channel.queue-national-registries | SQS queue name for incoming address callbacks | local-ext-channels-inputs |
pn.paper-channel.attempt-queue-national-registries | Max consumer retry attempts on the inbound queue | 3 |
Error handling
| Exception / Status | Cause | Behaviour |
|---|---|---|
NATIONAL_REGISTRY_LISTENER_EXCEPTION | Error processing the inbound SQS callback | Logged; exception propagated to the queue consumer |
NATIONAL_REGISTRY_ADDRESS_NOT_FOUND | National Registries confirms no address exists for the fiscal code | Prepare flow terminates with an unreachable-address outcome |
NATIONAL_REGISTRY_ERROR (status) | HTTP error from the synchronous finderAddress call | Error is persisted and re-drive is attempted |
WebClientResponseException | Non-2xx HTTP response | Response body is logged at ERROR level; exception re-emitted |
The
correlationId stored on the delivery request is the key used to correlate the asynchronous SQS callback with the original prepare request. Losing this value makes it impossible to resume the flow.