views:

54

answers:

4

Hi There!

I have a design problem .

My application has multiple J2EE 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 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 mechanism's can I use to achieve this.

Thanks!

Pratik

+1  A: 

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.

Develman
+1  A: 

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

sateesh
A: 

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

Padmarag
+2  A: 

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

Calm Storm
Queues wouldn't really work since they're point-to-point (PTP). Assuming there is more than one consumer you'd want to use a topic (pub/sub)
mtpettyp