Untitled
unknown
plain_text
a year ago
1.8 kB
7
Indexable
import com.google.api.gax.core.FixedCredentialsProvider;
import com.google.api.gax.grpc.GrpcTransportChannel;
import com.google.api.gax.rpc.TransportChannelProvider;
import com.google.cloud.pubsub.v1.SubscriptionAdminSettings;
import com.google.pubsub.v1.SubscriptionName;
import io.grpc.ManagedChannelBuilder;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.beans.factory.annotation.Value;
@Configuration
public class PubSubConfig {
@Value("${proxy.host}")
private String proxyHost;
@Value("${proxy.port}")
private int proxyPort;
@Bean
public TransportChannelProvider channelProvider() {
return GrpcTransportChannel.newBuilder()
.setManagedChannelBuilder(
ManagedChannelBuilder.forTarget("pubsub.googleapis.com")
.proxyDetector(address -> {
return io.grpc.ProxyParameters.newBuilder()
.setType(io.grpc.ProxyParameters.ProxyType.HTTP)
.setProxyAddress(new InetSocketAddress(proxyHost, proxyPort))
.build();
})
.build())
.build();
}
@Bean
public SubscriptionAdminSettings subscriptionAdminSettings(
TransportChannelProvider channelProvider,
CredentialsProvider credentialsProvider) throws IOException {
return SubscriptionAdminSettings.newBuilder()
.setTransportChannelProvider(channelProvider)
.setCredentialsProvider(credentialsProvider)
.build();
}
}Editor is loading...
Leave a Comment