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

Support passwordless connections for JMS ServiceBus in Spring #33489

Merged
merged 32 commits into from
Mar 3, 2023

Conversation

backwind1233
Copy link
Contributor

@backwind1233 backwind1233 commented Feb 14, 2023

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
Copy link
Collaborator

azure-sdk commented Feb 14, 2023

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
Contributor Author

/azp run java - spring - tests

@azure-pipelines
Copy link

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
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
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
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

Copy link
Contributor Author

@backwind1233 backwind1233 Feb 15, 2023

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
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
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
Contributor Author

/azp run java - spring - tests

@azure-pipelines
Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@azure-pipelines
Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@backwind1233
Copy link
Contributor Author

/azp run java - spring - tests

@azure-pipelines
Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@backwind1233
Copy link
Contributor Author

/azp run java - spring - tests

@azure-pipelines
Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@backwind1233
Copy link
Contributor Author

/azp run java - spring - tests

@azure-pipelines
Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@backwind1233
Copy link
Contributor Author

/azp run java - spring - tests

@azure-pipelines
Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@azure-pipelines
Copy link

No pipelines are associated with this pull request.

1 similar comment
@azure-pipelines
Copy link

No pipelines are associated with this pull request.

@backwind1233
Copy link
Contributor Author

/azp run java - spring - tests-weekly

@azure-pipelines
Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@backwind1233
Copy link
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