← Back to blog
SpringBoot13 min read

Spring Boot 4.2 Upgrade Guide for Payment Services

Spring Boot 4.2 upgrade guide for payment services: AMQP 1.0 vs Kafka, OpenTelemetry metric renames, forwarded headers, and a staged canary rollback plan.

Illustration of a Spring Boot 4.2 upgrade for payment services, showing message queues, a metrics dashboard, a Kubernetes ingress and a staged canary rollout

To move a payment service from Spring Boot 4.1 to 4.2 safely, bump the version and nothing else. Keep AMQP 1.0 and the OpenTelemetry naming switch off, test forwarded headers behind your real ingress, then canary and widen in stages. Upgrades like this seldom hurt because of compile errors. They hurt when a latency panel goes empty during a settlement run, when every audit row shows the ingress pod's IP, or when new pods take ten extra seconds to turn Ready and the autoscaler falls behind. The rest of this post is the plan I intend to follow for those cases on 4.1 to 4.2.

A caveat about status. I have not yet run this upgrade on a production service, so there are no 4.2 benchmark numbers here. The 19 November 2026 GA date and the feature list came to me through a secondary summary, and the official 4.2 reference pages I could open still said "in development". I flag each unconfirmed detail where it appears, and every config snippet below is something to verify against your own build.

Out of scope: the RestTemplate deprecation (covered in the RestTemplate to RestClient migration post), the Kafka dead-letter queue work, and the Pulsar deprecation. Pulsar users should read the release notes directly.

What changes in 4.2 that can hurt a payment service

Four items from the release summary deserve review. They carry different kinds of risk, so they get different handling:

  1. AMQP 1.0 support. New starters let Boot talk to brokers over AMQP 1.0. Risk: an architecture decision, and none if you leave it unused.
  2. OpenTelemetry naming for metrics. An opt-in switch that renames HTTP metrics and their tags. Risk: dashboards and alerts that fail silently.
  3. Forwarded headers. How the app derives client IP and scheme from X-Forwarded-For, X-Forwarded-Proto and Forwarded behind an ingress. Risk: wrong audit data or spoofable addresses.
  4. Faster executable-jar startup, plus a Cloud Native Buildpacks base image on Ubuntu 26.04. Risk: low, and it gives you scale-out headroom if you measure it properly.

Diagram of a staged Spring Boot 4.2 rollout on Kubernetes, covering canary traffic, metric dual-write, forwarded-header checks and rollback

Part 1: AMQP 1.0 versus Kafka for payment flows

The release material lists two AMQP 1.0 starters: a generic one built on the Qpid ProtonJ2 client, and a RabbitMQ-focused one, spring-boot-starter-amqp-rabbitmq, which sits next to the older RabbitMQ starter. I could not confirm the exact artifact names or how they relate to the legacy starter in the official reference. A dependency block should therefore be treated as a draft until you have checked the coordinates:

<!-- pom.xml: draft only, confirm artifactId against the 4.2 release notes -->
<dependency>
  <groupId>org.springframework.boot</groupId>
  <artifactId>spring-boot-starter-amqp-rabbitmq</artifactId>
</dependency>

The part I can speak to is the design question, which came up repeatedly at AirAsia scale (roughly 130 million requests a day) and in PSD2 open banking API work: is this message an event or a command?

  • An event records a fact: payment settled, mandate created. Several consumers may want it, some join late, and replaying history has value. That fits Kafka's retained, ordered log.
  • A command asks for one action, once: send this SMS, call this scheme, release this hold. One worker takes it and acknowledges it, and on failure the broker retries or parks it. That fits a queue, and AMQP brokers do queues well.

I have watched teams push commands through Kafka and then hand-build queue behaviour: retry counters in headers, delay topics, and one slow message blocking everything behind it in a partition. Kafka share groups soften that. A broker designed around queues is the other route, and AMQP 1.0 is how Spring now reaches one.

How I split payment traffic:

