I'm trying to set up a very basic proof of concept to link a Spring application to an Azure Event Hub. I keep getting this log in my startup:
[2021-11-17 16:49:18.343 ERROR 25816 --- [ main] o.s.cloud.stream.binding.BindingService : Failed to create consumer binding; retrying in 30 seconds
...
Caused by: java.lang.IllegalArgumentException: Cannot use a proxy when TransportType is not AMQP Web Sockets.
at com.azure.messaging.eventhubs.EventHubClientBuilder.getConnectionOptions(EventHubClientBuilder.java:764) ~[azure-messaging-eventhubs-5.10.2.jar:5.10.2]
at com.azure.messaging.eventhubs.EventHubClientBuilder.buildConnectionProcessor(EventHubClientBuilder.java:705) ~[azure-messaging-eventhubs-5.10.2.jar:5.10.2]
at com.azure.messaging.eventhubs.EventHubClientBuilder.buildAsyncClient(EventHubClientBuilder.java:638) ~[azure-messaging-eventhubs-5.10.2.jar:5.10.2]
at com.azure.messaging.eventhubs.EventProcessorClient.<init>(EventProcessorClient.java:89) ~[azure-messaging-eventhubs-5.10.2.jar:5.10.2]
at com.azure.messaging.eventhubs.EventProcessorClientBuilder.buildEventProcessorClient(EventProcessorClientBuilder.java:585) ~[azure-messaging-eventhubs-5.10.2.jar:5.10.2]
...
This is despite the fact that I defined beans for EventHubProducerAsyncClient, EventHubConsumerAsyncClient, and EventProcessorClient that explicitly set the transport type to AMQP_WEB_SOCKETS
. See here:
Producer:
@Bean
public EventHubProducerAsyncClient eventHubProducerAsyncClient() {
return new EventHubClientBuilder()
.connectionString(connectionString)
.proxyOptions(new ProxyOptions(
ProxyAuthenticationType.NONE,
new Proxy(Proxy.Type.HTTP, new InetSocketAddress("my proxy address", 8080)),
null, null
))
.transportType(AmqpTransportType.AMQP_WEB_SOCKETS)
.buildAsyncProducerClient();
}
Consumer:
@Bean
public EventHubConsumerAsyncClient eventHubConsumerAsyncClient() {
return new EventHubClientBuilder()
.connectionString(connectionString)
.proxyOptions(new ProxyOptions(
ProxyAuthenticationType.NONE,
new Proxy(Proxy.Type.HTTP, new InetSocketAddress("my proxy address", 8080)),
null, null
))
.transportType(AmqpTransportType.AMQP_WEB_SOCKETS)
.consumerGroup(DEFAULT_CONSUMER_GROUP_NAME)
.buildAsyncConsumerClient();
}
EventProcessor:
private static void onEvent(EventContext eventContext) {
PartitionContext partition = eventContext.getPartitionContext();
LOGGER.info("Received events from partition: " + partition.getPartitionId());
EventData event = eventContext.getEventData();
LOGGER.info("Sequence number: " + event.getSequenceNumber());
LOGGER.info("Contents: " + new String(event.getBody(), StandardCharsets.UTF_8));
}
@Bean
public EventProcessorClient eventProcessorClient() {
BlobContainerAsyncClient blobClient = new BlobContainerClientBuilder()
.connectionString(storageConnectionString)
.containerName(storageContainerName)
.buildAsyncClient();
return new EventProcessorClientBuilder()
.connectionString(connectionString)
.consumerGroup(DEFAULT_CONSUMER_GROUP_NAME)
.checkpointStore(new BlobCheckpointStore(blobClient))
.processEvent(eventContext -> onEvent(eventContext))
.processError(context -> {
LOGGER.error("Error occurred on partition: %s. Error: %s%n",
context.getPartitionContext().getPartitionId(), context.getThrowable());
})
.processPartitionInitialization(initializationContext -> {
LOGGER.info("Started receiving on partition: %s%n",
initializationContext.getPartitionContext().getPartitionId());
})
.processPartitionClose(closeContext -> {
LOGGER.info("Stopped receiving on partition: %s. Reason: %s%n",
closeContext.getPartitionContext().getPartitionId(),
closeContext.getCloseReason());
})
.proxyOptions(new ProxyOptions(
ProxyAuthenticationType.NONE,
new Proxy(Proxy.Type.HTTP, new InetSocketAddress("my proxy address", 8080)),
null, null
))
.transportType(AmqpTransportType.AMQP_WEB_SOCKETS)
.buildEventProcessorClient();
}
Am I missing something obvious here? I don't understand how it can complain about TransportType not being AMQP Web Sockets when its explicitly defined.