Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUG] Azure Service Bus Spring Cloud Stream isolated-object-mapper property #41932

Closed
3 tasks done
Sheldoras opened this issue Sep 19, 2024 · 3 comments · May be fixed by #42771
Closed
3 tasks done

[BUG] Azure Service Bus Spring Cloud Stream isolated-object-mapper property #41932

Sheldoras opened this issue Sep 19, 2024 · 3 comments · May be fixed by #42771
Assignees
Labels
azure-spring All azure-spring related issues Client This issue points to a problem in the data-plane of the library. customer-reported Issues that are reported by GitHub users external to the Azure organization. needs-team-attention Workflow: This issue needs attention from Azure service team or SDK team question The issue doesn't require a change to the product in order to be resolved. Most issues start as that
Milestone

Comments

@Sheldoras
Copy link

Describe the bug
Azure Service Bus for Spring Cloud Stream offers the property isolated-object-mapper see here which, at least from what I gather from the property description and available tests regarding this property, should enable a consumer of the library to define their own ObjectMapper to be used for the ServiceBusMessageConverter in place of a default one.

Exception or Stack Trace

2024-09-19T17:12:57.354+02:00  WARN 27448 --- [demo] [           main] s.c.a.AnnotationConfigApplicationContext : Exception encountered during context initialization - cancelling refresh attempt: org.springframework.context.ApplicationContextException: Failed to start bean 'inputBindingLifecycle'
2024-09-19T17:12:57.360+02:00  INFO 27448 --- [demo] [           main] .s.b.a.l.ConditionEvaluationReportLogger : 

Error starting ApplicationContext. To display the condition evaluation report re-run your application with 'debug' enabled.
2024-09-19T17:12:57.373+02:00 ERROR 27448 --- [demo] [           main] o.s.b.d.LoggingFailureAnalysisReporter   : 

***************************
APPLICATION FAILED TO START
***************************

Description:

Parameter 0 of method serviceBusMessageConverter in com.azure.spring.cloud.autoconfigure.implementation.servicebus.AzureServiceBusMessagingAutoConfiguration$ServiceBusTemplateConfiguration required a bean of type 'com.fasterxml.jackson.databind.ObjectMapper' that could not be found.

The following candidates were found but could not be injected:
	- User-defined bean method 'myObjectMapper' in 'ConsumerConfig'


Action:

Consider revisiting the entries above or defining a bean of type 'com.fasterxml.jackson.databind.ObjectMapper' in your configuration.

To Reproduce
Minimal setup to reproduce
Just run the application and it should fail with the error listed above.

Expected behavior
My expectation would be that when I set isolated-object-mapper to false - denoting that I do not want the isolated default to be used - but will instead provide my own ObjectMapper as Bean - this custom ObjectMapper is actually used.

Setup (please complete the following information):

  • OS: Windows
  • IDE: IntelliJ
  • Library/Libraries: Versions
  • Java version: 21
  • Frameworks: Spring Boot

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

  • Bug Description Added
  • Repro Steps Added
  • Setup information Added
@github-actions github-actions bot added azure-spring All azure-spring related issues Client This issue points to a problem in the data-plane of the library. customer-reported Issues that are reported by GitHub users external to the Azure organization. needs-team-attention Workflow: This issue needs attention from Azure service team or SDK team question The issue doesn't require a change to the product in order to be resolved. Most issues start as that labels Sep 19, 2024
Copy link

Copy link

Thank you for your feedback. Tagging and routing to the team member best able to assist.

@saragluna saragluna assigned moarychan and unassigned saragluna Sep 20, 2024
@saragluna saragluna added this to the 2024-10 milestone Sep 20, 2024
@saragluna saragluna modified the milestones: 2024-10, 2024-11 Oct 8, 2024
@moarychan
Copy link
Member

moarychan commented Nov 1, 2024

Hi @Sheldoras , thanks for using Service Bus binder!

I can reproducer this issue, the root cause is that the Spring Cloud Stream's sub application context does not contains the custom ObjectMapper bean, there're two workaround to fix it:

  1. Register your custom configuration to the sub context, add below configuration:
spring:
 cloud:
   stream:
     binders:
       my_bus:
         environment:
           spring:
             main:
               sources: com.example.demo.ConsumerConfig
  1. Share the ObjectMapper bean to sub context, add a file named src/main/resources/META-INF/shared.beans and context is the com.fasterxml.jackson.databind.ObjectMapper.

  2. (Recommend) Use a BinderCustomizer bean to customize the binder, add a below code:

@Bean
BinderCustomizer binderCustomizer() {
    return (binder, binderName) -> {
        ServiceBusMessageChannelBinder serviceBus = (ServiceBusMessageChannelBinder) binder;
        serviceBus.setMessageConverter(new ServiceBusMessageConverter(new ObjectMapper()));
    };
}

Meanwhile, a PR to add shared beans is under review.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
azure-spring All azure-spring related issues Client This issue points to a problem in the data-plane of the library. customer-reported Issues that are reported by GitHub users external to the Azure organization. needs-team-attention Workflow: This issue needs attention from Azure service team or SDK team question The issue doesn't require a change to the product in order to be resolved. Most issues start as that
Projects
Status: Done
Development

Successfully merging a pull request may close this issue.

3 participants