FlowPickWhy
Payment lifecycle events, audit trail, reconciliation feedsKafkaReplay and per-key ordering matter
Outbound notifications, one-off scheme calls, back-office tasksAMQP 1.0 queuePer-message ack, redelivery, broker-side dead-lettering
Anything that must look exactly-onceEither, plus an idempotent consumerNo transport gives you this

The last row holds on both transports, because a message can arrive twice. The consumer must absorb the duplicate; the transactional outbox and idempotent consumers write-up shows the pattern I use on both sides.

Generic or RabbitMQ-specific starter? With RabbitMQ already in the estate, I would take the RabbitMQ-specific starter, since your operators already know its management UI and queue arguments. The generic starter makes sense if you must stay portable across brokers and are prepared to stick to the standard feature set.

For this upgrade, do not introduce AMQP in the same release as the version bump. With two changes in one deploy, you cannot tell which one caused an incident.

Part 2: OpenTelemetry conventions will move your metric names

If you carry the pager, spend your review time here. The release summary describes a single opt-in property, roughly:

# application.yml
management:
  observations:
    conventions: open-telemetry   # per the summary; confirm the property in the 4.2 reference

I have not verified that property path against the official reference, and the summary may simplify it. What matters is the behaviour: the default stays as it was, so upgrading with no config change alters nothing. The danger comes later, when someone flips it in a config-only change that looks harmless and a week of green dashboards turns grey.

The conventions decide metric and tag names. A Spring service on the current defaults exports HTTP server timing as http.server.requests, which Prometheus shows as http_server_requests_seconds_*, with tags uri, method, status and outcome. The OpenTelemetry HTTP convention calls the server timer http.server.request.duration, with attributes http.request.method, http.response.status_code and http.route. Those names come from the OpenTelemetry specification, not from the Boot 4.2 reference, so scrape a running 4.2 instance with the switch on and read the real output. Prometheus also converts dots to underscores and appends unit suffixes, so the final series name differs once more.

This is how the same p95 query would change, assuming the usual Prometheus exporter conversion (check against your scrape):

# before
histogram_quantile(0.95,
  sum by (le) (rate(http_server_requests_seconds_bucket{uri="/payments"}[5m])))

# after (expected shape, confirm on your own /actuator/prometheus output)
histogram_quantile(0.95,
  sum by (le) (rate(http_server_request_duration_seconds_bucket{http_route="/payments"}[5m])))

Everything that queries the old names fails quietly:

  • An SLO on the old bucket series returns no data, and many alert rules read "no data" as healthy.
  • Alerts like status=~"5.." stop matching, because the label is now http_response_status_code.
  • Recording rules, Grafana template variables and capacity reports inherit the same hole.

I went through this exercise when the OpenTelemetry Java agent changed its names. The checklist in my Java agent 3.0 migration post carries over, and tracing is covered in distributed tracing with OpenTelemetry in production.

The dual-write window

You do not have to pick one naming scheme. During a dual-write window the old names keep paging you while you build and verify the new dashboards. I do not know of one Boot property that emits both sets, so I would do it in Prometheus, which needs no application code and rolls back by deleting a file. Recording rules publish the new-style series from the old data, so a panel can be switched and compared like for like:

# prometheus-rules.yml
groups:
  - name: http-dual-write
    rules:
      - record: job:http_server_request_duration_seconds_count:rate5m
        expr: sum by (job, http_route) (
                label_replace(rate(http_server_requests_seconds_count[5m]),
                              "http_route", "$1", "uri", "(.*)"))

Once the app really emits the new series, you compare the two for the same traffic and only then re-point alerts. Doing the mirroring in the application with a custom Micrometer observation handler is possible, but I would avoid it: you must read the elapsed time from the observation yourself, and tagging http.route with raw paths instead of route templates blows up series cardinality and your Prometheus bill.

Close the window on an exit condition, never a calendar date. Mine: two full billing cycles, one incident review, and every alert re-pointed and test-fired.

Part 3: Forwarded headers behind a Kubernetes ingress

