Skip to content

Commit

Permalink
Rename properties and binder name for eventhubs binder (#25430)
Browse files Browse the repository at this point in the history
* rename event hubs binder name and properties prefix from eventhub to eventhubs, and refactor some classes names accordingly. Also, this pr remove the duplicate EventHubProvisioner
  • Loading branch information
saragluna authored Nov 16, 2021
1 parent a73bd73 commit c7d49d7
Show file tree
Hide file tree
Showing 102 changed files with 752 additions and 770 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -492,7 +492,7 @@ the main ServiceBusClientBuilder. -->
<suppress checks="com.azure.tools.checkstyle.checks.EnforceFinalFieldsCheck" files="com.azure.spring.messaging.container.AbstractListenerContainer.java"/>
<suppress checks="com.azure.tools.checkstyle.checks.EnforceFinalFieldsCheck" files="ServiceBusTopicBinderConfiguration.java"/>
<suppress checks="com.azure.tools.checkstyle.checks.EnforceFinalFieldsCheck" files="ServiceBusQueueBinderConfiguration.java"/>
<suppress checks="com.azure.tools.checkstyle.checks.EnforceFinalFieldsCheck" files="com.azure.spring.cloud.stream.binder.eventhubs.config.EventHubBinderConfiguration.java"/>
<suppress checks="com.azure.tools.checkstyle.checks.EnforceFinalFieldsCheck" files="com.azure.spring.cloud.stream.binder.eventhubs.config.EventHubsBinderConfiguration.java"/>

<suppress checks="com.azure.tools.checkstyle.checks.EnforceFinalFieldsCheck" files="com.azure.spring.cloud.autoconfigure.keyvault.env.KeyVaultOperation.java"/>
<suppress checks="com.azure.tools.checkstyle.checks.EnforceFinalFieldsCheck" files="com.azure.spring.cloud.autoconfigure.data.cosmos.CosmosDataAutoConfiguration.java"/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
import com.azure.messaging.eventhubs.EventHubClientBuilder;
import com.azure.messaging.eventhubs.EventHubConsumerAsyncClient;
import com.azure.messaging.eventhubs.EventHubProducerAsyncClient;
import com.azure.spring.cloud.actuate.eventhubs.EventHubHealthIndicator;
import com.azure.spring.cloud.autoconfigure.eventhubs.AzureEventHubAutoConfiguration;
import com.azure.spring.cloud.actuate.eventhubs.EventHubsHealthIndicator;
import com.azure.spring.cloud.autoconfigure.eventhubs.AzureEventHubsAutoConfiguration;
import org.springframework.beans.factory.ObjectProvider;
import org.springframework.boot.actuate.autoconfigure.health.ConditionalOnEnabledHealthIndicator;
import org.springframework.boot.actuate.health.HealthIndicator;
Expand All @@ -22,17 +22,17 @@
*/
@Configuration
@ConditionalOnClass({ EventHubClientBuilder.class, HealthIndicator.class })
@AutoConfigureAfter(AzureEventHubAutoConfiguration.class)
public class EventHubHealthConfiguration {
@AutoConfigureAfter(AzureEventHubsAutoConfiguration.class)
public class EventHubsHealthConfiguration {

@Bean
@ConditionalOnBean(EventHubClientBuilder.class)
@ConditionalOnEnabledHealthIndicator("azure-eventhub")
public EventHubHealthIndicator eventHubHealthIndicator(
public EventHubsHealthIndicator eventHubsHealthIndicator(
ObjectProvider<EventHubProducerAsyncClient> producerAsyncClients,
ObjectProvider<EventHubConsumerAsyncClient> consumerAsyncClients) {

return new EventHubHealthIndicator(producerAsyncClients.getIfAvailable(),
return new EventHubsHealthIndicator(producerAsyncClients.getIfAvailable(),
consumerAsyncClients.getIfAvailable());
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
org.springframework.boot.autoconfigure.EnableAutoConfiguration=\
com.azure.spring.cloud.actuate.autoconfigure.cosmos.CosmosHealthConfiguration,\
com.azure.spring.cloud.actuate.autoconfigure.eventhubs.EventHubHealthConfiguration,\
com.azure.spring.cloud.actuate.autoconfigure.eventhubs.EventHubsHealthConfiguration,\
com.azure.spring.cloud.actuate.autoconfigure.keyvault.KeyVaultHealthConfiguration,\
com.azure.spring.cloud.actuate.autoconfigure.storage.StorageBlobHealthConfiguration,\
com.azure.spring.cloud.actuate.autoconfigure.storage.StorageFileHealthConfiguration,\
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@
import java.time.Duration;

/**
* Health indicator for Event Hubs.
* Health indicator for Azure Event Hubs.
*/
public class EventHubHealthIndicator implements HealthIndicator {
public class EventHubsHealthIndicator implements HealthIndicator {

private static final int DEFAULT_TIMEOUT = 30;

Expand All @@ -22,8 +22,8 @@ public class EventHubHealthIndicator implements HealthIndicator {

private int timeout = DEFAULT_TIMEOUT;

public EventHubHealthIndicator(EventHubProducerAsyncClient producerAsyncClient,
EventHubConsumerAsyncClient consumerAsyncClient) {
public EventHubsHealthIndicator(EventHubProducerAsyncClient producerAsyncClient,
EventHubConsumerAsyncClient consumerAsyncClient) {
this.producerAsyncClient = producerAsyncClient;
this.consumerAsyncClient = consumerAsyncClient;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

import com.azure.messaging.eventhubs.EventHubClientBuilder;
import com.azure.messaging.eventhubs.checkpointstore.blob.BlobCheckpointStore;
import com.azure.spring.cloud.autoconfigure.eventhubs.properties.AzureEventHubProperties;
import com.azure.spring.cloud.autoconfigure.eventhubs.properties.AzureEventHubsProperties;
import com.azure.spring.service.storage.blob.BlobServiceClientBuilderFactory;
import com.azure.storage.blob.BlobContainerAsyncClient;
import org.slf4j.Logger;
Expand Down Expand Up @@ -39,12 +39,12 @@ public class AzureBlobCheckpointStoreConfiguration {
public BlobCheckpointStore blobCheckpointStore(
@Qualifier(EVENT_HUB_PROCESSOR_CHECKPOINT_STORE_STORAGE_CLIENT_BUILDER_FACTORY_BEAN_NAME)
BlobServiceClientBuilderFactory factory,
AzureEventHubProperties eventHubProperties,
AzureEventHubsProperties eventHubsProperties,
ObjectProvider<BlobCheckpointStoreContainerInitializer> initializers) {
final BlobContainerAsyncClient blobContainerAsyncClient = factory
.build()
.buildAsyncClient()
.getBlobContainerAsyncClient(eventHubProperties.getProcessor().getCheckpointStore().getContainerName());
.getBlobContainerAsyncClient(eventHubsProperties.getProcessor().getCheckpointStore().getContainerName());

initializers.ifAvailable(initializer -> initializer.init(blobContainerAsyncClient));

Expand All @@ -65,17 +65,18 @@ public BlobCheckpointStoreContainerInitializer blobCheckpointStoreContainerIniti

@Bean(EVENT_HUB_PROCESSOR_CHECKPOINT_STORE_STORAGE_CLIENT_BUILDER_FACTORY_BEAN_NAME)
@ConditionalOnMissingBean(name = EVENT_HUB_PROCESSOR_CHECKPOINT_STORE_STORAGE_CLIENT_BUILDER_FACTORY_BEAN_NAME)
public BlobServiceClientBuilderFactory eventHubProcessorBlobServiceClientBuilderFactory(AzureEventHubProperties eventHubProperties) {
return new BlobServiceClientBuilderFactory(getCheckpointStoreProperties(eventHubProperties));
public BlobServiceClientBuilderFactory eventHubProcessorBlobServiceClientBuilderFactory(
AzureEventHubsProperties eventHubsProperties) {
return new BlobServiceClientBuilderFactory(getCheckpointStoreProperties(eventHubsProperties));
}

private AzureEventHubProperties.Processor.BlobCheckpointStore getCheckpointStoreProperties(
AzureEventHubProperties ehProperties) {
private AzureEventHubsProperties.Processor.BlobCheckpointStore getCheckpointStoreProperties(
AzureEventHubsProperties ehProperties) {

AzureEventHubProperties.Processor.BlobCheckpointStore result = new AzureEventHubProperties.Processor
AzureEventHubsProperties.Processor.BlobCheckpointStore result = new AzureEventHubsProperties.Processor
.BlobCheckpointStore();
AzureEventHubProperties.Processor.BlobCheckpointStore csProperties = ehProperties.getProcessor()
.getCheckpointStore();
AzureEventHubsProperties.Processor.BlobCheckpointStore csProperties = ehProperties.getProcessor()
.getCheckpointStore();

mergeAzureCommonProperties(ehProperties, csProperties, result);
BeanUtils.copyProperties(csProperties, result);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
import com.azure.messaging.eventhubs.EventHubClientBuilder;
import com.azure.spring.cloud.autoconfigure.AzureServiceConfigurationBase;
import com.azure.spring.cloud.autoconfigure.condition.ConditionalOnAnyProperty;
import com.azure.spring.cloud.autoconfigure.eventhubs.properties.AzureEventHubProperties;
import com.azure.spring.cloud.autoconfigure.eventhubs.properties.AzureEventHubsProperties;
import com.azure.spring.cloud.autoconfigure.properties.AzureGlobalProperties;
import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
Expand All @@ -22,22 +22,22 @@
@ConditionalOnProperty(value = "spring.cloud.azure.eventhubs.enabled", havingValue = "true", matchIfMissing = true)
@ConditionalOnAnyProperty(prefix = "spring.cloud.azure.eventhubs", name = { "connection-string", "namespace" })
@Import({
AzureEventHubClientBuilderConfiguration.class,
AzureEventHubConsumerClientConfiguration.class,
AzureEventHubProducerClientConfiguration.class,
AzureEventHubsClientBuilderConfiguration.class,
AzureEventHubsConsumerClientConfiguration.class,
AzureEventHubsProducerClientConfiguration.class,
AzureBlobCheckpointStoreConfiguration.class,
AzureEventProcessorClientConfiguration.class
AzureEventHubsProcessorClientConfiguration.class
})
public class AzureEventHubAutoConfiguration extends AzureServiceConfigurationBase {
public class AzureEventHubsAutoConfiguration extends AzureServiceConfigurationBase {

public AzureEventHubAutoConfiguration(AzureGlobalProperties azureGlobalProperties) {
public AzureEventHubsAutoConfiguration(AzureGlobalProperties azureGlobalProperties) {
super(azureGlobalProperties);
}

@Bean
@ConfigurationProperties(AzureEventHubProperties.PREFIX)
public AzureEventHubProperties azureEventHubProperties() {
return loadProperties(this.azureGlobalProperties, new AzureEventHubProperties());
@ConfigurationProperties(AzureEventHubsProperties.PREFIX)
public AzureEventHubsProperties azureEventHubsProperties() {
return loadProperties(this.azureGlobalProperties, new AzureEventHubsProperties());
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

import com.azure.messaging.eventhubs.EventHubClientBuilder;
import com.azure.spring.cloud.autoconfigure.condition.ConditionalOnAnyProperty;
import com.azure.spring.cloud.autoconfigure.eventhubs.properties.AzureEventHubProperties;
import com.azure.spring.cloud.autoconfigure.eventhubs.properties.AzureEventHubsProperties;
import com.azure.spring.core.AzureSpringIdentifier;
import com.azure.spring.core.connectionstring.ConnectionStringProvider;
import com.azure.spring.core.connectionstring.StaticConnectionStringProvider;
Expand All @@ -24,7 +24,7 @@
@Configuration(proxyBeanMethods = false)
@ConditionalOnAnyProperty(prefix = "spring.cloud.azure.eventhubs", name = { "connection-string", "namespace" })
@ConditionalOnProperty(prefix = "spring.cloud.azure.eventhubs", name = "event-hub-name")
class AzureEventHubClientBuilderConfiguration {
class AzureEventHubsClientBuilderConfiguration {

@Bean
@ConditionalOnMissingBean
Expand All @@ -34,8 +34,8 @@ public EventHubClientBuilder eventHubClientBuilder(EventHubClientBuilderFactory

@Bean
@ConditionalOnMissingBean
public EventHubClientBuilderFactory eventHubClientBuilderFactory(AzureEventHubProperties properties,
ObjectProvider<ConnectionStringProvider<AzureServiceType.EventHub>> connectionStringProviders) {
public EventHubClientBuilderFactory eventHubClientBuilderFactory(AzureEventHubsProperties properties,
ObjectProvider<ConnectionStringProvider<AzureServiceType.EventHubs>> connectionStringProviders) {
final EventHubClientBuilderFactory builderFactory = new EventHubClientBuilderFactory(properties);

builderFactory.setConnectionStringProvider(connectionStringProviders.getIfAvailable());
Expand All @@ -45,10 +45,10 @@ public EventHubClientBuilderFactory eventHubClientBuilderFactory(AzureEventHubPr

@Bean
@ConditionalOnProperty("spring.cloud.azure.eventhubs.connection-string")
public StaticConnectionStringProvider<AzureServiceType.EventHub> eventHubStaticConnectionStringProvider(
AzureEventHubProperties eventHubProperties) {
return new StaticConnectionStringProvider<>(AzureServiceType.EVENT_HUB,
eventHubProperties.getConnectionString());
public StaticConnectionStringProvider<AzureServiceType.EventHubs> eventHubsStaticConnectionStringProvider(
AzureEventHubsProperties eventHubsProperties) {
return new StaticConnectionStringProvider<>(AzureServiceType.EVENT_HUBS,
eventHubsProperties.getConnectionString());
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
import com.azure.messaging.eventhubs.EventHubConsumerClient;
import com.azure.spring.cloud.autoconfigure.condition.ConditionalOnAnyProperty;
import com.azure.spring.cloud.autoconfigure.condition.ConditionalOnMissingProperty;
import com.azure.spring.cloud.autoconfigure.eventhubs.properties.AzureEventHubProperties;
import com.azure.spring.cloud.autoconfigure.eventhubs.properties.AzureEventHubsProperties;
import com.azure.spring.core.AzureSpringIdentifier;
import com.azure.spring.core.connectionstring.StaticConnectionStringProvider;
import com.azure.spring.core.service.AzureServiceType;
Expand All @@ -32,12 +32,12 @@
*/
@Configuration(proxyBeanMethods = false)
@Import({
AzureEventHubConsumerClientConfiguration.DedicatedConsumerConnectionConfiguration.class,
AzureEventHubConsumerClientConfiguration.SharedConsumerConnectionConfiguration.class
AzureEventHubsConsumerClientConfiguration.DedicatedConsumerConnectionConfiguration.class,
AzureEventHubsConsumerClientConfiguration.SharedConsumerConnectionConfiguration.class
})
@ConditionalOnAnyProperty(prefix = "spring.cloud.azure.eventhubs", name = { "event-hub-name", "consumer.event-hub-name" })
@ConditionalOnProperty(prefix = "spring.cloud.azure.eventhubs.consumer", name = "consumer-group")
class AzureEventHubConsumerClientConfiguration {
class AzureEventHubsConsumerClientConfiguration {

@ConditionalOnMissingProperty(prefix = "spring.cloud.azure.eventhubs.consumer", name = { "connection-string", "namespace" })
@ConditionalOnAnyProperty(prefix = "spring.cloud.azure.eventhubs", name = { "connection-string", "namespace" })
Expand All @@ -46,7 +46,7 @@ class AzureEventHubConsumerClientConfiguration {
static class SharedConsumerConnectionConfiguration {

private final EventHubClientBuilder builder;
SharedConsumerConnectionConfiguration(AzureEventHubProperties properties, EventHubClientBuilder builder) {
SharedConsumerConnectionConfiguration(AzureEventHubsProperties properties, EventHubClientBuilder builder) {
this.builder = builder;

PropertyMapper mapper = new PropertyMapper();
Expand All @@ -71,10 +71,10 @@ public EventHubConsumerClient eventHubConsumerClient(EventHubClientBuilder build
@Configuration(proxyBeanMethods = false)
static class DedicatedConsumerConnectionConfiguration {

private final AzureEventHubProperties.Consumer consumerProperties;
private final AzureEventHubsProperties.Consumer consumerProperties;

DedicatedConsumerConnectionConfiguration(AzureEventHubProperties eventHubProperties) {
this.consumerProperties = eventHubProperties.buildConsumerProperties();
DedicatedConsumerConnectionConfiguration(AzureEventHubsProperties eventHubsProperties) {
this.consumerProperties = eventHubsProperties.buildConsumerProperties();
}

@Bean(EVENT_HUB_CONSUMER_CLIENT_BUILDER_FACTORY_BEAN_NAME)
Expand All @@ -83,7 +83,7 @@ public EventHubClientBuilderFactory eventHubClientBuilderFactoryForConsumer() {

final EventHubClientBuilderFactory builderFactory = new EventHubClientBuilderFactory(this.consumerProperties);

builderFactory.setConnectionStringProvider(new StaticConnectionStringProvider<>(AzureServiceType.EVENT_HUB,
builderFactory.setConnectionStringProvider(new StaticConnectionStringProvider<>(AzureServiceType.EVENT_HUBS,
this.consumerProperties.getConnectionString()));
builderFactory.setSpringIdentifier(AzureSpringIdentifier.AZURE_SPRING_EVENT_HUB);
return builderFactory;
Expand Down
Loading

0 comments on commit c7d49d7

Please sign in to comment.