Giter Club home page Giter Club logo

Comments (7)

gerektoolhy avatar gerektoolhy commented on June 14, 2024 1

@payman81, here's the gist - bus middleware support. Apologies for that being explicitly verbose, but I wanted to show how we are using JustEat. I'll try to explain as much possible the key concepts we have introduced. Note that in any way I am not saying this is applicable to everyone, but some ideas i would like to see implemented in one way or another in JustSaying.

  1. We use a autofac dependency injection. We needed a unit of work handler, where dependencies would be resolved once per message.
  2. Middleware support, similarly to what we have with the Owin pipeline.
  3. JustSaying handlers can be chained, but there is no way how to flow the context. We have introduced IBusContext which is passed to all middlewares and handlers.
  4. In the startup class you can see how we set up the middlewares that will be used.
  5. @petemounce , in the startup, we set up bus correlation middleware. This is what directly relates to your topic here. You put any context in bus headers - user id, current running service, correlation id, etc.
  6. Added IDictionary<string, string> Headers { get; set; } to the message.
  7. BusUnitOfWorkHandler is the implementation of JustSaying handler, which internally pushes the message through the middleware pipeline, and handles the message. We could even add support for registering multiple handlers here, which is not supported by JustSaying out of the box.
  8. IBusPublisher - this is a wrapper on top of JustSaying publisher, adds support for message mutators. You can look at this as the pipeline for the published messages.

I have added some extra in line comments to the code, so hopefully that will explain some bits.

Hope this helps, comments and feedback more than welcome.

from justsaying.

gerektoolhy avatar gerektoolhy commented on June 14, 2024

We solved this by just adding a dict<string, string> as the Headers property on the message, and added middleware to put correlation ids on the outgoing messages. If correlation ID exists on incoming message, we pass that through to outgoing messages. In fact, we have the same going on with HTTP requests, so we can track API requests and bus messages and correlate these.

We should consider this carefully, but this might be a useful feature.

from justsaying.

petemounce avatar petemounce commented on June 14, 2024

@dariusdamalakas that sounds like what we want too. Do you have code to share?

from justsaying.

gerektoolhy avatar gerektoolhy commented on June 14, 2024

@petemounce, It's not trivial, as we've built a bus middleware concept around the IHandler interface, similar to what Owin gives with its middlewares, in a similar fashion with app.Use(justSayingBusMiddleware). I can try and extract some of it into a gist to give an idea how we went around with it. I'd be happy to hear your thoughts whether any of it could be made generic enough to suite everyone.

from justsaying.

payman81 avatar payman81 commented on June 14, 2024

@dariusdamalakas It would be great If you could send us a gist with your snippets. I think that's something people can benefit from.

from justsaying.

stale avatar stale commented on June 14, 2024

This issue has been automatically marked as stale because it has not had any recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

from justsaying.

stale avatar stale commented on June 14, 2024

Closed automatically due to inactivity.

from justsaying.

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.