azure-sdk-for-java icon indicating copy to clipboard operation
azure-sdk-for-java copied to clipboard

spring.cloud.azure.servicebus.producer.entity-type not working

Open fredysierra opened this issue 1 year ago • 6 comments

Query/Question We were moving from spring-cloud-azure-stream-binder-servicebus version 5.5.0 to 5.8.0. We found that this version now requires to specify for each consumer or producer the entity-type. Otherwise, In the logs I can see:

org.springframework.cloud.stream.binder.BinderException: Exception thrown while starting consumer: 
	at org.springframework.cloud.stream.binder.AbstractMessageChannelBinder.doBindConsumer(AbstractMessageChannelBinder.java:582) ~[spring-cloud-stream-4.0.4.jar:4.0.4]
	at org.springframework.cloud.stream.binder.AbstractMessageChannelBinder.doBindConsumer(AbstractMessageChannelBinder.java:102) ~[spring-cloud-stream-4.0.4.jar:4.0.4]
	at org.springframework.cloud.stream.binder.AbstractBinder.bindConsumer(AbstractBinder.java:144) ~[spring-cloud-stream-4.0.4.jar:4.0.4]
	at org.springframework.cloud.stream.binding.BindingService.lambda$rescheduleConsumerBinding$1(BindingService.java:211) ~[spring-cloud-stream-4.0.4.jar:4.0.4]
	at org.springframework.scheduling.support.DelegatingErrorHandlingRunnable.run(DelegatingErrorHandlingRunnable.java:54) ~[spring-context-6.0.12.jar:6.0.12]
	at java.base/java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:539) ~[na:na]
	at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264) ~[na:na]
	at java.base/java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:304) ~[na:na]
	at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1136) ~[na:na]
	at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:635) ~[na:na]
	at java.base/java.lang.Thread.run(Thread.java:833) ~[na:na]
Caused by: java.lang.IllegalArgumentException: The EntityType of the consumer can't be null.
	at org.springframework.util.Assert.notNull(Assert.java:204) ~[spring-core-6.0.12.jar:6.0.12]
	at com.azure.spring.cloud.stream.binder.servicebus.implementation.provisioning.ServiceBusChannelResourceManagerProvisioner.provisionConsumerDestination(ServiceBusChannelResourceManagerProvisioner.java:66) ~[spring-cloud-azure-stream-binder-servicebus-5.8.0.jar:5.8.0]
	at com.azure.spring.cloud.stream.binder.servicebus.implementation.provisioning.ServiceBusChannelResourceManagerProvisioner.provisionConsumerDestination(ServiceBusChannelResourceManagerProvisioner.java:29) ~[spring-cloud-azure-stream-binder-servicebus-5.8.0.jar:5.8.0]
	at org.springframework.cloud.stream.binder.AbstractMessageChannelBinder.doBindConsumer(AbstractMessageChannelBinder.java:512) ~[spring-cloud-stream-4.0.4.jar:4.0.4]
	... 10 common frames omitted

This is for us a big inconvenience as we have a large number of producers and consumers.

We tried to use the properties spring.cloud.azure.servicebus.producer.entity-type and spring.cloud.azure.servicebus.consumer.entity-type as documented here hoping these properties will apply in a generic way and save us to specify the property per producer and consumer. That did not happen.

Why spring.cloud.azure.servicebus.producer.entity-type and spring.cloud.azure.servicebus.consumer.entity-type do not work as documented? are there any other alternatives to avoid specify entity-type per consumer or producer?

Setup:

  • spring-cloud-azure-stream-binder-servicebus:5.8.0
  • Spring Boot 3.1.4
  • Spring Cloud 2022.0.4

Simple app: To reproduce use my entity-type_issue branch. https://github.com/fredysierra/scs-service-bus/tree/entity-type_issue

Information Checklist Kindly make sure that you have added all the following information above and checkoff the required fields otherwise we will treat the issuer as an incomplete report

  • [x] Query Added
  • [x] Setup information Added

fredysierra avatar Feb 14 '24 17:02 fredysierra

@saragluna could you please help route @fredysierra's issue

