Event driven and scheduled service

I have one question.
One my service, let us say, Service A, Expects input from a subscribing service( a notification). Before 9 AM, it should get some information from my subscribing sevrice (like event driven service), Otherwise It should act as scheduled service.
I was not able to figure exactly, how can I make a single service as an event driven as well as scheduled.
Please suggest me


Hi Kris,

I think you need a “global variable” to keep track if your service has run before 9AM (then the service is fired by the notification). If the services is fired by an event, mark the global variable as “processsed”. When the scheduled serviceA runs at 9AM, check this variable. If variable is processed, stop and do nothing. Otherwise do your thing.

How to implement this global variable thing. You have to find a place in your environment that is shared by all your IS instances (when you are in a cluster). Options:

  1. Use repo server
  2. Use a memory
  3. Use a file


  1. won’t recomment this one, because sometimes very slow
  2. Data lost at restart. You have to keep memory of all IS instances in sync. You can do a service call to “getBrokerHosts” and do a http call to a service that sync’s the memory (make this service Anynumous) on every IS
  3. Only applicabale when you have a shared file system. When you have, i would recomment this option.

When not in a cluster, just use a file. Easy, quick and no hassle.



Sorry but it’s not clear to me – Is ServiceA the publisher (using publishAndWait) or subscriber? Or put it another way, is ServiceA waiting for a reply, or is it waiting for a publish/deliver?

If ServiceA is the publisher, aside from Rob’s suggestion, you can also try working backwards. ServiceA figures out the time between now and 9am, calls publishAndWait with waitTime being the time that we just calculated (and async=false). Then ServiceA just processing whether it received a reply (before 9am) or not (at 9am).

Rob and Chang.
Thank you very much for the suggestions.