question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Why are duplicate event listeners/consumers supported?

See original GitHub issue

Hi @RobWin,

As per this Javadoc, the Circuit breaker registry will either create a new circuit breaker or return an existing one with the same name. At the same time, I also noticed that the event listeners use an implementation of a List to keep track of all the registered event listeners.

Due to the dual behavior of Circuit Breaker registry, clients would now have to make sure that they don’t attach duplicate listeners. Use-case: If I’d like to attach an onEvent listener at the time of creation of circuit breaker, I risk registering the same listener multiple times.

Is there a reason to allow duplicate listeners? If this is not intended, we could use CopeOnWriteArraySet if we don’t expect the # of listeners to be large. But if it’s expected to have a large # of listeners, one option would be to use ConcurrentHashMap.

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:7 (7 by maintainers)

github_iconTop GitHub Comments

1reaction
dlsrb6342commented, Feb 4, 2020

Yes right. You can consume EntryAddedEvent<CircuitBreaker>.

public class CustomRegistryEventConsumer<CircuitBreaker> implements RegistryEventConsumer<CircuitBreaker> {

    @Override
    public void onEntryAddedEvent(EntryAddedEvent<CircuitBreaker> entryAddedEvent) {
        entryAddedEvent.getAddedEntry().getEventPublisher().onEvent(......);
    }

    @Override
    public void onEntryRemovedEvent(EntryRemovedEvent<E> entryRemoveEvent) {    }

    @Override
    public void onEntryReplacedEvent(EntryReplacedEvent<E> entryReplacedEvent) {    }

}
1reaction
laksnvcommented, Feb 4, 2020
Read more comments on GitHub >

github_iconTop Results From Across the Web

Handling Duplicate Messages (Idempotent Consumers)
This means that you need to develop your consumers to be able to effectively handle duplicate messages. The term for this is having...
Read more >
javascript - When are duplicate event listeners discarded, and ...
If multiple identical EventListeners are registered on the same EventTarget with the same parameters, the duplicate instances are discarded.
Read more >
Handling duplicate messages using the Idempotent consumer ...
If a message handler is not inherently idempotent, it must record successfully processed messages and discard duplicates.
Read more >
Handling Duplicate Messages (Idempotent Consumers)
Why do message brokers support "At Least Once" messaging, and how do you handle duplicates ? Here's how to make idempotent consumers and...
Read more >
Duplicate Salesforce event listeners during CloudHub zero ...
Duplicate Salesforce event listeners during CloudHub zero-downtime app re-deployment · CloudHub allows app re-deployment with zero-downtime. · SYMPTOM · CAUSE.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found