-
Notifications
You must be signed in to change notification settings - Fork 2.1k
Add unit test for CachingConnectionFactory producer/consumer reuse and update azure-servicebus-jms to 2.1.0 #47282
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
Merged
+107
−4
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
…nFactory behavior Verify that when using CachingConnectionFactory mode, producer and consumer caching is properly configured for reusing MessageProducer and MessageConsumer instances for the same destination. Test covers both standard and premium pricing tiers. Co-authored-by: Netyyyy <92105726+Netyyyy@users.noreply.github.com>
Copilot
AI
changed the title
[WIP] Add unit test for Spring Cloud Azure Service Bus JMS
Add unit test for CachingConnectionFactory producer/consumer reuse in Spring Cloud Azure Service Bus JMS
Nov 14, 2025
Copilot finished work on behalf of
Netyyyy
November 14, 2025 09:26
Copilot finished reviewing on behalf of
Netyyyy
November 24, 2025 02:32
- Updated azure-servicebus-jms version from 2.0.0 to 2.1.0 in: - eng/versioning/external_dependencies.txt - sdk/spring/spring-cloud-azure-autoconfigure/pom.xml - sdk/spring/spring-cloud-azure-starter-servicebus-jms/pom.xml - Simplified test code per review feedback: - Removed unnecessary blank lines - Simplified bean retrieval by getting CachingConnectionFactory directly - Removed unused imports - Test verifies that CachingConnectionFactory caches producers/consumers for the same destination when configured with appropriate properties Co-authored-by: Netyyyy <92105726+Netyyyy@users.noreply.github.com>
Copilot
AI
changed the title
Add unit test for CachingConnectionFactory producer/consumer reuse in Spring Cloud Azure Service Bus JMS
Add unit test for CachingConnectionFactory producer/consumer reuse and update azure-servicebus-jms to 2.1.0
Dec 1, 2025
Copilot finished work on behalf of
Netyyyy
December 1, 2025 09:10
Added new test method cachingConnectionFactoryReusesSameProducerForSameDestination that: - Demonstrates the same producer is returned for the same destination (queue1) - Demonstrates a different producer is returned for different destinations (queue2) - Uses Mockito.verify to prove createProducer is only called once per destination, confirming the caching behavior Co-authored-by: Netyyyy <92105726+Netyyyy@users.noreply.github.com>
- Use statically imported verify and times instead of fully qualified names - Improve comment formatting for better readability Co-authored-by: Netyyyy <92105726+Netyyyy@users.noreply.github.com>
Copilot finished work on behalf of
Netyyyy
December 2, 2025 01:34
…tion caching The test now demonstrates the specific fix in azure-servicebus-jms 2.1.0: - In 2.0.0, each Queue instance had unique toString() like "ServiceBusJmsQueue@11655" which prevented CachingConnectionFactory from caching producers for the same queue - In 2.1.0, toString() returns the queue name, enabling proper caching Test verifies that: - Multiple Queue instances with same toString() value use cached producer - Different Queue instances with different toString() values use different producers - Mockito.verify confirms createProducer is only called once for same-named queues Co-authored-by: Netyyyy <92105726+Netyyyy@users.noreply.github.com>
Copilot finished work on behalf of
Netyyyy
December 2, 2025 06:07
Added new test cachingConnectionFactoryFailsToReuseProducerWithUniqueToString that demonstrates the bug in azure-servicebus-jms 2.0.0 where each Queue instance had a unique toString() like "ServiceBusJmsQueue@11655", which prevented CachingConnectionFactory from caching producers for the same queue name. The test verifies that: - When toString() returns unique values, createProducer is called twice - Different producers are returned even for the same queue name - This contrasts with the fixed 2.1.0 behavior where toString() returns the queue name, enabling proper caching Co-authored-by: Netyyyy <92105726+Netyyyy@users.noreply.github.com>
Copilot finished work on behalf of
Netyyyy
December 2, 2025 06:27
Updated tests to use actual ServiceBusJmsQueue instances instead of mocked Queue: - Added test serviceBusJmsQueueToStringReturnsConsistentValueForSameQueueName that verifies ServiceBusJmsQueue.toString() returns consistent values for the same queue name (the key fix in azure-servicebus-jms 2.1.0) - Updated cachingConnectionFactoryReusesSameProducerForSameDestination to use ServiceBusJmsQueue instances via reflection - This test would fail with azure-servicebus-jms 2.0.0 because toString() returned unique values like "ServiceBusJmsQueue@hashcode" Co-authored-by: Netyyyy <92105726+Netyyyy@users.noreply.github.com>
Copilot finished work on behalf of
Netyyyy
December 2, 2025 07:01
Copilot finished reviewing on behalf of
Netyyyy
December 3, 2025 01:01
rujche
reviewed
Dec 3, 2025
rujche
approved these changes
Dec 3, 2025
Member
rujche
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM.
Member
|
/check-enforcer override |
Netyyyy
approved these changes
Dec 3, 2025
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description
Adds a unit test verifying that Spring Cloud Azure Service Bus JMS correctly configures
CachingConnectionFactoryto cache and reuseMessageProducerinstances for the same destination. Also updates theazure-servicebus-jmsdependency to version 2.1.0.Changes
New test:
cachingConnectionFactoryReusesSameProducerForSameDestinationinServiceBusJmsConnectionFactoryConfigurationTestsServiceBusJmsSession.createQueue()to create actualServiceBusJmsQueueinstanceswhen(mockInnerSession.createProducer(any(Destination.class)))to mock producer creation, returning different producers for each callServiceBusJmsQueueinstances with the same queue name (demonstrating caching works)assertThat(producer1ForQueue1.toString()).isEqualTo(producer2ForQueue1.toString())becauseServiceBusJmsQueue.toString()returned unique values like "ServiceBusJmsQueue@hashcode", preventingCachingConnectionFactoryfrom caching producerstoString()returns consistent values based on queue name, enabling proper cachingDependency update: Updated
azure-servicebus-jmsfrom 2.0.0 to 2.1.0 in:eng/versioning/external_dependencies.txtsdk/spring/spring-cloud-azure-autoconfigure/pom.xmlsdk/spring/spring-cloud-azure-starter-servicebus-jms/pom.xmlThe test ensures Spring Framework's
CachingConnectionFactorywill cache producers as documented in CachingConnectionFactory.java#L362. The key fix in azure-servicebus-jms 2.1.0 is thatServiceBusJmsQueue.toString()now returns the queue name, enabling proper caching (in 2.0.0, it returned unique values like "ServiceBusJmsQueue@11655" which prevented caching).Fixes #47281
All SDK Contribution checklist:
General Guidelines and Best Practices
Testing Guidelines
Original prompt
💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.