How do I update a NoSQL database and publish an event atomically in an event-driven microservices architecture?

In an event-driven microservices architecture, services typically need to update their domain state while publishing an integration event on a service bus (either completed or not completed). When using a relational database, this is usually accomplished by using the Outbox pattern: the database stores a single entry indicating that Event X needs to be published. This entry is saved as part of the same transaction that contains the domain state changes. A background process queries these entries and publishes the events. This means the event will eventually be published, eventually making the system consistent.

However, NoSQL databases do not support the idea of ​​updating multiple documents in a single transaction, and many of them do not support this without ugly workarounds. Below is a list of possible solutions (some uglier than others):

1. Deviation of the postal issue pattern:

Outbox patterns, but instead of having a separate collection of pending event documents, are stored as part of the domain entity. Each domain entity encapsulates a collection of events that still need to be published, and a background process queries those entities and publishes the events.


  1. If the background process publishes the event, but does not remove it
    It is republished by the domain entity. This should not actually be a problem if updates are not essential or the event handler can identify duplicate events.
  2. Domain entities are
    damaged by integration events.

2. Event Sourcing:

Event sourcing addresses this problem, but is very complex to implement and requires a lot of effort for small microservices.


  1. Complex, it may be necessary to completely revise the way services work with data.

3. Listen to your own events:

The service publishes only one event that is also subscribed (it does not update its status as part of the same operation). When the service bus returns the event for treatment, the service updates its domain entity.


  1. Other microservices can handle the event before the original microservice. This can lead to problems if it is assumed that the event has already occurred, although this is not the case.

Are there any other solutions to this problem? Which is the best?

magento2 – Magento 2 Module Observer Sequence order and sales order event

We have two modules that trigger the same event: checkout_submit_all_after.But I have to give a preference for this, I tried to give sequence in module b, but it does not work. For Ex module A and module B triggers the same event, but module B triggers First, it's my request to trigger module A, and after module B, there's a way I can do this. And what are the events that are triggered when the order placed over cron jobs is placed by crons? .Please give me a solution for going forward.
Thank you

amazon web services – boto3: The event source allocation can not be updated as it is being used.

Basically, I update the event source map for a lambda trigger on an SQS to programmatically enable / disable it.

                            # List all event sources for this new name queue
