spring-cloud-gateway icon indicating copy to clipboard operation
spring-cloud-gateway copied to clipboard

Spring Cloud gateway mvc, virtual threads and threadlocal

Open she43 opened this issue 2 years ago • 1 comments

With the new spring cloud gateway mvc, and virtual threads enabled - how do i pass use threadlocal information for a single virtual thread? My ask is i want to store the logging id which is unique per request. If mvc handles each request in seperate virtual thread - how do i maintain the context of the virtual thread and where?

she43 avatar Jan 19 '24 20:01 she43

I might not fully understand your question, but, as I see in my project on Java 21 and MVC gateway, the context and tracing are passed from the MVC gateway to all the called microservices.

NiiazKhan avatar Feb 18 '24 19:02 NiiazKhan

None of this is specific to spring cloud gateway and I don't have any particular knowledge of the combination of virtual threads, org.slf4j.MDC and thread locals.

This stackoverflow looks promising https://stackoverflow.com/questions/77937111/utilizing-logging-mdc-with-virtual-threads

spencergibb avatar Mar 11 '24 20:03 spencergibb