The brief I was working from says forwarded-header handling was redesigned between RC2 and GA. I could not find a source stating what changed, and I will not invent a diff. Below is the stable background, followed by a test that works whatever the change was.

The long-standing property:

server:
  forward-headers-strategy: native   # or framework, or none
  • none ignores forwarded headers.
  • native lets the embedded server handle them. In Tomcat that is the RemoteIpValve, which only honours headers from proxies matching its internalProxies pattern, by default private ranges. On Kubernetes, pod CIDRs are often private, so "internal" can be wider than you intended.
  • framework has Spring's ForwardedHeaderFilter handle them. That filter does not know which hop is trusted, so something in front, such as Envoy or NGINX ingress, must strip inbound X-Forwarded-* from the outside world.

Concrete failure modes I would test for:

  • Spoofing. With framework and an ingress that appends to X-Forwarded-For rather than overwriting it, a caller sends X-Forwarded-For: 10.0.0.5 and your fraud scorer or IP allow-list reads the fake leftmost value.
  • Ignored headers. With none, or native and a proxy outside the trusted range, every request shows the ingress pod's address. Per-client rate limits become a single global limit, and the audit log stores cluster-internal IPs. Under PSD2-style audit rules that is a compliance defect.
  • Scheme loss. TLS terminates at the ingress, the app sees http, and redirects and generated links point to the wrong scheme.

I wrote about neighbouring exposure in the Spring Boot 4.1 SSRF mitigation post.

The routine I run on any version bump:

  1. Read the 4.2 release notes and the "Running Behind a Front-end Proxy Server" section for your exact version, then compare the property names with your application.yml. Search the startup log for deprecated and ignored.
  2. Deploy 4.2 to a test namespace behind the same ingress class and gateway as production.
  3. Send one request from outside carrying a spoofed X-Forwarded-For, and one clean request through the front door. Log getRemoteAddr(), the scheme and the generated absolute URL for each.
  4. Confirm the spoofed value is not trusted and the real client address is visible.
  5. Check a redirect and its Location header. The summary mentions a Tomcat relative-redirect default change, and that interacts with scheme handling behind a TLS-terminating proxy.

A mocked-request integration test makes the next upgrade repeat this for free:

@SpringBootTest
@AutoConfigureMockMvc
class ForwardedHeadersIT {

  @Autowired MockMvc mvc;

  @Test
  void spoofedHeaderFromUntrustedHopIsNotTrusted() throws Exception {
    mvc.perform(get("/debug/client")
            .with(r -> { r.setRemoteAddr("203.0.113.9"); return r; })
            .header("X-Forwarded-For", "10.0.0.5"))
       .andExpect(jsonPath("$.clientIp").value("203.0.113.9"));
  }
}

(/debug/client is a test-only endpoint of mine that echoes the resolved address; you must add your own.) If steps 3 to 5 behave exactly as on 4.1, the redesign cost you nothing. If they differ, you found out in a test namespace, not in a fraud report.

Part 4: Startup gains, measured properly

The summary reports faster class loading for executable jars, and the buildpack base moves to Ubuntu 26.04. I will not quote a speedup because I have no 4.2 numbers of my own and will not borrow anyone else's. What I can offer is the method.

Three timings matter:

  • Cold start: container start to "application started". Read it from the startup log, and also take wall-clock from pod Scheduled to Ready, since image pull and JVM warm-up fall outside that log line.
  • Readiness lag: from "started" to the first passing readiness probe. A large initialDelaySeconds hides the whole gain.
  • Scale-out latency: from the Horizontal Pod Autoscaler (HPA) adding a replica to that pod taking traffic. This one protects you in a settlement-window spike.
# 30 runs per version, same node pool; repeat once with the image cached and once on a cold node
for i in $(seq 1 30); do
  kubectl rollout restart deploy/payments-api -n perf
  kubectl rollout status deploy/payments-api -n perf --timeout=180s
  kubectl get pod -l app=payments-api -n perf \
    -o jsonpath='{.items[0].status.conditions[?(@.type=="Ready")].lastTransitionTime}{"\n"}'
