About these Java snippets
This is a working collection of Java utilities I reach for across real Spring Boot services, not academic examples. Every snippet here started life in a production codebase, got stress-tested under load, and was then trimmed down to the smallest form that still earns its keep. If you build backend APIs, batch jobs, or long-running JVM services, you will likely recognize the problems these solve.
The snippets target Java 17+ and work on modern Spring Boot (3.x). Most are framework-agnostic at the core, with a thin Spring adapter where it makes sense, so you can lift the logic into Quarkus, Micronaut, or a plain main method without a rewrite.
What's inside
- Resilience and retries: a retry executor with configurable attempts, backoff, validation predicates, and failure hooks. Cleaner than sprinkling
try/catchloops across your services. - Rate limiting: an AOP
@RateLimitannotation backed by a Token Bucket algorithm. Drop it on any Spring@RestControllerendpoint to protect downstream systems. - Configuration access: a centralized helper for reading environment variables, system properties, and Spring profiles with type-safe getters and sensible defaults.
- Number conversion: convert integers to words using the Indian numbering system (Lakhs, Crores), useful for invoice, finance, and fintech apps.
More utilities land here as I extract them from client work: observability helpers, Testcontainers base classes, outbox publishers, and small concurrency primitives. If you want to see what is coming next, the blog usually covers the deeper "why" before a snippet shows up here.
How to use them
Every snippet page shows the full source, the dependencies it needs, and a minimal usage example. Copy, paste, and adapt. The code is deliberately small so you can read it in under a minute and own it in your codebase. There is no Maven dependency to install, no version lock-in, no license ceremony. Treat it like a recipe book, not a framework.
If something breaks, is out of date, or could be simpler, the snippets are open on GitHub. Pull requests and issues are very welcome.