在 Http Inbound Spring 集成中获取远程 IP 的最佳方式

Best way to get Remote IP in Http Inbound Spring Integration

如何在 spring 集成(Http Inbound)中获取远程 IP。 我已经搜索过堆栈溢出,我无法将答案与我想要实现的目标联系起来。

    @Bean
    public IntegrationFlow inquiry(IntegrationFlow outboundGateway){
        return IntegrationFlows.from(Http.inboundGateway("/inquiry")
                .errorChannel("errorChannel")
                .requestPayloadType(String.class)
                .requestMapping(m -> m.methods(HttpMethod.POST)))
                .wireTap(Loggers.REQUEST_LOGGER_CHANNEL)
                .handle((p,h)->{
                    log.info("REMOTE IP: {}",...)
                    return p;
                })
                .transform(Transformers.fromJson(PayloadDTO.class))
                ...;
    }
log.info("REMOTE IP: {}", 
         ((ServletRequestAttributes) RequestContextHolder.currentRequestAttributes()).getRequest().getRemoteAddr()) 

另请参阅:https://mkyong.com/java/how-to-get-client-ip-address-in-java/