开发者

Actor model pattern : Limiting number of concurrent running actors

开发者 https://www.devze.com 2023-01-28 02:46 出处:网络
I\'ve designed an application based on the actor model pattern utilizing the spring application context events as the way to pass messages .

I've designed an application based on the actor model pattern utilizing the spring application context events as the way to pass messages . I have three layers :

  1. issues a requesttransactionevent
  2. issues a dotransactionevent <-- should limit the current number of running transactions
  3. issues a donetransactionevent

layer 1 saves the request to the DB (for distributed arch. monitoring requirements) and issues the clientrequest layer 2 receives it and should check how many a dotransactionevents it has running (issued and not returned donetransaction) if it has a free slot it should issue a dotransaction and it is allso declared as the listener for the donetransactionevent .

what is the most elegant way to implement layer 2 without a synchronous method or something of that sort , the trick here is that it needs to pull the requestparameters saved by layer1 t开发者_C百科o the db for issuing a dotransactionevent .


You could treat the collection of dotransactionevents as a queue, and have a parallel set of queue handlers which each process an item at a time from the queue. By controlling the number of queue handlers you could control the number of running transactions, as you described.

0

精彩评论

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

关注公众号