Untitled
@Configuration public class GcpProxyConfig { @Value("${http.proxy.host}") private String proxyHost; @Value("${http.proxy.port}") private int proxyPort; @PostConstruct public void configureProxy() { // Configure gRPC to use the proxy System.setProperty("grpc.proxy.type", "HTTP"); System.setProperty("grpc.proxy.address", proxyHost + ":" + proxyPort); // Also set java proxy properties again to ensure all layers use proxy System.setProperty("https.proxyHost", proxyHost); System.setProperty("https.proxyPort", String.valueOf(proxyPort)); System.setProperty("http.proxyHost", proxyHost); System.setProperty("http.proxyPort", String.valueOf(proxyPort)); } @Bean public TransportChannelProvider transportChannelProvider() { return InstantiatingGrpcChannelProvider.newBuilder() .build(); } @Bean @Primary public PubSubConfiguration pubSubConfiguration( TransportChannelProvider transportChannelProvider, CredentialsProvider credentialsProvider) { return new PubSubConfiguration() { @Override public TransportChannelProvider transportChannelProvider() { return transportChannelProvider; } @Override public CredentialsProvider credentialsProvider() { return credentialsProvider; } }; } }
Leave a Comment