I have a general question regarding the usage of the OSGi EventAdmin service. I'm currently using it in开发者_JAVA技巧 a setting where potentially thousands of events can be generated per second. My fear is that the EventAdmin service might be a bottleneck. Initial results I get from my profiler seem to support this. The questions I have are:
- Is there a general rule of thumb when to use the EventAdmin service?
- How do the sendEvent and postEvent methods differ in terms of performance?
- Is there a particular OSGi container which is known to have a low performing EventAdmin implementation?
Thanks in advance for your support!
Cheers, Georg
Do you have more information about the bottleneck you see?
We have an update coming for the Event Admin spec (see RFC 157 in [1]) to aid some performance issues. But this is not completed spec work yet.
Send event is a synchronous send, so the calling thread blocks until all listeners have been notified. Most implementations use the callers thread. Post event does not block the caller. It queues the work for another thread to deliver the event. The current Event Admin spec requires ordering for async events, so this can cause delays if ordering is not required. RFC 157 provides the ability to not require this ordering.
I have no data on whether one implementation before better or worse than another.
[1] http://www.osgi.org/Download/File?url=/download/osgi-4.3-early-draft2.pdf
精彩评论