• Post Reply Bookmark Topic Watch Topic
  • New Topic

How can I "interupt" a running program  RSS feed

 
M Rodrigues
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I want to be able to interupt a process reading from a message queue and writing to a DB. i.e. tell the process to stop; refresh properties; etc.

I could have the program re-read its properties on some interval, but that seems expensive, and not real-time enough.

Can I update the value of some process or VM variable/property externally?

Thanks
Mark
 
Julian Kennedy
Ranch Hand
Posts: 823
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Mark,

I'm assuming that you want to interrupt your queue reader process from another (unrelated) process, otherwise the solution would be trivial.

As you say, one option is to have your app periodically reload its properties, including (say) a "pause" property which would have the effect of pausing the reader. Of course, how quickly this would stop would depend on the polling frequency and the polling thread would have to run regardless of whether you ever actually wanted to stop the process.

The typical alternative to this kind of polling is to use an event-driven model. That could be an equivalent of the Observer/Observable design pattern where your queue reader would implement a method to be called by your interrupter. As the two objects (reader and interrupter) would be in different processes, the first communication mechanism that springs to mind is RMI. I'm no expert on RMI so I'll have to leave you there, but I hope this is of some use.

Maybe others can add more substance to this suggestion.

Regards

Jules
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!