ECM
ECM
总版主
总版主
  • 社区居民
  • 忠实会员
  • 原创写手
阅读:935回复:0

How do I notify a Consumer job that Producer job is done?

楼主#
更多 发布于:2016-05-16 10:53
Using Spring/Quartz, I have an ProducerJob that is run first. Then I have a ConsumerJob that must wait for the result of ProducerJob (which creates records in the DB). What's the best way for ConsumerJob to be notified of the results of ProducerJob? Should I let ConsumerJob to constantly check the database, and sleep/wait if ProducerJob is not yet done? I realize my question may be similar to Pass BlockingQueue in JobDataMap of Quartz, although no specific implementation was identified. Still not getting how this would be implemented though.
answer(解决方案):

In the Producer/Consumer pattern the consumer has to wait for the data the producer prduces. If you want to decouple both using a database, the consumer has to poll. Yes. Another solution is to use a BlockingQueue and let the consumer write the database entries. This would reduce database load and is propably simpler to implement. And the producer is mutch faster, which is often a reason to use this pattern.

 

 

 

 

 

 

 

异常中心网是一家专门收集整理程序员编程过程中遇到的常见异常(exception)以及各种异常问答中心的网站。异常中心网旨在,减少程序员在编码遇到异常,处理各种异常时间和痛苦,让程序员能更愉快的、快速的定位异常并查找对应的异常解决方案。异常中心网诚心打造最完美的编程社区为程序员用户服务,努力成为最好的程序员乐园程序员社区程序异常中心程序bug中心异常问答中心

 

喜欢0 评分0
游客

返回顶部