SlideShare a Scribd company logo
Dive into SObjectizer-5.5
SObjectizer Team, Jan 2016
Seventh Part: Message Limits
(at v.5.5.15)
This is the next part of the series of presentations with deep
introduction into features of SObjectizer-5.5.
This part is dedicated to message limits feature.
This feature is intended to use in protection of agents from
overloading.
SObjectizer Team, Jan 2016
Introduction
SObjectizer Team, Jan 2016
The main way of interaction between agents in SObjectizer
is asynchronous messages.
It makes very easy to use “fire-and-forget” scheme:
● an agent A finishes its own part of work, sends the result as a
message to agent B and starts new processing;
● agent B receives a message, processes it and sends a new
message to agent C;
● agent C receives a message, processes it and sends…
This is very simple scheme but...
SObjectizer Team, Jan 2016
...what if some agent in this chain processes messages
much slower than the other agents which send new
messages to it?
This problem is known as overloading of agent.
SObjectizer Team, Jan 2016
Overloading leads to growth of event queues.
Event queues eat more and more memory.
Growing memory usage slows down the application.
Lower speed leads to faster growth of event queues…
As a result of overloading the application is degraded and
should be killed in most cases.
SObjectizer Team, Jan 2016
There is no simple solution for overloading problem because
a good overload control scheme for a particular application-
specific agent will be very domain-specific and, probably,
can’t be reused in another project.
So, there is no ready-to-use just out-of-box tool or
mechanism in SObjectizer which could be seen as ‘one size
fits all’ solution for overloading problem.
SObjectizer Team, Jan 2016
But there is a mechanism which can protect agents from
overloading in simple situations.
This mechanism is known as message limits.
SObjectizer Team, Jan 2016
Message limits is an optional feature which can be turned on
for individual agent.
If message limits is turned on for an agent SObjectizer will
count instances of messages in agent’s event queue.
When number of messages of particular type exceeds limit
for that type SObjectizer performs an overlimit reaction
which is specified by user.
SObjectizer Team, Jan 2016
Types Of Overlimit Reactions
SObjectizer Team, Jan 2016
There are several overlimit reactions which can be
performed by SObjectizer:
● dropping new messages;
● killing the whole application by std::abort();
● redirecting new messages to another mbox;
● transforming new messages to messages of different
types (with possibility to redirect them to different
mboxes).
SObjectizer Team, Jan 2016
Message dropping is the simplest form of overlimit reactions.
It means that a new message of type T which exceeds limit
for messages of type T will be ignored and will not be
pushed to event queue of the subscriber.
This type of reaction can be useful if there is an intensive
flow of messages and losing of several messages is not a
problem. For example: ignored message will be repeated by
sender after some timeout.
SObjectizer Team, Jan 2016
Another simple overlimit reaction is killing the whole
application by std::abort().
This overlimit reaction can be used in scenarios where the
application must guarantee some throughput but can’t do
that.
For example: an agent should process messages quite
quickly. But there is a bug in the agent’s implementation and
sometimes it fell into infinite loop. The only solution there is
killing the app and restart it.
SObjectizer Team, Jan 2016
The next overlimit reaction is redirection of a new message
to another mbox.
This type of reaction could be used in different schemes:
● a very simple load balancing with agents A1, A2, ..., An. Agent A1
redirects messages to A2. A2 redirects to A3 and so on;
● different kind of processing by different subscribers. There could
be agent N which does a normal processing. On overload it
redirects messages to agent P which just sends back a reply
“system is busy, try later”.
SObjectizer Team, Jan 2016
The last and most complex reaction is transformation with
optional redirection.
This type of reaction could be used in implementing complex
domain-specific schemes of overload control.
For example, an overloaded agent could transform new messages
into signals about overloaded state and sends it to an overload
controller. The controller can perform some actions like changing
processing params, disconnecting some clients, switching off some
logging and so on...
SObjectizer Team, Jan 2016
Maximum Overlimit Reaction Deep
SObjectizer Team, Jan 2016
There is a possibility of redirection loops for overlimit
reactions of ‘redirect’ and ‘transform’ types.
For example: agent A1 redirects message to A2, A2
redirects to A3, …, An redirects back to A1.
Without a control of recursion of overlimit reactions infinite
loops inside message delivery procedure could arise.
SObjectizer Team, Jan 2016
Because of that SObjectizer limits the number of overlimit
reactions which are performed during the delivery of a
message instance.
This is called ‘overlimit_deep’ and the current maximum
value of overlimit_deep is 16.
This value is hardcoded in the current SObjectizer
implementation and can’t be changed in run-time.
SObjectizer Team, Jan 2016
When maximum value of overlimit_deep is reached then a
delivery of message is aborted by raising so_5::exception_t
with the appropriate error code.
Please note that if it is a delivery via multi-consumer mbox
then some subscribers will not receive a message. Even if
they do not use message limits at all.
It is because the whole delivery procedure is canceled.
SObjectizer Team, Jan 2016
How To Specify Message Limits?
SObjectizer Team, Jan 2016
This part of presentation contains some examples of
message limits definition.
But before going deep into code samples some important
rules first...
SObjectizer Team, Jan 2016
If an agent defines message limit for some message type T it
must also define message limits for all other message types
it processes.
If an agent defines message limit for type T and tries to
make a subscription for message of type M which hasn’t
defined limit there will be an error.
SObjectizer Team, Jan 2016
Message limits are defined at the moment of agent’s
construction and can’t be changed or removed later.
Definition of message limits are passed to the constructor of
so_5::agent_t or to coop_t::define_agent() method via so_5::
context_t object.
SObjectizer Team, Jan 2016
Definition of message limits with ‘drop message’ overlimit
reaction could look like:
// For ordinary agents:
class request_processor : public so_5::agent_t {
public :
request_processor( context_t ctx )
: so_5::agent_t( ctx
// No more than 20 messages with dropping of extra messages.
+ limit_then_drop< request >( 20 )
// No more than 1 message with dropping of extra messages.
+ limit_then_drop< get_status >( 1 ) )
...
};
// For ad-hoc agents:
coop.define_agent( coop.make_agent_context()
+ so_5::agent_t::limit_then_drop< request >( 20 )
+ so_5::agent_t::limit_then_drop< get_status >( 1 ) )...
SObjectizer Team, Jan 2016
Definition of message limits with ‘abort the app’ overlimit
reaction could look like:
// For ordinary agents:
class hardware_interface : public so_5::agent_t {
public :
hardware_interface( context_t ctx )
: so_5::agent_t( ctx
// Usually there must be no more than 10 waiting commands.
// But if something goes wrong and hardware part doesn't respond
// it is better to terminate the whole application.
+ limit_then_abort< outgoing_apdu_command >( 500 ) )
...
};
// For ad-hoc agents:
coop.define_agent( coop.make_agent_context()
+ so_5::agent_t::limit_then_abort< outgoing_apdu_command >( 500 ) );
SObjectizer Team, Jan 2016
Definition of message limits with ‘redirect’ overlimit reaction
could look like:
class normal_request_processor : public so_5::agent_t
{
public :
normal_request_processor(
context_t ctx,
// Message box of agent for handling requests in overload mode.
// In this mode requests are not processed but negative response with the appropriate
// result code is sent back (and this fact is stored in the application log).
so_5::mbox_t overload_mode_processor )
: so_5::agent_t( ctx
// We can hold no more that 10 requests in queue.
// All extra messages must be redirected to overload-mode processor
// for generation of negative replies.
+ limit_then_redirect< request >( 10,
[overload_mode_processor] { return overload_mode_processor; } )
...
};
SObjectizer Team, Jan 2016
Definition of message limits with ‘transform’ overlimit
reaction could look like (for the case of a message):
class request_processor : public so_5::agent_t
{
public :
normal_request_processor( context_t ctx )
: so_5::agent_t( ctx
// We can hold no more that 10 requests in queue.
// For all extra messages negative replies must be generated.
+ limit_then_transform( 10, [](const request & evt) {
return make_transformed< negative_reply >(
// Mbox for sending reply is got from original request.
evt.reply_to(),
// All other arguments are passed to negative_reply constructor.
error_code::processor_is_busy );
} ) )
{}
...
};
SObjectizer Team, Jan 2016
Definition of message limits with ‘transform’ overlimit
reaction could look like (for the case of a signal):
class long_operation_performer : public so_5::agent_t
{
public :
long_operation_performer( context_t ctx, so_5::mbox_t mbox_for_notifications )
: so_5::agent_t( ctx
// If we cannot process previous get_status signal
// then we are busy and can tell about this.
+ limit_then_transform< get_status >( 1,
[this, mbox_for_notifications] {
// The result of the transformation is another signal and because of that
// there is only one argument for make_transform (the target mbox).
return make_transformed< status_busy >( notification_mbox );
} ) )
{}
...
};
SObjectizer Team, Jan 2016
Some Final Words
SObjectizer Team, Jan 2016
This presentation is just a short introduction in the topic of
message limits.
For more detailed information please see the corresponding
section of Project’s Wiki.
But it is necessary to remember that message limits is not a
fullfledged solution for overload problem...
SObjectizer Team, Jan 2016
Message limits could be seen as a basic building blocks for
more complex application- and domain-specific overload
control schemes.
Some examples of such schemes which are based on collector-
performer agents pairs are represented in several examples in the
SObjectizer’s distribution (they are also described in Project’s Wiki):
● work_generation;
● collector_performer_pair and collector_many_performers;
● simple_message_deadline;
● prio_work_stealing.
SObjectizer Team, Jan 2016
Additional Information:
Project’s home: http://sourceforge.net/projects/sobjectizer
Documentation: http://sourceforge.net/p/sobjectizer/wiki/
Forum: http://sourceforge.net/p/sobjectizer/discussion/
Google-group: https://groups.google.com/forum/#!forum/sobjectizer
GitHub mirror: https://github.com/masterspline/SObjectizer

More Related Content

PDF
Dive into SObjectizer 5.5. Third part. Coops
PDF
Dive into SObjectizer 5.5. Eighth Part: Dispatchers
PDF
Dive into SObjectizer-5.5. Sixth part: Synchronous Interaction
PDF
Dive into SObjectizer 5.5. Fourth part. Exception
PDF
Dive into SObjectizer 5.5. Introductory part
PDF
Dive into SObjectizer 5.5. Fifth part: Timers
PDF
Dive into SObjectizer 5.5. Tenth part: Mutable Messages
PDF
Dive into SObjectizer 5.5. Ninth Part: Message Chains
Dive into SObjectizer 5.5. Third part. Coops
Dive into SObjectizer 5.5. Eighth Part: Dispatchers
Dive into SObjectizer-5.5. Sixth part: Synchronous Interaction
Dive into SObjectizer 5.5. Fourth part. Exception
Dive into SObjectizer 5.5. Introductory part
Dive into SObjectizer 5.5. Fifth part: Timers
Dive into SObjectizer 5.5. Tenth part: Mutable Messages
Dive into SObjectizer 5.5. Ninth Part: Message Chains

What's hot (20)

PDF
What is SObjectizer 5.5
PDF
arataga. SObjectizer and RESTinio in action: a real-world example
PDF
Date Processing Attracts Bugs or 77 Defects in Qt 6
PDF
Bot builder v4 HOL
PDF
PVS-Studio vs Chromium. 3-rd Check
ODP
Testing RESTful Webservices using the REST-assured framework
PDF
ajax_pdf
PPT
my accadanic project ppt
PDF
Analysis of bugs in Orchard CMS
ODP
Creating a Java EE 7 Websocket Chat Application
PPTX
Android session-5-sajib
ODP
MQTT and Java - Client and Broker Examples
PPTX
Dependency Injection for Android
PPTX
Dependency Injection for Android @ Ciklum speakers corner Kiev 29. May 2014
PDF
Mvc interview questions – deep dive jinal desai
DOCX
Parallel Programming With Dot Net
PPTX
Typescript barcelona
PPTX
PPT
Spring AOP
What is SObjectizer 5.5
arataga. SObjectizer and RESTinio in action: a real-world example
Date Processing Attracts Bugs or 77 Defects in Qt 6
Bot builder v4 HOL
PVS-Studio vs Chromium. 3-rd Check
Testing RESTful Webservices using the REST-assured framework
ajax_pdf
my accadanic project ppt
Analysis of bugs in Orchard CMS
Creating a Java EE 7 Websocket Chat Application
Android session-5-sajib
MQTT and Java - Client and Broker Examples
Dependency Injection for Android
Dependency Injection for Android @ Ciklum speakers corner Kiev 29. May 2014
Mvc interview questions – deep dive jinal desai
Parallel Programming With Dot Net
Typescript barcelona
Spring AOP
Ad

Viewers also liked (11)

PDF
What’s new in SObjectizer 5.5.8
PPTX
Big data and Predictive Analytics By : Professor Lili Saghafi
PDF
Secure Code Review 101
PPTX
Evgeniy Muralev, Mark Vince, Working with the compiler, not against it
PPTX
C++ Core Guidelines
PDF
15years of Service with IBM MEA and 20 years with IBM in total
PDF
Google Cloud Platform
PDF
Actor Model and C++: what, why and how?
PDF
Phygital
PDF
Five keys to successful cloud migration
 
PDF
Design in Tech Report 2017
What’s new in SObjectizer 5.5.8
Big data and Predictive Analytics By : Professor Lili Saghafi
Secure Code Review 101
Evgeniy Muralev, Mark Vince, Working with the compiler, not against it
C++ Core Guidelines
15years of Service with IBM MEA and 20 years with IBM in total
Google Cloud Platform
Actor Model and C++: what, why and how?
Phygital
Five keys to successful cloud migration
 
Design in Tech Report 2017
Ad

Similar to Dive into SObjectizer 5.5. Seventh part: Message Limits (20)

PDF
What is SObjectizer 5.7 (at v.5.7.0)
PDF
What's new in SObjectizer 5.5.9
PDF
What is SObjectizer 5.6 (at v.5.6.0)
PDF
Combine Framework
PPTX
Meet with Meteor
PPTX
DOC
Manual testing interview questions
PDF
Mdb dn 2016_07_elastic_search
DOCX
How to build typing indicator in a Chat app
PPTX
Poject documentation deepak
PDF
An Ideal Way to Integrate a Static Code Analyzer into a Project
PDF
Android 8 behavior changes
PDF
Reactive Applications with Apache Pulsar and Spring Boot
PPTX
Javascripts hidden treasures BY - https://geekyants.com/
PDF
Book management system
PPTX
Reactive programming with rx java
PDF
1844 1849
PDF
1844 1849
What is SObjectizer 5.7 (at v.5.7.0)
What's new in SObjectizer 5.5.9
What is SObjectizer 5.6 (at v.5.6.0)
Combine Framework
Meet with Meteor
Manual testing interview questions
Mdb dn 2016_07_elastic_search
How to build typing indicator in a Chat app
Poject documentation deepak
An Ideal Way to Integrate a Static Code Analyzer into a Project
Android 8 behavior changes
Reactive Applications with Apache Pulsar and Spring Boot
Javascripts hidden treasures BY - https://geekyants.com/
Book management system
Reactive programming with rx java
1844 1849
1844 1849

More from Yauheni Akhotnikau (12)

PDF
Actor Model and C++: what, why and how? (March 2020 Edition)
PDF
[C++ CoreHard Autumn 2018] Actors vs CSP vs Task...
PDF
Shrimp: A Rather Practical Example Of Application Development With RESTinio a...
PDF
Акторы в C++: взгляд старого практикующего актородела (St. Petersburg C++ Use...
PDF
Акторы на C++: стоило ли оно того?
PDF
25 Years of C++ History Flashed in Front of My Eyes
PDF
GECon 2017: C++ - a Monster that no one likes but that will outlast them all
PDF
Шишки, набитые за 15 лет использования акторов в C++
PDF
Для чего мы делали свой акторный фреймворк и что из этого вышло?
PDF
Модель акторов и C++ что, зачем и как?
PDF
Погружение в SObjectizer 5.5. Вводная часть
PDF
Обзор SObjectizer 5.5
Actor Model and C++: what, why and how? (March 2020 Edition)
[C++ CoreHard Autumn 2018] Actors vs CSP vs Task...
Shrimp: A Rather Practical Example Of Application Development With RESTinio a...
Акторы в C++: взгляд старого практикующего актородела (St. Petersburg C++ Use...
Акторы на C++: стоило ли оно того?
25 Years of C++ History Flashed in Front of My Eyes
GECon 2017: C++ - a Monster that no one likes but that will outlast them all
Шишки, набитые за 15 лет использования акторов в C++
Для чего мы делали свой акторный фреймворк и что из этого вышло?
Модель акторов и C++ что, зачем и как?
Погружение в SObjectizer 5.5. Вводная часть
Обзор SObjectizer 5.5

Recently uploaded (20)

PDF
Nekopoi APK 2025 free lastest update
PDF
2025 Textile ERP Trends: SAP, Odoo & Oracle
PPTX
Agentic AI : A Practical Guide. Undersating, Implementing and Scaling Autono...
PDF
Design an Analysis of Algorithms II-SECS-1021-03
PDF
SAP S4 Hana Brochure 3 (PTS SYSTEMS AND SOLUTIONS)
PPTX
Reimagine Home Health with the Power of Agentic AI​
PDF
T3DD25 TYPO3 Content Blocks - Deep Dive by André Kraus
PDF
PTS Company Brochure 2025 (1).pdf.......
PDF
Adobe Premiere Pro 2025 (v24.5.0.057) Crack free
PDF
Adobe Illustrator 28.6 Crack My Vision of Vector Design
PDF
How to Migrate SBCGlobal Email to Yahoo Easily
PDF
System and Network Administraation Chapter 3
PDF
Flood Susceptibility Mapping Using Image-Based 2D-CNN Deep Learnin. Overview ...
PDF
top salesforce developer skills in 2025.pdf
PPTX
Transform Your Business with a Software ERP System
PDF
Raksha Bandhan Grocery Pricing Trends in India 2025.pdf
PDF
Internet Downloader Manager (IDM) Crack 6.42 Build 41
PDF
Wondershare Filmora 15 Crack With Activation Key [2025
PPTX
Introduction to Artificial Intelligence
PPTX
Essential Infomation Tech presentation.pptx
Nekopoi APK 2025 free lastest update
2025 Textile ERP Trends: SAP, Odoo & Oracle
Agentic AI : A Practical Guide. Undersating, Implementing and Scaling Autono...
Design an Analysis of Algorithms II-SECS-1021-03
SAP S4 Hana Brochure 3 (PTS SYSTEMS AND SOLUTIONS)
Reimagine Home Health with the Power of Agentic AI​
T3DD25 TYPO3 Content Blocks - Deep Dive by André Kraus
PTS Company Brochure 2025 (1).pdf.......
Adobe Premiere Pro 2025 (v24.5.0.057) Crack free
Adobe Illustrator 28.6 Crack My Vision of Vector Design
How to Migrate SBCGlobal Email to Yahoo Easily
System and Network Administraation Chapter 3
Flood Susceptibility Mapping Using Image-Based 2D-CNN Deep Learnin. Overview ...
top salesforce developer skills in 2025.pdf
Transform Your Business with a Software ERP System
Raksha Bandhan Grocery Pricing Trends in India 2025.pdf
Internet Downloader Manager (IDM) Crack 6.42 Build 41
Wondershare Filmora 15 Crack With Activation Key [2025
Introduction to Artificial Intelligence
Essential Infomation Tech presentation.pptx

Dive into SObjectizer 5.5. Seventh part: Message Limits

  • 1. Dive into SObjectizer-5.5 SObjectizer Team, Jan 2016 Seventh Part: Message Limits (at v.5.5.15)
  • 2. This is the next part of the series of presentations with deep introduction into features of SObjectizer-5.5. This part is dedicated to message limits feature. This feature is intended to use in protection of agents from overloading. SObjectizer Team, Jan 2016
  • 4. The main way of interaction between agents in SObjectizer is asynchronous messages. It makes very easy to use “fire-and-forget” scheme: ● an agent A finishes its own part of work, sends the result as a message to agent B and starts new processing; ● agent B receives a message, processes it and sends a new message to agent C; ● agent C receives a message, processes it and sends… This is very simple scheme but... SObjectizer Team, Jan 2016
  • 5. ...what if some agent in this chain processes messages much slower than the other agents which send new messages to it? This problem is known as overloading of agent. SObjectizer Team, Jan 2016
  • 6. Overloading leads to growth of event queues. Event queues eat more and more memory. Growing memory usage slows down the application. Lower speed leads to faster growth of event queues… As a result of overloading the application is degraded and should be killed in most cases. SObjectizer Team, Jan 2016
  • 7. There is no simple solution for overloading problem because a good overload control scheme for a particular application- specific agent will be very domain-specific and, probably, can’t be reused in another project. So, there is no ready-to-use just out-of-box tool or mechanism in SObjectizer which could be seen as ‘one size fits all’ solution for overloading problem. SObjectizer Team, Jan 2016
  • 8. But there is a mechanism which can protect agents from overloading in simple situations. This mechanism is known as message limits. SObjectizer Team, Jan 2016
  • 9. Message limits is an optional feature which can be turned on for individual agent. If message limits is turned on for an agent SObjectizer will count instances of messages in agent’s event queue. When number of messages of particular type exceeds limit for that type SObjectizer performs an overlimit reaction which is specified by user. SObjectizer Team, Jan 2016
  • 10. Types Of Overlimit Reactions SObjectizer Team, Jan 2016
  • 11. There are several overlimit reactions which can be performed by SObjectizer: ● dropping new messages; ● killing the whole application by std::abort(); ● redirecting new messages to another mbox; ● transforming new messages to messages of different types (with possibility to redirect them to different mboxes). SObjectizer Team, Jan 2016
  • 12. Message dropping is the simplest form of overlimit reactions. It means that a new message of type T which exceeds limit for messages of type T will be ignored and will not be pushed to event queue of the subscriber. This type of reaction can be useful if there is an intensive flow of messages and losing of several messages is not a problem. For example: ignored message will be repeated by sender after some timeout. SObjectizer Team, Jan 2016
  • 13. Another simple overlimit reaction is killing the whole application by std::abort(). This overlimit reaction can be used in scenarios where the application must guarantee some throughput but can’t do that. For example: an agent should process messages quite quickly. But there is a bug in the agent’s implementation and sometimes it fell into infinite loop. The only solution there is killing the app and restart it. SObjectizer Team, Jan 2016
  • 14. The next overlimit reaction is redirection of a new message to another mbox. This type of reaction could be used in different schemes: ● a very simple load balancing with agents A1, A2, ..., An. Agent A1 redirects messages to A2. A2 redirects to A3 and so on; ● different kind of processing by different subscribers. There could be agent N which does a normal processing. On overload it redirects messages to agent P which just sends back a reply “system is busy, try later”. SObjectizer Team, Jan 2016
  • 15. The last and most complex reaction is transformation with optional redirection. This type of reaction could be used in implementing complex domain-specific schemes of overload control. For example, an overloaded agent could transform new messages into signals about overloaded state and sends it to an overload controller. The controller can perform some actions like changing processing params, disconnecting some clients, switching off some logging and so on... SObjectizer Team, Jan 2016
  • 16. Maximum Overlimit Reaction Deep SObjectizer Team, Jan 2016
  • 17. There is a possibility of redirection loops for overlimit reactions of ‘redirect’ and ‘transform’ types. For example: agent A1 redirects message to A2, A2 redirects to A3, …, An redirects back to A1. Without a control of recursion of overlimit reactions infinite loops inside message delivery procedure could arise. SObjectizer Team, Jan 2016
  • 18. Because of that SObjectizer limits the number of overlimit reactions which are performed during the delivery of a message instance. This is called ‘overlimit_deep’ and the current maximum value of overlimit_deep is 16. This value is hardcoded in the current SObjectizer implementation and can’t be changed in run-time. SObjectizer Team, Jan 2016
  • 19. When maximum value of overlimit_deep is reached then a delivery of message is aborted by raising so_5::exception_t with the appropriate error code. Please note that if it is a delivery via multi-consumer mbox then some subscribers will not receive a message. Even if they do not use message limits at all. It is because the whole delivery procedure is canceled. SObjectizer Team, Jan 2016
  • 20. How To Specify Message Limits? SObjectizer Team, Jan 2016
  • 21. This part of presentation contains some examples of message limits definition. But before going deep into code samples some important rules first... SObjectizer Team, Jan 2016
  • 22. If an agent defines message limit for some message type T it must also define message limits for all other message types it processes. If an agent defines message limit for type T and tries to make a subscription for message of type M which hasn’t defined limit there will be an error. SObjectizer Team, Jan 2016
  • 23. Message limits are defined at the moment of agent’s construction and can’t be changed or removed later. Definition of message limits are passed to the constructor of so_5::agent_t or to coop_t::define_agent() method via so_5:: context_t object. SObjectizer Team, Jan 2016
  • 24. Definition of message limits with ‘drop message’ overlimit reaction could look like: // For ordinary agents: class request_processor : public so_5::agent_t { public : request_processor( context_t ctx ) : so_5::agent_t( ctx // No more than 20 messages with dropping of extra messages. + limit_then_drop< request >( 20 ) // No more than 1 message with dropping of extra messages. + limit_then_drop< get_status >( 1 ) ) ... }; // For ad-hoc agents: coop.define_agent( coop.make_agent_context() + so_5::agent_t::limit_then_drop< request >( 20 ) + so_5::agent_t::limit_then_drop< get_status >( 1 ) )... SObjectizer Team, Jan 2016
  • 25. Definition of message limits with ‘abort the app’ overlimit reaction could look like: // For ordinary agents: class hardware_interface : public so_5::agent_t { public : hardware_interface( context_t ctx ) : so_5::agent_t( ctx // Usually there must be no more than 10 waiting commands. // But if something goes wrong and hardware part doesn't respond // it is better to terminate the whole application. + limit_then_abort< outgoing_apdu_command >( 500 ) ) ... }; // For ad-hoc agents: coop.define_agent( coop.make_agent_context() + so_5::agent_t::limit_then_abort< outgoing_apdu_command >( 500 ) ); SObjectizer Team, Jan 2016
  • 26. Definition of message limits with ‘redirect’ overlimit reaction could look like: class normal_request_processor : public so_5::agent_t { public : normal_request_processor( context_t ctx, // Message box of agent for handling requests in overload mode. // In this mode requests are not processed but negative response with the appropriate // result code is sent back (and this fact is stored in the application log). so_5::mbox_t overload_mode_processor ) : so_5::agent_t( ctx // We can hold no more that 10 requests in queue. // All extra messages must be redirected to overload-mode processor // for generation of negative replies. + limit_then_redirect< request >( 10, [overload_mode_processor] { return overload_mode_processor; } ) ... }; SObjectizer Team, Jan 2016
  • 27. Definition of message limits with ‘transform’ overlimit reaction could look like (for the case of a message): class request_processor : public so_5::agent_t { public : normal_request_processor( context_t ctx ) : so_5::agent_t( ctx // We can hold no more that 10 requests in queue. // For all extra messages negative replies must be generated. + limit_then_transform( 10, [](const request & evt) { return make_transformed< negative_reply >( // Mbox for sending reply is got from original request. evt.reply_to(), // All other arguments are passed to negative_reply constructor. error_code::processor_is_busy ); } ) ) {} ... }; SObjectizer Team, Jan 2016
  • 28. Definition of message limits with ‘transform’ overlimit reaction could look like (for the case of a signal): class long_operation_performer : public so_5::agent_t { public : long_operation_performer( context_t ctx, so_5::mbox_t mbox_for_notifications ) : so_5::agent_t( ctx // If we cannot process previous get_status signal // then we are busy and can tell about this. + limit_then_transform< get_status >( 1, [this, mbox_for_notifications] { // The result of the transformation is another signal and because of that // there is only one argument for make_transform (the target mbox). return make_transformed< status_busy >( notification_mbox ); } ) ) {} ... }; SObjectizer Team, Jan 2016
  • 30. This presentation is just a short introduction in the topic of message limits. For more detailed information please see the corresponding section of Project’s Wiki. But it is necessary to remember that message limits is not a fullfledged solution for overload problem... SObjectizer Team, Jan 2016
  • 31. Message limits could be seen as a basic building blocks for more complex application- and domain-specific overload control schemes. Some examples of such schemes which are based on collector- performer agents pairs are represented in several examples in the SObjectizer’s distribution (they are also described in Project’s Wiki): ● work_generation; ● collector_performer_pair and collector_many_performers; ● simple_message_deadline; ● prio_work_stealing. SObjectizer Team, Jan 2016
  • 32. Additional Information: Project’s home: http://sourceforge.net/projects/sobjectizer Documentation: http://sourceforge.net/p/sobjectizer/wiki/ Forum: http://sourceforge.net/p/sobjectizer/discussion/ Google-group: https://groups.google.com/forum/#!forum/sobjectizer GitHub mirror: https://github.com/masterspline/SObjectizer