What are Design patterns useful for Notification system?
Some explanation: there are several machines(hosts) that need to be notified about any changes of some data on certain resource machine. Resource machine all time checks data and if any changes were made it notified all listeners.
As I understand I should use Observer pattern, May be Absrtact Factory for generalization, What else?
As I understand Resource machine should use as server(java.net.serv开发者_如何学Pythonersocket) as client(java.net.socket) to sending special messages to listeners and getting request? And all other machines need to use as server(to recieving messages about any changes of data) as client(to sending request to get new data). Am I right?
And may be you can explain me any other sides of realization notification systems? Probably it's useful using JMX, but I think it's too gargantuan for this problem?
The Enterprise Integration Patterns website (http://www.eaipatterns.com/) gives a good overview over messaging patterns.
You can look at something like RPC. This enables you to implement the observer pattern, but the receiving objects are placed on another host.
This way, the fact that the observer are on a different host is transparent to the rest of the code.
Well, that pretty much describes the Observer pattern.
Some kind of factory will probably end up being needed for creating a client object associated with each remote machine on the 'server'.
That being said, trying to figure out what design patterns you can apply to a problem up-front is frequently the wrong choice.
I dont think you should be thinking Design patterns, notification (as you envisage it for your system) and JMX at the same time. You are mixing and things from totally different layers of the whole process. The patterns are not directly applied to whole systems and JMX is not an implementation of a specific category of systems. Delving into them would not help you. I think you should first think much more on the system you want to build, because it seems to me that you trying to find out what you want to build by exploring abstract construction patterns and specific technologies first. It should be the other way around. Pod's comment on your question nailed it. It is like you are designing a car and asking for information on tire brands and turbine types before having decided on the suspension type or the chassis or even the type of car.
Some times publisher-subscriber is best way to implement notification system.
精彩评论