ARTEMIS-4923 reduce synchronization in ManagementServiceImpl #5087
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
The
ManagementService
is used by the broker to register and unregister components for management as well as send notifications. When the broker is busy dealing with new sessions and auto-creating queues, addresses, etc. there is a lot of contention.To reduce synchronization and improve the service overall this commit does the following:
synchronized
from most methods. In most cases it's completely unnecessary because the methods are already using a thread-safe data-structure (e.g.ConcurrentHashMap
) or more specific synchronization is already in place (e.g. onmbeanServer
).start
&stop
methods and adds gates viastarted
.sendNotification
method by synchronizing once rather than twice and performing legitimacy checks sooner.registereQueue
method.To be clear, there are no tests included with this commit as there should be no semantic changes. Existing tests should be sufficient to identify any regressions.