done

Compare the median and the 95th percentile instead of the mean. A new base image changes layer sizes, so pull time can move either way. Check memory too: a limit that was tight on 4.1 may need a second look. My piece on virtual threads in Spring Boot production covers how I size pods when thread behaviour changes.

Retune in this order: readiness probe delays, HPA stabilisation windows, then replica minimums. Cutting minimum replicas because "it starts faster now" is the one mistake I would avoid on a payment path. Treat faster start as extra margin, never as a reason to remove it.

Part 5: The staged rollout

Zero-downtime database work taught me the shape: expand, verify, contract (zero-downtime database migrations with Flyway). A framework bump follows the same logic.

StageActionExit condition
0. PrepareBe on the latest 4.1.x patch. Build 4.2 in CI and read the warnings. Leave AMQP and the OTel switch off.Clean build, no unexplained deprecation warnings
1. Staging soakDeploy to a production-like namespace with the real ingress. Run forwarded-header and contract tests.Header tests match 4.1, no new error classes in logs
2. Canary, 1 to 5 percentRoute a small weighted slice. Compare error rate, p95 latency and consumer lag with the stable pods.24 hours across a peak, no divergence
3. Dual-write preparedBuild new-name dashboards and alert rules beside the old ones. The old names stay the paging source.New panels match the old for the same traffic
4. Widen25, 50, then 100 percent, pausing at each step through a business peak.Same checks at every step
5. Convention switchEnable the OTel naming switch in its own release, canary first. Page from the new names after the window.Every alert test-fired against new series
6. ContractDelete old dashboards and the mirror rules. Tighten probes and HPA from measured data.Written sign-off, runbook updated
7. OptionalAdd one AMQP 1.0 queue for one command flow, in a separate change.Its own canary

The naming switch sits at stage 5 on purpose: it is the one change I would never ship in the same release as the version bump.

A weighted canary can be as plain as two Deployments behind one Service plus an NGINX ingress canary annotation:

# canary ingress (ingress-nginx)
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
  name: payments-api-canary
  annotations:
    nginx.ingress.kubernetes.io/canary: "true"
    nginx.ingress.kubernetes.io/canary-weight: "5"
spec:
  ingressClassName: nginx
  rules:
    - host: api.example.com
      http:
        paths:
          - path: /
            pathType: Prefix
            backend:
              service:
                name: payments-api-42
                port: { number: 8080 }

Rollback plan

Write it before you start, and rehearse it once.

  • Image: keep the previous 4.1.x tag pinned and deployable, so kubectl rollout undo takes minutes and needs no rebuild.
  • Config: put each new property in its own config map key so the convention switch reverts without touching the binary.
  • Data compatibility: confirm 4.2 writes nothing 4.1 cannot read. Serialized sessions, cached objects and message payloads are the usual culprits, and a changed Jackson default can make a post-widening rollback choke on data the new version wrote.
  • Triggers: decide the numbers before the canary begins, for example error rate above baseline by a fixed margin for ten minutes. Deciding mid-incident turns into an argument.
  • Messaging: if you added an AMQP queue, rolling back the app leaves messages in the broker. Drain or park them on purpose.

For how I keep several live systems steady at once, see my experience; I run live market-data and trading components next to payment work, and the same discipline applies. The replay side is in deterministic market-data replay with QuestDB, where replay lets me test a change before it meets real money.

What I would do on Monday

Three steps, in order. Run your service on 4.2 in a throwaway namespace and read the startup log for deprecation and ignored-property warnings. List every alert and SLO that queries an HTTP or JVM metric by name; that list is your OpenTelemetry migration scope even if you never flip the switch this quarter. Then push one spoofed and one genuine forwarded-header request through your real ingress and record what the app sees. If you want a second opinion on a payment-service upgrade plan, get in touch and send me your rollout table.

Related Articles