A runnable Spring Boot application that demonstrates all springtainer embedded test containers working together in one coherent example, and serves as an internal testing ground for the springtainer maintainers when verifying larger changes (so they don't have to reach for an unrelated downstream application).
A minimal "Product" flow ties every container together in one realistic path:
POST /products— persists the product in MySQL (springtainer-mysql), indexes it into Elasticsearch (springtainer-elasticsearch), caches it in Redis (springtainer-redis), and publishes aProductCreatedEventvia RabbitMQ (springtainer-rabbitmq).- A
@RabbitListenerreceives that event (demonstrating RabbitMQ consumption), writes an audit-log entry to MongoDB (springtainer-mongodb), calls an external enrichment endpoint mocked via MockServer (springtainer-mockserver), and uploads the result as a report to AWS S3 Mock (springtainer-awss3mock). GET /products/{id}— reads through the Redis cache, falling back to MySQL on a miss.GET /products/search?q=...— full-text search via Elasticsearch.GET /products/{id}/audit-log— reads the audit trail from MongoDB.GET /products/{id}/report— downloads the generated report from AWS S3 Mock.
All seven containers start automatically as soon as the application context comes up - no external infrastructure or Docker Compose file needed.
mvn spring-boot:run
Or, after mvn clean install, run the packaged executable jar directly (note the -exec classifier - the plain springtainer-example.jar is the non-executable artifact used internally by the IT tests):
java -jar target/springtainer-example-exec.jar
Then, once the containers have started (watch the log for ...-container started lines):
curl -X POST localhost:8080/products \
-H "Content-Type: application/json" \
-d '{"name":"Demo Chair","description":"A comfortable chair","price":49.99}'
curl localhost:8080/products/1
curl "localhost:8080/products/search?q=Demo"
curl localhost:8080/products/1/audit-log
curl localhost:8080/products/1/report
The audit-log and report endpoints are populated asynchronously by the RabbitMQ listener - if they return nothing immediately after creating a product, wait a moment and retry.
mvn clean install
Runs the full ProductFlowIT end-to-end test, which exercises every container in a single flow and is the reference point for verifying that changes to any springtainer-* module still work correctly together.
| springtainer module | Used by |
|---|---|
springtainer-mysql |
ProductRepository |
springtainer-elasticsearch |
ProductSearchService |
springtainer-redis |
ProductCacheService |
springtainer-rabbitmq |
ProductEventPublisher / ProductEventListener |
springtainer-mongodb |
AuditLogRepository / AuditLogService |
springtainer-mockserver |
EnrichmentClient / EnrichmentMockSetup |
springtainer-awss3mock |
ReportStorageService |