Comments (7)
@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.
- We use a autofac dependency injection. We needed a unit of work handler, where dependencies would be resolved once per message.
- Middleware support, similarly to what we have with the Owin pipeline.
- 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. - In the startup class you can see how we set up the middlewares that will be used.
- @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.
- Added
IDictionary<string, string> Headers { get; set; }
to the message. - 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.
- 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.
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.
@dariusdamalakas that sounds like what we want too. Do you have code to share?
from justsaying.
@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.
@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.
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.
Closed automatically due to inactivity.
from justsaying.
Related Issues (20)
- Support late binding of topic names
- Amazon.SQS.AmazonSQSException: Submitted policy is over max allowed size HOT 3
- [Feature Request] Add A Generic IMessagePublisher HOT 1
- Change error logging from trace to warning/error when messages are deleted HOT 1
- Add support for Batch operation
- Improve the Examples to include Middlewares? HOT 7
- Getting "There are pending startup tasks that must be executed by calling StartAsync before messages may be published" on lambda HOT 3
- JustSaying keeps logging error messages when the SQS queue is deleted.
- Getting System.InvalidOperationException: Cannot resolve scoped service 'Microsoft.AspNetCore.Mvc.ViewFeatures.Buffers.IViewBufferScope' from root provider error. HOT 1
- Investigate Improvements to MessageSerializationRegister
- Make the behaviour clear when providing a Service URI HOT 1
- Remove `SqsPolicy` from JustSaying
- Allow restarting the JustSayingBus once it is stopped HOT 3
- Queue policy over max allowed size on 14+ subscriptions after 7.1.0 HOT 1
- Add Public API analyzers
- DOCS: Middleware documentation is out of date, and does not reflect how to use HOT 2
- Custom middleware that throws an exception will cause handler starvation HOT 1
- Native AOT Compatibility HOT 1
- Policy Filler Scope Configuration Option
- Support Scoped dependency injection when underlying container does HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from justsaying.