Hi devs,

Already some time ago I had the idea to refactor the existing metrics collection code (used by the JMX support) in the transport base package to use an observer pattern. More precisely the idea is to allow to register any number of observers (or event listeners if you prefer) with a transport listener or sender. These observers would then be notified whenever something interesting happens in the transport (message received, error, etc.). Basically the refactoring would be achieved by extracting an interface from MetricsCollector and change the 1:1 relationship between transport and observer (metrics collector) into a 1:n relationship. The existing MetricsCollector would then become one particular observer.

I'm primarily interested in this change because I'm facing a particular problem in the transport unit tests: the test cases have no way to detect a reception error in the transport, except for waiting for the timeout. This could be solved using the observer pattern described above. Probably this particular use case on its own wouldn't justify the change, but there will probably be other interesting use cases.

WDYT?

Andreas

Reply via email to