Git Product home page Git Product logo

Comments (11)

iancooper avatar iancooper commented on May 12, 2024 5

I would avoid Transactions via decorators.

We tried this in our early days of running on Brighter, but it leads to the anti-pattern that the whole of the handler is contained within the transaction. Now, if a developer decides to do something long-running here, such as calling an HTTP endpoint, or posting a message onto RMQ, you are going to hold the transaction open for the whole time period. That is obviously a no-no.

For that reason we dropped Transactional decorators and forced developers to explicitly manage the transaction lifetime within the handler.

Our main use case for decorators is resiliency. Brighter wraps Polly and you can then run your pipeline within a Polly policy declaritively. We do this by using a Russian Doll approach to composition. EPoll is a Python library that one of the team wrote that uses a similar decorator wrapper to support resiliency model.

We also use decorators to handle fallback scenarios. Darker, our query side project for example will use it to acces a cache on fallback.

from eshoponcontainers.

CESARDELATORRE avatar CESARDELATORRE commented on May 12, 2024

Agreed. This issue is actually kind of old and we were thinking about something different instead of a transaction decorator.
The next decorator we were thinking about was a Validator decorator, maybe using FluentValidation https://github.com/JeremySkinner/FluentValidation or similar.

Resiliency might also be a good case for a decorator, although using Polly for resiliency would also be needed from the client apps. We're planning to use Polly for resiliency in the upcoming weeks, as shown in our roadmap.

It would be great to see a fork of this sample app with your implementation using Brighter, so we and the community learn from your experiences. And it would be referenced from our guidance, too. :)

from eshoponcontainers.

iancooper avatar iancooper commented on May 12, 2024

Will do, we have 15% time coming up next week, we'll endeavour to get a Brighter fork up and running so you can see how it would work. I can probably get a few co-conspirators to help me :-)

(PS It does also mean we can do some heavy lifting if you need some bodies. Just ask. We have thought about doing something similar to your project, but working with you guys makes more sense, so not a big ask)

from eshoponcontainers.

CESARDELATORRE avatar CESARDELATORRE commented on May 12, 2024

Sure! If you guys see code that could be improved by itself (not really related to the Brighter implementation), please do pull requests! :)

from eshoponcontainers.

maulik-modi avatar maulik-modi commented on May 12, 2024

@iancooper , do we have Outbox implementation in Brighton?

Sending message from Command Handler to RabbitMQ might break transactional outbox pattern

from eshoponcontainers.

iancooper avatar iancooper commented on May 12, 2024

@maulik-modi Brighter V9 has good Outbox support that works with RMQ publisher confirms. It's in pre-release. I think we need to get another release out in the next day or so for the publisher-confirms code. We'll go to non pre-release once our community have told us then don't have any major issues

from eshoponcontainers.

iancooper avatar iancooper commented on May 12, 2024

You choose an Outbox that matches the Db you use, and call DepositPost() within that transaction. You then call ClearoutBox() to flush the messages.

You can then use our OutboxSweeper to look for messages that have not been confirmed as sent within a time window and resend them (you need to run that on a thread yourself, though we are thinking about doing that for you too in a future release).

Both Kafka and RMQ callbacks for confirming a message has propagated to all the nodes are supported and will mark messages as dispatched if they confirm it was sent.

from eshoponcontainers.

iancooper avatar iancooper commented on May 12, 2024

There is earlier Outbox support for Brighter, but it was not so simple to use. With this release we have made it easier to use (it's effectively always on but will default to in-memory if you don't configure a persistent store, and we limit how much the in-memory box can grow)

from eshoponcontainers.

maulik-modi avatar maulik-modi commented on May 12, 2024

@iancooper , Please confirm https://github.com/BrighterCommand/Brighter/tree/master/src is the reository.

When I looked at TopicClientWrapper.cs in Azure Service Bus, I could see Transaction related code, I could not find similar code block in RMQ e.g. https://github.com/BrighterCommand/Brighter/blob/master/src/Paramore.Brighter.MessagingGateway.RMQ/RmqMessagePublisher.cs

public void Send(Microsoft.Azure.ServiceBus.Message message)
        {
            //Azure Service Bus only supports IsolationLevel.Serializable if in a transaction
            if (Transaction.Current != null && Transaction.Current.IsolationLevel != IsolationLevel.Serializable)
            {
                using (new TransactionScope(TransactionScopeOption.Suppress))
                {
                    _topicClient.SendAsync(message).Wait();
                }
            }
            else
            {
                _topicClient.SendAsync(message).Wait();
            }
        }

from eshoponcontainers.

iancooper avatar iancooper commented on May 12, 2024

In v9 we use publisher confirms: https://www.rabbitmq.com/confirms.html

https://github.com/BrighterCommand/Brighter/blob/master/src/Paramore.Brighter.MessagingGateway.RMQ/RmqMessageProducer.cs

from eshoponcontainers.

iancooper avatar iancooper commented on May 12, 2024

That then hooks back to our Outbox support: https://github.com/BrighterCommand/Brighter/blob/master/src/Paramore.Brighter/CommandProcessor.cs (look at the ConfigurePublisherCallbackMaybe() method to start you off)

from eshoponcontainers.

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.