惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

人人都是产品经理
人人都是产品经理
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
月光博客
月光博客
雷峰网
雷峰网
Google DeepMind News
Google DeepMind News
Y
Y Combinator Blog
Microsoft Security Blog
Microsoft Security Blog
M
MIT News - Artificial intelligence
WordPress大学
WordPress大学
MongoDB | Blog
MongoDB | Blog
V
V2EX
博客园 - 【当耐特】
GbyAI
GbyAI
Stack Overflow Blog
Stack Overflow Blog
I
InfoQ
Martin Fowler
Martin Fowler
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
Hugging Face - Blog
Hugging Face - Blog
B
Blog
V
Visual Studio Blog
D
DataBreaches.Net
C
Check Point Blog
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
F
Fortinet All Blogs

DEV Community

Authentication Security Deep Dive: From Brute Force to Salted Hashing (With Java Examples) Why AI Systems Don’t Fail — They Drift Spilling beans for how i learn for exam😁"Reinforcement Learning Cheat Sheet" I Replaced Chrome with Safari for AI Browser Automation. Here's What Broke (and What Finally Worked) How Python Borrows Other People's Work The $40 Architecture: Processing 1 Billion API Requests with 99.99% Uptime Vibe Coding: A Workflow Guide (From Zero to SaaS) Most webhook security guides protect the wrong side. The scary part is delivery. Headless CMS for TanStack Start: Build a Blog with Cosmic EU Age Verification App "Hacked in 2 Minutes" — What Actually Happened Comfy Cloud’s delete function does not actually remove files Running AI Models on GPU Cloud Servers: A Beginner Guide Event-driven media intelligence with AWS Step Functions and Bedrock I scored 500 AI prompts across 8 quality dimensions — here's what broke How to Call Google Gemini API from Next.js (Free Tier, No Backend Needed) The Portal Protocol: Reclaiming Human Connection in the Age of AI How to Fix Your Team's Scattered Knowledge Problem With a Self-Hosted Forum Intro to tc Cloud Functors: A Graph-First Mental Model for the Modern Cloud Designing Multi-Tenant Backends With Both Ownership and Team Access I Built a Neumorphic CSS Library with 77+ Components — Here's What I Learned PostgreSQL Performance Optimization: Why Connection Pooling Is Critical at Scale Cómo construí un SaaS multi-rubro para gestionar expensas en Argentina con FastAPI + Vue 3 🚀 I Built an Ethical Hacking Scanner Tool – Open Source Project I Replaced /usage and /context in Claude Code With a Single Statusline A Pythonic Way to Handle Emails (IMAP/SMTP) with Auto-Discovery and AI-Ready Design I Collected 8.9 Million Polymarket Price Points — Here's What I Found About How Markets Really Move EcoTrack AI — Carbon Footprint Tracker & Dashboard Everyone's Using AI. No One Agrees How. 5 self-hosted ebook managers worth trying in 2026 Building Your First AI Agent with LangChain: From Chatbot to Autonomous Assistant
Building an Order Processing Pipeline with Spring Integra...
Praveen Yadav · 2026-06-24 · via DEV Community

Praveen Yadav

If you’ve used Spring Boot REST APIs but haven’t explored Spring Integration yet, this project is a practical way to see what message-driven flow design looks like in real code.

I built a sample app that processes orders from two different entry points:

  1. HTTP API (POST /api/orders)
  2. File polling (drop CSV files into input/)

Both inputs share the same core processing logic.

👉 Source code: https://github.com/ykpraveen/spring-integration-sample


What this project does

Each order goes through this pipeline:

  1. Transform input payload into Order
  2. Validate (id, customer, total)
  3. Route by amount:
    • total <= 100 → EXPRESS
    • total > 100 → REVIEW
  4. Persist order (JPA)
  5. Fan out to:
    • archive output file
    • summary aggregation

Runtime persistence uses PostgreSQL, and tests use H2.


Tech stack

  • Java 21
  • Spring Boot 4.1
  • Spring Integration 7 (Java DSL)
  • Spring Data JPA
  • PostgreSQL (runtime)
  • H2 (test)
  • Maven

Architecture at a glance

1) HTTP flow

POST /api/orders sends raw JSON to a messaging gateway, then:

  • JsonToOrderTransformer
  • OrderValidationService
  • content-based router (EXPRESS / REVIEW)
  • OrderStore.put(...)
  • publish-subscribe to archive + summary + HTTP response message

2) File flow

The poller watches input/*.csv, then:

  • FileToStringTransformer
  • CsvToOrderTransformer
  • validation + routing + persistence
  • publish-subscribe to archive + summary

3) Error handling

  • HTTP errors return JSON via dedicated HTTP error handling.
  • File processing errors generate failure logs in output/failed/ and move bad source files to input/failed/.

Why Spring Integration here?

Using Spring Integration made these parts clean and explicit:

  • Routing rules are declarative.
  • Fan-out behavior is easy with publish-subscribe channels.
  • Retry advice can be attached per handler in the file pipeline.
  • The integration graph (/api/integration/graph) helps visualize the runtime flow.

Example requests

Submit an EXPRESS order

curl -X POST http://localhost:8080/api/orders \
  -H "Content-Type: application/json" \
  -d '{"id":"ORD-001","customer":"Alice","description":"Book","total":25.00}'

Submit a REVIEW order

curl -X POST http://localhost:8080/api/orders \
  -H "Content-Type: application/json" \
  -d '{"id":"ORD-002","customer":"Bob","description":"Laptop","total":1500.00}'

Get one order

curl http://localhost:8080/api/orders/ORD-001

List all orders

curl http://localhost:8080/api/orders


Running locally

Clone the repo first:

git clone https://github.com/ykpraveen/spring-integration-sample.git
cd spring-integration-sample

Then run:

docker compose up -d
mvn clean package
mvn spring-boot:run

Then test HTTP endpoints or drop a CSV file into input/.


Testing

The project currently has 38 tests (unit + integration), covering:

  • transformation and validation
  • HTTP happy paths and failure paths
  • duplicate order handling (409 Conflict)
  • file poller processing and retries
  • summary aggregation behavior
  • integration graph endpoint

You can run these directly from the repo: https://github.com/ykpraveen/spring-integration-sample


Key implementation details I found useful

  1. Use correlation IDs in headers and push them into MDC for traceable logs across flow steps.
  2. Keep config split by concern (HttpIntegrationConfig, FileIntegrationConfig, shared config) instead of one huge integration config class.
  3. Treat summary aggregation as stateful logic: clear release rules (batch size vs timeout), stable keys, and append-safe file writing.
  4. Prefer explicit web path-variable lookup for GET /api/orders/{id} over indirect URL parsing.

Repo

You can clone the project and run it as a demo starter for:

  • Spring Integration basics
  • event/message-driven service design in Spring
  • hybrid ingestion patterns (HTTP + file)

If you’re learning Spring Integration, this pattern is a good stepping stone before Kafka/Rabbit-based distributed flows.

GitHub: https://github.com/ykpraveen/spring-integration-sample