Giter Site home page Giter Site logo

Comments (5)

eao197 avatar eao197 commented on May 18, 2024

If I understand you correctly, deadletter-handlers can help here. There is also a small example of deadletter-handler in the standard SObjectizer's examples.

from sobjectizer.

zamazan4ik avatar zamazan4ik commented on May 18, 2024

Thank you. If I understand correctly, I shall manually register any possible event in deadletter handler. Is it possible somehow add a generic deadletter handler for any event, for which there is no other handlers? I don't want to register all possible events in my system manually in a deadletter handler.

Probably I should explain a little bit, why it's important for me. In my system there are lot of different events. Different subsets can be handled only in different states. If they send to not corresponding state - they must be ignored with proper logging. Manual registration of a new event to a deadletter handler is not a good solution here since I just can forget about registration in different deadletter nadlers in my system.

Mentioned above Boost.SML has such feature:

"unexpected events handling"_s  + unexpected_event<_> / [] { std::cout << "generic unexpected event" << std::endl; }

from sobjectizer.

eao197 avatar eao197 commented on May 18, 2024

SObjectizer doesn't allow the handling of a message of unknown type. That is why a subscription is possible only to a message of a particular type. And there is no way to do "a generic" message handler that can handle any message type (or a message of some subtype).

Messages of any type can be sent to a receiver, but if there is no a subscription for a particular message type that message will be thrown out. This is a specific of SObjectizer. At least for its current form.

And the case is the same for deadletter handlers. That is why you can't have "a generic" deadletter handler.

from sobjectizer.

zamazan4ik avatar zamazan4ik commented on May 18, 2024

Hm... Thanks. Seems like the best solution here for will be:

  • Introduce "generic" deadletter handler for all agents in the system (probably as a base class for all agents - I should recheck the possibility for doing such thing with SObjectizer)
  • When new event is introduced in the system - register it in the "generic" deadletter handler. Since I don't see any easy autocheck for automatic finding problems like "You've introduced new event but forgot to register it in the deadletter handler" - here will be some manual work
  • Register the "generic" deadletter handler for all corresponding agents in the system

Hope it'll work. Thank you!

from sobjectizer.

eao197 avatar eao197 commented on May 18, 2024

I think a trick with the usage of custom mbox and custom message envelope can be used here to avoid manual work.

The scheme is:

  • you create your own custom mbox that envelopes every message into your special envelope. Then this mbox passes the new enveloped message to the actual destination mbox. A proxy from so5extra can be used for the simplification of this task;
  • then you use your custom mbox instance instead of mbox of your agent. It means that you give a reference to your custom mbox to message senders instead of agent's direct mbox;
  • your special envelope has a boolean flag inside. That flag is set to true if a message is delivered to the destination. It means that the flag is set to true only in access_hook with access_context_t::handler_found argument;
  • you check this flag in the destructor of your special envelope and if it isn't true you log the fact that message wasn't handled.

A just_envelope_t from so5extra can be used for the simplification of the implementation of your special envelope.

PS. I'm afraid there is no easier way. I don't even see a good way to extend SObjectizer's functionality to simplify the task of handling missed (unexpected) messages. It's because an obvious approach of addition some so_unexpected_message virtual method to agent_t will conflict with adv_thread_pool dispatcher, where complex scheme with postponing of events is used. Maybe another solution can be invented here, but it's impossible to predict when it can be found and how quickly it can be implemented into SObjectizer.

from sobjectizer.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.