response = lada.list_event_source_mappings (
EventSourceArn = #: ars: aws: sqs: us-west-2: 234234: & # 39; + newname,
FunctionName = #: ars: aws: lambda: us-west-2: 234234: function: execute & # 39;
event_mappings = answer["EventSourceMappings"]
       print str (event_mappings)
for event_map in event_mappings:
print "Remove lambda trigger"
#Update them all with Disabled
response = lada.update_event_source_mapping (
UUID = event_map["UUID"].
FunctionName = #: ars: aws: lambda: us-west-2: 234234: function: execute & # 39 ;,
Enabled = False

I understand that, I googled that mistake, but nothing comes out.

An error occurred while calling (ResourceInUseException)
Update Event Source mapping process:
The event source association can not be updated because it is being used.

Why does this happen and how can I fix it? I just want to programmatically enable / disable a specific lambda trigger for a particular SQS.

Encryption – Encryption of mobile user data in the event of a PIN / device security breach

As I understand it, modern mobile operating systems often encrypt app data when a device is locked with a PIN or password. How do I protect users if their device or PIN has been compromised?

If I manually encrypt certain parts of my app data, where do I store the key to decrypt it if a hacker or unauthorized user holds the physical device or PIN / password in their hands?

Modular and clear JS programming for event handling

In the following code we use the function incrementer (is capitalized for clarity, although it should be used without it New) to instantiate a number.

incrementer offers a method growth a counter in a span, We have two such counters, and so we define incrementer Avoid code duplicates (although it would be nice to always do so, even without worrying about duplicates).

Function Incrementer (name, value) {
leave that = {};

// Constructor = name;
let mydiv = document.getElementById (& # 39; mydiv & # 39;);
mydiv.appendChild (document.createElement (& # 39; br & # 39;));
that.span = document.createElement (& # 39; span & # 39;); = & # 39; # num & # 39; + name;
that.span.innerHTML = value;
mydiv.appendChild (that.span);

that.increment = function () {
var i = parseInt (that.span.textContent) + 1;
that.span.innerHTML = i;
give that back;
var incrementer1 = incrementer (& # 39; one & # 39 ;, 10);
var incrementer2 = incrementer (zwei two,, 20);

Function double_increment () {
incrementer1.increment ();
incrementer2.increment ();

The function double_increment () is then used to increase both numbers.

I'm looking for criticism of this code, in particular:

  1. The block marked "Constructor" is directly in the function incrementer rather than in a function called constructor, What is the right basis for cleaner code?
  2. The function double_increment () seems awkward. It only exists in the global area to respond to events (user input in general, whether a button or otherwise). Is this a sufficient basis for a (larger) codebase?

php – Submit through an onclick event

I have a problem understanding how the submith.onchange method works to update a field in my database laravel

First, I have a drop-down menu with links to routes:

  • Here I show a collection in the options that come from a database:

  • Option 1
  • Option 2
  • change to display the list of accounts:

    @if ($ Accounts-> count ())
    @foreach ($ accounts as $ AccountsOptions)
  • {{$ AccountsHeaderList-> name}}
  • I go to my route document web.php :

    Route :: PATCH (& # 39; / AccountsUpdate / Auth :: user () -> id & # 39 ;,
    & # 39; HomeController @ AccountsUpdate & # 39; -> Name (& # 39; AccountsUpdate & # 39;);

    and in my controller HomeController I try to do that, but it shows me error:
    Too few arguments to work:

    App  Http  Controllers  HomeController :: AccountsUpdate (), 1 passed and exactly 2 expected

    My driver looks like this:

    public function AccountsUpdate (Request $ request, $ id)
    $ validatedData = $ request-> validate ([
            'ultima_cuenta' => 'required|max:255',
    User :: where (& # 39; id, $ id) -> update ($ validatedData);
    return redirect (& # 39; home & # 39;);

    I am very new to Laravel and I am not sure which error I found from the first day. I hope that I have explained myself well, if someone else finds this problem in menus, thank you in advance

    Probability – finding an example of an independent coin toss event

    This is from the book All of Statistics – Larry Wasserman, Chapter 1, Exercise 23

    Here we will gain some experience with the simulation of conditional probabilities.
    Consider throwing a fair die. To let $ A = [2, 4, 6]$ and $ B = [1,2,3,4]$,
    Then, $ P (A) = 1/2, P (B) = 2/3 $ and $ P (A cap B) = 1/3 $, Since $ P (A
    > cap B) = P (A) P (B) $
    the events A and B are independent.

    Find two events now $ A $ and $ B $ they are not independent.

    Suppose I then choose A = {2, 4} $ P (A) = 1/3 $, and $ P (A cap B) $ is still $ 1/3. P (A cap B) neq P (A) P (B) $, However, I think that A and B are still independent because I could not see how selecting B and A influenced another. How can you find a definition? $ A $ and $ B $ that they are dependent?

    Hooks – Write a function to detect an event

    I use the event calendar to process events on a site I create.

    I would like an include to fire when the user is on an event page (archives, single, etc., etc.). My include contains a handful of custom hooks that manage the insertion, removal, and insertion of custom HTML.

    I have tested the following:

    / **
    * Recognize tribal events and add text to the top of the page
    * /
    if (class_exists (& # 39; Tribe__Events__Main & # 39;)) {// Will only fire when the plugin is active
    Function is_tribe_calendar () {
    if (tribe_is_event () || tribe_is_event_category () || tribe_is_in_main_loop () || tribe_is_view () || tribe_events == get_post_type () || is_singular (& # 39; tribe_events & # 39;))
    echo & # 39;

    Tribal events is active.

    & # 39 ;; } add_action (& # 39; wp_head & # 39 ;, # 39; is_tribe_calendar & # 39;); }

    This feature works fine and inserts text at the top of the page if the user is in an archive (calendar) or in a single event.

    On the basis of my test, I wrote the following:

    / **
    * Detect trive events and need include
    * /
    if (class_exists (& # 39; Tribe__Events__Main & # 39;)) {// Will only fire when the plugin is active
    Function is_tribe_calendar () {
    if (tribe_is_event () || tribe_is_event_category () || tribe_is_in_main_loop () || tribe_is_view () || tribe_events == get_post_type () || is_singular (& # 39; tribe_events & # 39;))
    require get_template_directory (). & # 39; /inc/tribe-events.php&#39 ;;
    add_action (& # 39; wp_head & # 39 ;, # 39; is_tribe_calendar & # 39;);

    I do not think so wp_head Here's the hook, because I want to load an include with a custom PHP. Should I even use a catch for this kind of functionality?

    magento 1.9 – What is the right event to collect / update order information after successful order?

    I saw several people use it save_order_place_after, as well as checkout_onepage_controller_success_action, My problem is that I want to do a quick scan of the information collected in this order and update the tables based on the information collected. I've tried both events and got the following results (using PayPal On-wall Checkout):


    • Empty page loaded (PayPal payment verification page according to URL)
    • Order interrupted (no success page)
    • The payment was successfully sent to PayPal
    • No order information is stored in the admin section or in the database
    • The account is then broken and can not place another order without receiving an error
    • An e-mail will be triggered and sent successfully Observer.php


    • Order is successful
    • Success page loaded
    • Nothing is done by it Observer.php

    There are no syntax errors in the Observer.phpbecause it works correctly at the first event, but seems to interrupt the order in any way.

    Is there any other event that fires after an order is successfully completed and saved so that I can scan all information collected on the order?