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

Remove some meaningless jms properties #32467

Merged
merged 4 commits into from
Dec 21, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 30 additions & 0 deletions eng/code-quality-reports/src/main/resources/revapi/revapi.json
Original file line number Diff line number Diff line change
Expand Up @@ -370,6 +370,36 @@
"new": "class com\\.azure\\.messaging\\.eventhubs\\..*",
"justification": "SDK classes are allowed to be exposed by dependencies using them."
},
{
"code": "java.method.removed",
"old": "method java.lang.String com.azure.spring.cloud.autoconfigure.jms.properties.AzureServiceBusJmsProperties::getPassword()",
"justification": "Remove some meaningless jms properties"
},
{
"code": "java.method.removed",
"old": "method java.lang.String com.azure.spring.cloud.autoconfigure.jms.properties.AzureServiceBusJmsProperties::getRemoteUrl()",
"justification": "Remove some meaningless jms properties"
},
{
"code": "java.method.removed",
"old": "method java.lang.String com.azure.spring.cloud.autoconfigure.jms.properties.AzureServiceBusJmsProperties::getUsername()",
"justification": "Remove some meaningless jms properties"
},
{
"code": "java.method.removed",
"old": "method void com.azure.spring.cloud.autoconfigure.jms.properties.AzureServiceBusJmsProperties::setPassword(java.lang.String)",
"justification": "Remove some meaningless jms properties"
},
{
"code": "java.method.removed",
"old": "method void com.azure.spring.cloud.autoconfigure.jms.properties.AzureServiceBusJmsProperties::setRemoteUrl(java.lang.String)",
"justification": "Remove some meaningless jms properties"
},
{
"code": "java.method.removed",
"old": "method void com.azure.spring.cloud.autoconfigure.jms.properties.AzureServiceBusJmsProperties::setUsername(java.lang.String)",
"justification": "Remove some meaningless jms properties"
},
{
"regex": true,
"code": "java.method.numberOfParametersChanged",
Expand Down
8 changes: 8 additions & 0 deletions sdk/spring/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,13 @@
# Release History

## 4.6.0-beta.1 (Unreleased)

### Spring Cloud Azure Autoconfigure
This section includes changes in `spring-cloud-azure-autoconfigure` module.

#### Breaking Changes
- Delete properties: `spring.jms.serviebus.username`, `spring.jms.serviebus.password` and `spring.jms.serviebus.remote-uri` [#32467](https://github.com/Azure/azure-sdk-for-java/pull/32467).

## 6.0.0-beta.4 (2022-12-07)
Upgrade Spring Boot dependencies version to 3.0.0-RC2 and Spring Cloud dependencies version to 2022.0.0-RC2.

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
package com.azure.spring.cloud.autoconfigure.jms;

import com.azure.spring.cloud.autoconfigure.jms.properties.AzureServiceBusJmsProperties;
import com.azure.spring.cloud.core.implementation.connectionstring.ServiceBusConnectionString;
import org.apache.qpid.jms.policy.JmsDefaultPrefetchPolicy;
import org.springframework.util.Assert;
import org.springframework.util.StringUtils;
Expand All @@ -19,6 +20,8 @@ public class ServiceBusJmsConnectionFactoryFactory {
private final AzureServiceBusJmsProperties properties;
private final List<ServiceBusJmsConnectionFactoryCustomizer> factoryCustomizers;

private static final String AMQP_URI_FORMAT = "amqps://%s?amqp.idleTimeout=%d";

ServiceBusJmsConnectionFactoryFactory(AzureServiceBusJmsProperties properties,
List<ServiceBusJmsConnectionFactoryCustomizer> factoryCustomizers) {
Assert.notNull(properties, "Properties must not be null");
Expand Down Expand Up @@ -54,9 +57,12 @@ private <T extends ServiceBusJmsConnectionFactory> void setPrefetchPolicy(T fact
private <T extends ServiceBusJmsConnectionFactory> T createConnectionFactoryInstance(Class<T> factoryClass) {
try {
T factory;
String remoteUrl = this.properties.getRemoteUrl();
String username = this.properties.getUsername();
String password = this.properties.getPassword();
ServiceBusConnectionString serviceBusConnectionString = new ServiceBusConnectionString(properties.getConnectionString());
String host = serviceBusConnectionString.getEndpointUri().getHost();

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

if (StringUtils.hasLength(username) && StringUtils.hasLength(password)) {
factory = factoryClass.getConstructor(String.class, String.class, String.class)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@

package com.azure.spring.cloud.autoconfigure.jms.properties;

import com.azure.spring.cloud.core.implementation.connectionstring.ServiceBusConnectionString;
import org.springframework.beans.factory.InitializingBean;
import org.springframework.boot.autoconfigure.jms.JmsPoolConnectionFactoryProperties;
import org.springframework.boot.context.properties.ConfigurationProperties;
Expand All @@ -29,9 +28,6 @@ public class AzureServiceBusJmsProperties implements InitializingBean {
*/
private boolean enabled = true;

private static final String DEFAULT_REMOTE_URL = "amqp://localhost:5672";

private static final String AMQP_URI_FORMAT = "amqps://%s?amqp.idleTimeout=%d";
/**
* Connection string to connect to a Service Bus namespace.
*/
Expand All @@ -56,21 +52,6 @@ public class AzureServiceBusJmsProperties implements InitializingBean {
@NestedConfigurationProperty
private final JmsPoolConnectionFactoryProperties pool = new JmsPoolConnectionFactoryProperties();

/**
* URL of the AMQP broker. Auto-generated by default.
*/
private String remoteUrl = DEFAULT_REMOTE_URL;

/**
* Login user of the AMQP broker.
*/
private String username;

/**
* Login password of the AMQP broker.
*/
private String password;

/**
* Whether to enable Service Bus JMS autoconfiguration.
* @return Whether to enable Service Bus autoconfiguration
Expand All @@ -87,54 +68,6 @@ public void setEnabled(boolean enabled) {
this.enabled = enabled;
}

/**
* Get the URL of the AMQP broker.
* @return the URL of the AMQP broker.
*/
public String getRemoteUrl() {
return remoteUrl;
}

/**
* Set the URL of the AMQP broker.
* @param remoteUrl the URL of the AMQP broker.
*/
public void setRemoteUrl(String remoteUrl) {
this.remoteUrl = remoteUrl;
}

/**
* Get the login user of the AMQP broker.
* @return the login user of the AMQP broker.
*/
public String getUsername() {
return username;
}

/**
* Set the login user of the AMQP broker.
* @param username the login user of the AMQP broker.
*/
public void setUsername(String username) {
this.username = username;
}

/**
* Get the login password of the AMQP broker.
* @return the login password of the AMQP broker.
*/
public String getPassword() {
return password;
}

/**
* Set the login password of the AMQP broker.
* @param password the login password of the AMQP broker.
*/
public void setPassword(String password) {
this.password = password;
}

/**
* The properties for a pooled connection factory.
* @return the properties for a pooled connection factory.
Expand Down Expand Up @@ -237,13 +170,6 @@ public void afterPropertiesSet() throws Exception {
if (null == pricingTier || !pricingTier.matches("(?i)premium|standard|basic")) {
throw new IllegalArgumentException("'spring.jms.servicebus.pricing-tier' is not valid");
}

ServiceBusConnectionString serviceBusConnectionString = new ServiceBusConnectionString(connectionString);
String host = serviceBusConnectionString.getEndpointUri().getHost();

this.remoteUrl = String.format(AMQP_URI_FORMAT, host, idleTimeout.toMillis());
this.username = serviceBusConnectionString.getSharedAccessKeyName();
this.password = serviceBusConnectionString.getSharedAccessKey();
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
import org.junit.jupiter.params.provider.NullAndEmptySource;
import org.junit.jupiter.params.provider.ValueSource;

import static org.assertj.core.api.Assertions.assertThat;
import static org.junit.jupiter.api.Assertions.assertThrows;
import static org.junit.jupiter.api.Assertions.assertTrue;

Expand Down Expand Up @@ -45,15 +44,4 @@ void pricingTierNotValid(String pricingTier) {
assertTrue(actualMessage.contains(expectedMessage));
}

@ParameterizedTest
@ValueSource(strings = { "basic", "standard", "premium" })
void setConnectionStringFormatCorrect(String pricingTier) throws Exception {
AzureServiceBusJmsProperties prop = new AzureServiceBusJmsProperties();
prop.setConnectionString(CONNECTION_STRING);
prop.setPricingTier(pricingTier);
prop.afterPropertiesSet();
assertThat(prop.getUsername()).isEqualTo("sasKeyName");
assertThat(prop.getPassword()).isEqualTo("sasKey");
assertThat(prop.getRemoteUrl()).isEqualTo("amqps://host?amqp.idleTimeout=1800000");
}
}