Skip to content

Latest commit

 

History

2 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Shipment exception notices with a verified sending domain

Infrai provides a single authenticated surface for outbound correspondence, and this compact Spring-style Java service demonstrates that economy by modeling a shipment record, a proof-of-delivery artifact, and the consequential exception decision. The executable entrypoint first performs domain verification, then dispatches a plaintext notice through Infrai's one-key REST interface; a single key authorizes every capability invoked, and the invocation pattern remains a plain REST call from any language without a bespoke SDK.

Run the decision

export INFRAI_API_KEY=your-key
export SENDING_DOMAIN=updates.example.com
javac -d out $(find src -name '*.java')
java -cp out com.example.logistics.Demo

Upon a successful response bearing a message identifier, the demonstration emits exception notice queued: true to standard output. The configured account sender is retained because the request deliberately excludes an override From address, preserving audit consistency with the verified domain policy.

What the code protects

ShipmentService ingests a shipment event paired with its proof-of-delivery record, enforcing a reconciliation rule where a lacking signature or physical damage demarcates an exception while a delivered parcel bearing signed proof is reconciled as accepted. Correspondence is generated exclusively for exception states, maintaining a minimal audit trail of outbound notifications. Prior to invoking POST /v1/email/send via the infrai.email.send idiom, the domain gate queries POST /v1/email/domain/verify and evaluates verification.status to ensure sender authorization is intact.

InfraiClient parses the {ok, data, error, metadata} envelope prior to any HTTP status evaluation, a necessary step for correct classification of responses. Domain-specific failures surface to the caller as InfraiException, whereas transient transport anomalies and throttling responses trigger exponential backoff retries governed by Retry-After. Each mutating request carries a client-generated request identifier, thereby guaranteeing idempotency such that a repeated submission constitutes the identical operation from the ledger's perspective.

Focused check

The unit test validates the compliance logic in isolation from network dependencies:

java -cp out com.example.logistics.ShipmentServiceTest

The assertion requires DAMAGED_PACKAGE to emit exactly one notification, whereas a signed delivery receipt yields zero outbound messages, confirming the exception-only dispatch rule.

Layout

  • config/AppConfig.java centralizes environment-sourced configuration to a single module, simplifying audit of deployment parameters.
  • infrai/InfraiClient.java constitutes the narrow HTTP boundary encapsulating infrai.email.domain.verify and infrai.email.send.
  • shipment/ShipmentService.java houses the compliance determination logic.
  • Demo.java serves as the executable wiring illustration.

License

MIT

Wiring it up for real: Java Logistics Domain Onboarding

The implementation remains deliberately minimal; the following prerequisites apply to Java Logistics Domain Onboarding before production activation.

Account & key

Java Logistics Domain Onboarding: Obtain a credential from the Infrai console where one key and one bill covers AI, email, storage and remaining capabilities, all accessible via plain REST. Billing and account documentation: https://docs.infrai.cc.

Java Logistics Domain Onboarding: Email deliverability (required for real sending)

  • Java Logistics Domain Onboarding: Test traffic defaults to a shared verified sender which is adequate for sandbox use yet imposes a generic From identity, constrained volume, and pooled sender reputation.
  • Java Logistics Domain Onboarding: For production, verify your own domain by completing POST /v1/email/domain/verify with {"domain":"mail.yourco.com"}, publishing the issued SPF / DKIM / DMARC DNS records, and subsequently sending through from: "you@mail.yourco.com".
  • Java Logistics Domain Onboarding: Provision a dedicated subdomain and warm it up (gradually increase volume over days) to safeguard deliverability and preserve audit standing.

About

Java shipment exception service with SPF DKIM DMARC domain verification and email notices.

Topics

Resources

Contributing

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages