Skip to content

Close message channel issue #3026

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

Closed

Conversation

omercelikceng
Copy link
Contributor

Resolves #2869

@olegz
Copy link
Contributor

olegz commented Nov 5, 2024

@omercelikceng The issue #2869 marked as closed. Can you please explain what you are adding with this PR?

@omercelikceng
Copy link
Contributor Author

omercelikceng commented Nov 10, 2024

@omercelikceng The issue #2869 marked as closed. Can you please explain what you are adding with this PR?

Hi @olegz . I'd like to explain using the tests I've written. Assume we want to produce data by providing a binder to a dynamic destination.

image

In this example, when data is sent, it is put into the channelCache map within the StreamBridge class under the key "kafka1:dynamicTopic". The relevant code is shown in the image below.

bindProducer

Additionally, the this.bindingService.bindProducer(..) method is also invoked here. Let’s examine this method. When this method is called, the data is put into the producerBindings map within the BindingService class under the key "dynamicTopic". The relevant code is shown in the image below.

bind2

Moreover, all classes derived from AbstractBindableProxyFactory populate the outputHolders map, where the key is solely the output name. These classes also have the capability to invoke the unbindProducer method.

Subsequently, when the application is shutting down, the destroy method of the StreamBridge class is executed. All relevant values in the channelCache map are unbound by calling the unbindProducers method there. (via channelCache.keySet().forEach(bindingService::unbindProducers);). However, since the keys in channelCache map differ from those in producerBindings map, the unbind operation is not performed.

image

In other words, the key values in these maps are not identical. To resolve this issue during the unbind process, I made several enhancements to correct the inconsistencies.

If you run the tests I have written with the previous code, you will see that the error occurs.

@olegz olegz added this to the 4.2.0 milestone Nov 18, 2024
@olegz olegz closed this in dccf8ae Nov 18, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Spring cloud stream can not close MessageChannel
2 participants