开发者

Notification between Java EE components

I have a design problem .

My application has multiple Java EE components ,In simple terms one acts as a service provider(Non UI) and others are consumers(UI webapp) .

The consumer gets the configuration data from the service provider(this basically reads the data from DB) during the start up and stores it in the Cache.

The cache gets refreshed after periodic time to reflect any changes done at the database.

The开发者_如何学JAVA Problem

Apart from the cache refresh, I also want to notify the consumers when someone changes the DB that configuration has been changed please reload it.

What notification mechanisms can I use to achieve this?


I would go with JMS topics/queues. The producer sending a "REFRESH_CACHE" message on a topic and all consumers listening to this


I would use a topic for it. When the database changes you can send a message to the topic and all clients listen to it, can show a message.


Take a look at the Observer design pattern. You can store consumers in a list and notify them when something interesting happens.


You may need OBSERVER pattern.
It notifies the consumers (your UI apps) using Callback. You can use JMS for notifications.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