How to perform non-idempotent actions (send email) in a Actor model framework (e.g., akka.net)?












0














I am looking into using an actor model framework (akka.net with akka.net persistence, but I am looking for a general case answer) to build an 'widget order processing workflow'.



Pretty standard:




  1. Customer orders widget

  2. Payment is processed

  3. Email confirmation sent to customer

  4. Send picklist message to warehouse

  5. Warehouse sends a 'widget has been shipped' message back

  6. Send a 'your item has shipped' email to customer


Now let's say between 4 and 5 a server deployment/restart happens. This would cause a actor(s) rehydration (let's assume there is no snapshot yet). That means we would process the payment again, and resend the order placed email. However it turns out our customers don't like this 'feature'!



How to I prevent non-idempotent actions from re-occurring when using an actor model framework?



I have thought about having a separate store of 'payment processed for order db table'; but this feels like I am fighting the framework/paradigm and I wonder if there is a 'proper' way of doing this kind of thing!










share|improve this question





























    0














    I am looking into using an actor model framework (akka.net with akka.net persistence, but I am looking for a general case answer) to build an 'widget order processing workflow'.



    Pretty standard:




    1. Customer orders widget

    2. Payment is processed

    3. Email confirmation sent to customer

    4. Send picklist message to warehouse

    5. Warehouse sends a 'widget has been shipped' message back

    6. Send a 'your item has shipped' email to customer


    Now let's say between 4 and 5 a server deployment/restart happens. This would cause a actor(s) rehydration (let's assume there is no snapshot yet). That means we would process the payment again, and resend the order placed email. However it turns out our customers don't like this 'feature'!



    How to I prevent non-idempotent actions from re-occurring when using an actor model framework?



    I have thought about having a separate store of 'payment processed for order db table'; but this feels like I am fighting the framework/paradigm and I wonder if there is a 'proper' way of doing this kind of thing!










    share|improve this question



























      0












      0








      0







      I am looking into using an actor model framework (akka.net with akka.net persistence, but I am looking for a general case answer) to build an 'widget order processing workflow'.



      Pretty standard:




      1. Customer orders widget

      2. Payment is processed

      3. Email confirmation sent to customer

      4. Send picklist message to warehouse

      5. Warehouse sends a 'widget has been shipped' message back

      6. Send a 'your item has shipped' email to customer


      Now let's say between 4 and 5 a server deployment/restart happens. This would cause a actor(s) rehydration (let's assume there is no snapshot yet). That means we would process the payment again, and resend the order placed email. However it turns out our customers don't like this 'feature'!



      How to I prevent non-idempotent actions from re-occurring when using an actor model framework?



      I have thought about having a separate store of 'payment processed for order db table'; but this feels like I am fighting the framework/paradigm and I wonder if there is a 'proper' way of doing this kind of thing!










      share|improve this question















      I am looking into using an actor model framework (akka.net with akka.net persistence, but I am looking for a general case answer) to build an 'widget order processing workflow'.



      Pretty standard:




      1. Customer orders widget

      2. Payment is processed

      3. Email confirmation sent to customer

      4. Send picklist message to warehouse

      5. Warehouse sends a 'widget has been shipped' message back

      6. Send a 'your item has shipped' email to customer


      Now let's say between 4 and 5 a server deployment/restart happens. This would cause a actor(s) rehydration (let's assume there is no snapshot yet). That means we would process the payment again, and resend the order placed email. However it turns out our customers don't like this 'feature'!



      How to I prevent non-idempotent actions from re-occurring when using an actor model framework?



      I have thought about having a separate store of 'payment processed for order db table'; but this feels like I am fighting the framework/paradigm and I wonder if there is a 'proper' way of doing this kind of thing!







      akka actor akka.net






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited Nov 16 at 4:09

























      asked Nov 16 at 0:15









      DarcyThomas

      741927




      741927
























          2 Answers
          2






          active

          oldest

          votes


















          0














          Ok so it turns out it is pretty simple.



          With akka.net persistence, after a system restore, messages are replayed. The correct state can be recreated by (re) processing these messages.



          There is however a IsRestoring property, which can be checked to see if this is the first or a subsequent processing. Presumably other actor model framework have something similar.



          So you do something like:



          private void ProcessPayment (Order message)
          {
          if(!this.IsRestoring){
          //Perform non-idempotent payment process
          }
          }





          share|improve this answer































            -1














            To make a robust workflow processor, you have to store ALL data of a workflow process in a permanent storage.



            You can employ a database, a messaging system like Kafka, or use ready-made workflow management software.



            Since you already use Akka, Akka Persistence also can be an option.



            UPDATE



            Building a system which continue to work correctly in presence of system failures and restarts is a considerable task, far more complex than developing an actor framework. That is, you cannot just take any actor framework and add fault tolerance to it.






            share|improve this answer























            • Good info thanks, However you don't seem to be discussing anything specific to 'actor model frameworks' Do you think you could perhaps expand on your answer with that in mind?
              – DarcyThomas
              Nov 17 at 7:08











            Your Answer






            StackExchange.ifUsing("editor", function () {
            StackExchange.using("externalEditor", function () {
            StackExchange.using("snippets", function () {
            StackExchange.snippets.init();
            });
            });
            }, "code-snippets");

            StackExchange.ready(function() {
            var channelOptions = {
            tags: "".split(" "),
            id: "1"
            };
            initTagRenderer("".split(" "), "".split(" "), channelOptions);

            StackExchange.using("externalEditor", function() {
            // Have to fire editor after snippets, if snippets enabled
            if (StackExchange.settings.snippets.snippetsEnabled) {
            StackExchange.using("snippets", function() {
            createEditor();
            });
            }
            else {
            createEditor();
            }
            });

            function createEditor() {
            StackExchange.prepareEditor({
            heartbeatType: 'answer',
            autoActivateHeartbeat: false,
            convertImagesToLinks: true,
            noModals: true,
            showLowRepImageUploadWarning: true,
            reputationToPostImages: 10,
            bindNavPrevention: true,
            postfix: "",
            imageUploader: {
            brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
            contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
            allowUrls: true
            },
            onDemand: true,
            discardSelector: ".discard-answer"
            ,immediatelyShowMarkdownHelp:true
            });


            }
            });














            draft saved

            draft discarded


















            StackExchange.ready(
            function () {
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53329657%2fhow-to-perform-non-idempotent-actions-send-email-in-a-actor-model-framework-e%23new-answer', 'question_page');
            }
            );

            Post as a guest















            Required, but never shown

























            2 Answers
            2






            active

            oldest

            votes








            2 Answers
            2






            active

            oldest

            votes









            active

            oldest

            votes






            active

            oldest

            votes









            0














            Ok so it turns out it is pretty simple.



            With akka.net persistence, after a system restore, messages are replayed. The correct state can be recreated by (re) processing these messages.



            There is however a IsRestoring property, which can be checked to see if this is the first or a subsequent processing. Presumably other actor model framework have something similar.



            So you do something like:



            private void ProcessPayment (Order message)
            {
            if(!this.IsRestoring){
            //Perform non-idempotent payment process
            }
            }





            share|improve this answer




























              0














              Ok so it turns out it is pretty simple.



              With akka.net persistence, after a system restore, messages are replayed. The correct state can be recreated by (re) processing these messages.



              There is however a IsRestoring property, which can be checked to see if this is the first or a subsequent processing. Presumably other actor model framework have something similar.



              So you do something like:



              private void ProcessPayment (Order message)
              {
              if(!this.IsRestoring){
              //Perform non-idempotent payment process
              }
              }





              share|improve this answer


























                0












                0








                0






                Ok so it turns out it is pretty simple.



                With akka.net persistence, after a system restore, messages are replayed. The correct state can be recreated by (re) processing these messages.



                There is however a IsRestoring property, which can be checked to see if this is the first or a subsequent processing. Presumably other actor model framework have something similar.



                So you do something like:



                private void ProcessPayment (Order message)
                {
                if(!this.IsRestoring){
                //Perform non-idempotent payment process
                }
                }





                share|improve this answer














                Ok so it turns out it is pretty simple.



                With akka.net persistence, after a system restore, messages are replayed. The correct state can be recreated by (re) processing these messages.



                There is however a IsRestoring property, which can be checked to see if this is the first or a subsequent processing. Presumably other actor model framework have something similar.



                So you do something like:



                private void ProcessPayment (Order message)
                {
                if(!this.IsRestoring){
                //Perform non-idempotent payment process
                }
                }






                share|improve this answer














                share|improve this answer



                share|improve this answer








                edited Nov 17 at 18:11

























                answered Nov 17 at 9:50









                DarcyThomas

                741927




                741927

























                    -1














                    To make a robust workflow processor, you have to store ALL data of a workflow process in a permanent storage.



                    You can employ a database, a messaging system like Kafka, or use ready-made workflow management software.



                    Since you already use Akka, Akka Persistence also can be an option.



                    UPDATE



                    Building a system which continue to work correctly in presence of system failures and restarts is a considerable task, far more complex than developing an actor framework. That is, you cannot just take any actor framework and add fault tolerance to it.






                    share|improve this answer























                    • Good info thanks, However you don't seem to be discussing anything specific to 'actor model frameworks' Do you think you could perhaps expand on your answer with that in mind?
                      – DarcyThomas
                      Nov 17 at 7:08
















                    -1














                    To make a robust workflow processor, you have to store ALL data of a workflow process in a permanent storage.



                    You can employ a database, a messaging system like Kafka, or use ready-made workflow management software.



                    Since you already use Akka, Akka Persistence also can be an option.



                    UPDATE



                    Building a system which continue to work correctly in presence of system failures and restarts is a considerable task, far more complex than developing an actor framework. That is, you cannot just take any actor framework and add fault tolerance to it.






                    share|improve this answer























                    • Good info thanks, However you don't seem to be discussing anything specific to 'actor model frameworks' Do you think you could perhaps expand on your answer with that in mind?
                      – DarcyThomas
                      Nov 17 at 7:08














                    -1












                    -1








                    -1






                    To make a robust workflow processor, you have to store ALL data of a workflow process in a permanent storage.



                    You can employ a database, a messaging system like Kafka, or use ready-made workflow management software.



                    Since you already use Akka, Akka Persistence also can be an option.



                    UPDATE



                    Building a system which continue to work correctly in presence of system failures and restarts is a considerable task, far more complex than developing an actor framework. That is, you cannot just take any actor framework and add fault tolerance to it.






                    share|improve this answer














                    To make a robust workflow processor, you have to store ALL data of a workflow process in a permanent storage.



                    You can employ a database, a messaging system like Kafka, or use ready-made workflow management software.



                    Since you already use Akka, Akka Persistence also can be an option.



                    UPDATE



                    Building a system which continue to work correctly in presence of system failures and restarts is a considerable task, far more complex than developing an actor framework. That is, you cannot just take any actor framework and add fault tolerance to it.







                    share|improve this answer














                    share|improve this answer



                    share|improve this answer








                    edited Nov 17 at 7:41

























                    answered Nov 16 at 16:32









                    Alexei Kaigorodov

                    9,76611029




                    9,76611029












                    • Good info thanks, However you don't seem to be discussing anything specific to 'actor model frameworks' Do you think you could perhaps expand on your answer with that in mind?
                      – DarcyThomas
                      Nov 17 at 7:08


















                    • Good info thanks, However you don't seem to be discussing anything specific to 'actor model frameworks' Do you think you could perhaps expand on your answer with that in mind?
                      – DarcyThomas
                      Nov 17 at 7:08
















                    Good info thanks, However you don't seem to be discussing anything specific to 'actor model frameworks' Do you think you could perhaps expand on your answer with that in mind?
                    – DarcyThomas
                    Nov 17 at 7:08




                    Good info thanks, However you don't seem to be discussing anything specific to 'actor model frameworks' Do you think you could perhaps expand on your answer with that in mind?
                    – DarcyThomas
                    Nov 17 at 7:08


















                    draft saved

                    draft discarded




















































                    Thanks for contributing an answer to Stack Overflow!


                    • Please be sure to answer the question. Provide details and share your research!

                    But avoid



                    • Asking for help, clarification, or responding to other answers.

                    • Making statements based on opinion; back them up with references or personal experience.


                    To learn more, see our tips on writing great answers.





                    Some of your past answers have not been well-received, and you're in danger of being blocked from answering.


                    Please pay close attention to the following guidance:


                    • Please be sure to answer the question. Provide details and share your research!

                    But avoid



                    • Asking for help, clarification, or responding to other answers.

                    • Making statements based on opinion; back them up with references or personal experience.


                    To learn more, see our tips on writing great answers.




                    draft saved


                    draft discarded














                    StackExchange.ready(
                    function () {
                    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53329657%2fhow-to-perform-non-idempotent-actions-send-email-in-a-actor-model-framework-e%23new-answer', 'question_page');
                    }
                    );

                    Post as a guest















                    Required, but never shown





















































                    Required, but never shown














                    Required, but never shown












                    Required, but never shown







                    Required, but never shown

































                    Required, but never shown














                    Required, but never shown












                    Required, but never shown







                    Required, but never shown







                    Popular posts from this blog

                    How to change which sound is reproduced for terminal bell?

                    Can I use Tabulator js library in my java Spring + Thymeleaf project?

                    Title Spacing in Bjornstrup Chapter, Removing Chapter Number From Contents