joshfree avatar Feb 15 '24 18:02 joshfree

Hi @fredysierra , thanks for reaching out, we will take a look

Netyyyy avatar Feb 19 '24 02:02 Netyyyy

Hi @fredysierra , sorry for the inconvenience, spring.cloud.azure.servicebus.producer.entity-type and spring.cloud.azure.servicebus.consumer.entity-type doesn't work for bindings, please use spring.cloud.stream.servicebus.bindings.<binding-name>.consumer.entity-type or spring.cloud.stream.servicebus.bindings.<binding-name>.producer.entity-type instead, see Spring Cloud Stream support for more info.

If you use ARM to connect, it's necessary to configure each consumer or producer clearly, it's by design for provision resources and here is a sample. Or you use other way such connection-string, only need to configure entity-type for producer.

Netyyyy avatar Feb 21 '24 08:02 Netyyyy

Hi @fredysierra. Thank you for opening this issue and giving us the opportunity to assist. To help our team better understand your issue and the details of your scenario please provide a response to the question asked above or the information requested above. This will help us more accurately address your issue.

github-actions[bot] avatar Feb 23 '24 02:02 github-actions[bot]

Hi @fredysierra , sorry for the inconvenience, spring.cloud.azure.servicebus.producer.entity-type and spring.cloud.azure.servicebus.consumer.entity-type doesn't work for bindings, please use spring.cloud.stream.servicebus.bindings.<binding-name>.consumer.entity-type or spring.cloud.stream.servicebus.bindings.<binding-name>.producer.entity-type instead, see Spring Cloud Stream support for more info.

If you use ARM to connect, it's necessary to configure each consumer or producer clearly, it's by design for provision resources and here is a sample. Or you use other way such connection-string, only need to configure entity-type for producer.

Thank you so much for your answer. Considering this is a breaking change, it is frustrating that it was introduced in a minor upgrade version. As I mentioned to you, specifying entity-type per binder is a big inconvenience as we have a large number of producers and consumers in our product and our clients can define their own.

fredysierra avatar Feb 23 '24 12:02 fredysierra

Hi @fredysierra , it's an enhancement because in the past, it won't check if the entity-type is null https://github.com/Azure/azure-sdk-for-java/blob/ceef37471a23c8db576620ea9cf8a8cff03807cc/sdk/spring/spring-cloud-azure-stream-binder-servicebus/src/main/java/com/azure/spring/cloud/stream/binder/servicebus/provisioning/ServiceBusChannelResourceManagerProvisioner.java#L66 and add this code to make sure user can configure the entity-type correctly. As for the second question, @saragluna should we add a new feature for configuring one entity-type and all consumers and producers can use it?

Netyyyy avatar Feb 27 '24 01:02 Netyyyy

Sorry for the inconvenience, @fredysierra. Could you help share your configuration file? Setting on the producer/consumer is actually an intuitive way.

saragluna avatar Mar 01 '24 11:03 saragluna

@saragluna we know that adding this entity-type property is not hard. Our problem is the scale of this. We have many different services on our platform, and our clients can define their own services. For us and them, this would be a huge inconvenience. For now, we are looking into options to hack this. (adding the property dynamically ). However, it would be really important for us to have a property that defines the entity-type by default.

fredysierra avatar Mar 01 '24 12:03 fredysierra

@fredysierra may I ask whether you are using the ServiceBus binder to provison your queue or topic?

saragluna avatar Mar 13 '24 03:03 saragluna

yes @saragluna We do use the binder to provision those.

fredysierra avatar Mar 13 '24 11:03 fredysierra

@fredysierra we'll try to fix this.

saragluna avatar Mar 14 '24 08:03 saragluna

Will fix it by enabling the default value by setting "spring.cloud.stream.servicebus.default.producer|consumer.xxx", which will be picked up as the default value of "spring.cloud.stream.servicebus.bindings.<channel-name>.producer|consumer.xxx".

saragluna avatar Mar 20 '24 11:03 saragluna

Fixed in Spring Cloud Azure 5.11/4.17

Netyyyy avatar Apr 08 '24 01:04 Netyyyy