Actor model: limiting the number of simultaneously acting participants

I developed an application based on an actor model template using spring application context events as a way to pass messages. I have three layers:

  • issues a request_transactionevent request
  • throws dotransactionevent <- should limit the current number of transactions
  • gives out donetransactionevent

Level 1 saves the database request (for requirements for distributed consolidated control) and issues level 2 of the client’s request, which should receive it, and should check how much pre-transformation works for it (dontransition is issued and not returned), if it has an empty slot, it must issue a pre-transaction, and he is also declared a listener for donetransactionevent.

What is the most elegant way to implement level 2 without a synchronous method or something like that, the trick is that it needs to pull the query parameters saved by layer1 in db to fetch a dotransactionevent file.

+3
source share
1 answer

You can consider the dotransactionevents collection as a queue and have a parallel set of queue handlers, each of which processes an element at a time from the queue. By controlling the number of queue handlers, you can control the number of transactions performed as you described.

0
source

Source: https://habr.com/ru/post/1777636/


All Articles