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

Change the setClientFactoryCustomizers to addClientFactoryCustomizer #27775

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
Original file line number Diff line number Diff line change
Expand Up @@ -83,8 +83,8 @@ public class EventHubsMessageChannelBinder extends
private final Map<String, ExtendedProducerProperties<EventHubsProducerProperties>>
extendedProducerPropertiesMap = new ConcurrentHashMap<>();

private List<EventHubsProducerFactoryCustomizer> producerFactoryCustomizers = new ArrayList<>();
private List<EventHubsProcessorFactoryCustomizer> processorFactoryCustomizers = new ArrayList<>();
private final List<EventHubsProducerFactoryCustomizer> producerFactoryCustomizers = new ArrayList<>();
private final List<EventHubsProcessorFactoryCustomizer> processorFactoryCustomizers = new ArrayList<>();

/**
* Construct a {@link EventHubsMessageChannelBinder} with the specified headers to embed and {@link EventHubsChannelProvisioner}.
Expand Down Expand Up @@ -281,21 +281,25 @@ InstrumentationManager getInstrumentationManager() {
}

/**
* Set the producer factory customizers.
* Add a producer factory customizer.
*
* @param producerFactoryCustomizers The producer factory customizers.
* @param producerFactoryCustomizer The producer factory customizer to add.
*/
public void setProducerFactoryCustomizers(List<EventHubsProducerFactoryCustomizer> producerFactoryCustomizers) {
this.producerFactoryCustomizers = producerFactoryCustomizers;
public void addProducerFactoryCustomizer(EventHubsProducerFactoryCustomizer producerFactoryCustomizer) {
if (producerFactoryCustomizer != null) {

Choose a reason for hiding this comment

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

When will producerFactoryCustomizer be null?

Copy link
Member Author

Choose a reason for hiding this comment

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

this could be call by users

this.producerFactoryCustomizers.add(producerFactoryCustomizer);

Choose a reason for hiding this comment

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

Do we need to consider thread-safe here?

Copy link
Member Author

Choose a reason for hiding this comment

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

not for now

}
}

/**
* Set the processor factory customizers.
* Add a processor factory customizer.
*
* @param processorFactoryCustomizers The processor factory customizers.
* @param processorFactoryCustomizer The processor factory customizer to add.
*/
public void setProcessorFactoryCustomizers(List<EventHubsProcessorFactoryCustomizer> processorFactoryCustomizers) {
this.processorFactoryCustomizers = processorFactoryCustomizers;
public void addProcessorFactoryCustomizer(EventHubsProcessorFactoryCustomizer processorFactoryCustomizer) {
if (processorFactoryCustomizer != null) {
this.processorFactoryCustomizers.add(processorFactoryCustomizer);
}
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,6 @@
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Import;

import java.util.stream.Collectors;

import static com.azure.spring.cloud.autoconfigure.context.AzureContextUtils.DEFAULT_TOKEN_CREDENTIAL_BEAN_NAME;

/**
Expand Down Expand Up @@ -110,8 +108,8 @@ public EventHubsMessageChannelBinder eventHubBinder(EventHubsChannelProvisioner
binder.setBindingProperties(bindingProperties);
binder.setNamespaceProperties(namespaceProperties.getIfAvailable());
checkpointStores.ifAvailable(binder::setCheckpointStore);
binder.setProducerFactoryCustomizers(producerFactoryCustomizers.orderedStream().collect(Collectors.toList()));
binder.setProcessorFactoryCustomizers(processorFactoryCustomizers.orderedStream().collect(Collectors.toList()));
producerFactoryCustomizers.orderedStream().forEach(binder::addProducerFactoryCustomizer);

Choose a reason for hiding this comment

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

How about adding addProducerFactoryCustomizers to support add multiple customizers one time?

Copy link
Member Author

Choose a reason for hiding this comment

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

not for now, but maybe in later versions

processorFactoryCustomizers.orderedStream().forEach(binder::addProcessorFactoryCustomizer);
return binder;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,8 +85,8 @@ public class ServiceBusMessageChannelBinder extends
private final Map<String, ExtendedProducerProperties<ServiceBusProducerProperties>>
extendedProducerPropertiesMap = new ConcurrentHashMap<>();

private List<ServiceBusProducerFactoryCustomizer> producerFactoryCustomizers = new ArrayList<>();
private List<ServiceBusProcessorFactoryCustomizer> processorFactoryCustomizers = new ArrayList<>();
private final List<ServiceBusProducerFactoryCustomizer> producerFactoryCustomizers = new ArrayList<>();
private final List<ServiceBusProcessorFactoryCustomizer> processorFactoryCustomizers = new ArrayList<>();

/**
* Construct a {@link ServiceBusMessageChannelBinder} with the specified headersToEmbed and {@link ServiceBusChannelProvisioner}.
Expand Down Expand Up @@ -348,21 +348,25 @@ private String getGroup(String group) {
}

/**
* Set the producer factory customizers.
* Add a producer factory customizer.
*
* @param producerFactoryCustomizers The producer factory customizers.
* @param producerFactoryCustomizer The producer factory customizer to add.
*/
public void setProducerFactoryCustomizers(List<ServiceBusProducerFactoryCustomizer> producerFactoryCustomizers) {
this.producerFactoryCustomizers = producerFactoryCustomizers;
public void addProducerFactoryCustomizer(ServiceBusProducerFactoryCustomizer producerFactoryCustomizer) {
if (producerFactoryCustomizer != null) {
this.producerFactoryCustomizers.add(producerFactoryCustomizer);
}
}

/**
* Set the processor factory customizers.
* Add a processor factory customizer.
*
* @param processorFactoryCustomizers The processor factory customizers.
* @param processorFactoryCustomizer The processor factory customizer to add.
*/
public void setProcessorFactoryCustomizers(List<ServiceBusProcessorFactoryCustomizer> processorFactoryCustomizers) {
this.processorFactoryCustomizers = processorFactoryCustomizers;
public void addProcessorFactoryCustomizer(ServiceBusProcessorFactoryCustomizer processorFactoryCustomizer) {
if (processorFactoryCustomizer != null) {
this.processorFactoryCustomizers.add(processorFactoryCustomizer);
}
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,6 @@
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Import;

import java.util.stream.Collectors;

import static com.azure.spring.cloud.autoconfigure.context.AzureContextUtils.DEFAULT_TOKEN_CREDENTIAL_BEAN_NAME;

/**
Expand Down Expand Up @@ -111,8 +109,8 @@ public ServiceBusMessageChannelBinder serviceBusBinder(ServiceBusChannelProvisio
binder.setBindingProperties(bindingProperties);
binder.setNamespaceProperties(namespaceProperties.getIfAvailable());
binder.setMessageConverter(messageConverter.getIfAvailable());
binder.setProducerFactoryCustomizers(producerFactoryCustomizers.orderedStream().collect(Collectors.toList()));
binder.setProcessorFactoryCustomizers(processorFactoryCustomizers.orderedStream().collect(Collectors.toList()));
producerFactoryCustomizers.orderedStream().forEach(binder::addProducerFactoryCustomizer);
processorFactoryCustomizers.orderedStream().forEach(binder::addProcessorFactoryCustomizer);
return binder;
}

Expand Down