Moving from Spring Boot 2ZipkinSleuth to Spring Boot 3Micrometer: Equivalent of TraceableExecutorService - Stack Overflow

admin2025-04-28  2

We are migrating a Spring Boot 2 + Sleuth/Zipkin app to Spring Boot 3 + Micrometer/Zipkin.

import java.util.concurrent.ExecutorService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.BeanFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cloud.sleuth.instrument.async.TraceableExecutorService;
import org.springframework.stereotype.Service;

@Service
@Slf4j
public class ConnectorService implements Connector {

    protected final BankService bankService;
    protected final ExecutorService executorService;

    @Autowired
    public ConnectorService(BankService bankService, BeanFactory beanFactory) {
        this.bankService = bankService;
        this.executorService = new TraceableExecutorService(beanFactory, new ContextAwareThreadPoolExecutor());
    }

    @Override
    public void notifyOnPaymentStatusChange(Payment payment) {
        executorService.execute(() -> {
            try {
                bankService.notifyOnPaymentStatusChange(payment);
            } catch (RuntimeException e) {
                log.error("Error message goes here" + e);
            }
        });
    }

}

Is there an equivalent mechanism provided by Spring Boot 3 to replace org.springframework.cloud.sleuth.instrument.async.TraceableExecutorService?

转载请注明原文地址:http://anycun.com/QandA/1745852580a91238.html