Skip to content

Support passwordless connections for JMS ServiceBus in Spring#33489

Merged
backwind1233 merged 32 commits into
Azure:mainfrom
backwind1233:passwordless_jms
Mar 3, 2023
Merged

Support passwordless connections for JMS ServiceBus in Spring#33489
backwind1233 merged 32 commits into
Azure:mainfrom
backwind1233:passwordless_jms

Conversation

@backwind1233

@backwind1233 backwind1233 commented Feb 14, 2023

Copy link
Copy Markdown
Contributor

Description

Linked issue: #32463

The PR is an implementation to support passwordless connections for JMS ServiceBus in Spring.

Test locally

  1. Test Redis Passwordless ✅
  2. Test Jdbc-MySQL Passwordless ✅
  3. Test Jdbc-Postgre Passwordless ✅
  4. Test JMS Passwordless ✅
  5. Test Kafka Passwordless ✅

IT

pipeline: java - spring - tests ✅
pipeline: java - spring - tests-weekly ✅

@ghost ghost added the azure-spring All azure-spring related issues label Feb 14, 2023
@backwind1233 backwind1233 self-assigned this Feb 14, 2023
@azure-sdk

azure-sdk commented Feb 14, 2023

Copy link
Copy Markdown
Collaborator

API change check

APIView has identified API level changes in this PR and created following API reviews.

spring-cloud-azure-autoconfigure
spring-cloud-azure-core
spring-cloud-azure-service

@backwind1233

Copy link
Copy Markdown
Contributor Author

/azp run java - spring - tests

@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines successfully started running 1 pipeline(s).

@backwind1233 backwind1233 changed the title Support JMS ServiceBus passwordless connections Support passwordless connections for JMS ServiceBus in Spring Feb 14, 2023
@backwind1233 backwind1233 marked this pull request as ready for review February 14, 2023 09:36
@backwind1233

Copy link
Copy Markdown
Contributor Author

The resource scopes in ServiceBus is the same for different Clouds: "https://servicebus.azure.net/.default".

*
* @since 4.7.0
*/
public class AzureServiceBusCredentialSupplier implements Supplier<String> {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
public class AzureServiceBusCredentialSupplier implements Supplier<String> {
public class AzureServiceBusJmsCredentialSupplier implements Supplier<String> {

?

String remoteUrl = String.format(AMQP_URI_FORMAT, host, properties.getIdleTimeout().toMillis());
String username = serviceBusConnectionString.getSharedAccessKeyName();
String password = serviceBusConnectionString.getSharedAccessKey();
String remoteUrl = null;

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The ServiceBusJmsConnectionFactory shouldn't need to understand the serviceBusPasswordlessProperties

@backwind1233 backwind1233 Feb 15, 2023

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have refactored the code, I provided a ServiceConnectionStringProvider, but it's a little strange for me now. Maybe we can discuss about it.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ServiceConnectionStringProvider is not the best choice.

Comment on lines +18 to +45
@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.NONE)
@ActiveProfiles("servicebus-jms-passwordless")
public class ServiceBusJmsPasswordlessIT {
private static final Logger LOGGER = LoggerFactory.getLogger(ServiceBusJmsPasswordlessIT.class);
private static final String DATA = "service bus jms passwordless test";
private static final String QUEUE_NAME = "que001";
private final Exchanger<String> EXCHANGER = new Exchanger<>();

@Autowired
private JmsTemplate jmsTemplate;

@Test
@Timeout(70)
public void testServiceBusJmsOperation() throws InterruptedException {
LOGGER.info("ServiceBusJmsPasswordlessIT begin.");
jmsTemplate.convertAndSend(QUEUE_NAME, DATA);
LOGGER.info("Send message: {}", DATA);
String msg = EXCHANGER.exchange(null);
Assertions.assertEquals(DATA, msg);
LOGGER.info("ServiceBusJmsPasswordlessIT end.");
}

@JmsListener(destination = QUEUE_NAME, containerFactory = "jmsListenerContainerFactory")
public void receiveQueueMessage(String message) throws InterruptedException {
LOGGER.info("Received message from queue: {}", message);
EXCHANGER.exchange(message);
}
}

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No need of the public

@backwind1233

Copy link
Copy Markdown
Contributor Author

/azp run java - spring - tests

@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines successfully started running 1 pipeline(s).

@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines successfully started running 1 pipeline(s).

@backwind1233

Copy link
Copy Markdown
Contributor Author

/azp run java - spring - tests

@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines successfully started running 1 pipeline(s).

@backwind1233

Copy link
Copy Markdown
Contributor Author

/azp run java - spring - tests

@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines successfully started running 1 pipeline(s).

@backwind1233

Copy link
Copy Markdown
Contributor Author

/azp run java - spring - tests

@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines successfully started running 1 pipeline(s).

@backwind1233

Copy link
Copy Markdown
Contributor Author

/azp run java - spring - tests

@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines successfully started running 1 pipeline(s).

@azure-pipelines

Copy link
Copy Markdown
No pipelines are associated with this pull request.

1 similar comment
@azure-pipelines

Copy link
Copy Markdown
No pipelines are associated with this pull request.

@backwind1233

Copy link
Copy Markdown
Contributor Author

/azp run java - spring - tests-weekly

@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines successfully started running 1 pipeline(s).

@backwind1233

Copy link
Copy Markdown
Contributor Author

pipeline: java - spring - tests ✅
pipeline: java - spring - tests-weekly

@backwind1233 backwind1233 merged commit 0aa7f47 into Azure:main Mar 3, 2023
saragluna pushed a commit to saragluna/azure-sdk-for-java that referenced this pull request Jun 26, 2023
…33489)

Support passwordless connections for JMS ServiceBus in Spring.
saragluna added a commit that referenced this pull request Jun 26, 2023
* Support passwordless connections for JMS ServiceBus in Spring (#33489)
* fix differences in two versions
---------

Co-authored-by: zhihaoguo <zhihaoguo@microsoft.com>
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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants