I am attempting to add an NHibernate ISession object to a Consumer thread. I am not interested in injecting ISessionFactory or ISession to the Consumer class constructor. I would like to open the ISession before consume and dispose it after consume. I thought I had a solution with IConsumeMessageObserver but the async nature of MT causes the PreConsume to happen on a different thread than Consume. I'd like to do something similar to web api pipeline configuration like ActionFilterAttribute OnActionExecuting and OnActionExecuted which use the same thread before, during, and after execution. I also looked at using a transaction which seems to support storage across threads but this doesn't seem to fit with my use case.I'm sure this has been answered before but I have not been able to find what I'm looking for. Thanks in advance.
--
You received this message because you are subscribed to the Google Groups "masstransit-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to masstransit-discuss+unsub...@googlegroups.com.
To post to this group, send email to masstransit-discuss@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/masstransit-discuss/3d23c518-b539-4a18-83ce-e05fa7b1c70f%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
you should look at adding payloads to the ConsumeContext, so they are available to the consumer. Using thread static elements is always going to fail going forward as more async code becomes common.Take a look at this to get started:
On Tue, Jul 18, 2017 at 10:16 AM, Brian Colwell <bst...@gmail.com> wrote:
I am attempting to add an NHibernate ISession object to a Consumer thread. I am not interested in injecting ISessionFactory or ISession to the Consumer class constructor. I would like to open the ISession before consume and dispose it after consume. I thought I had a solution with IConsumeMessageObserver but the async nature of MT causes the PreConsume to happen on a different thread than Consume. I'd like to do something similar to web api pipeline configuration like ActionFilterAttribute OnActionExecuting and OnActionExecuted which use the same thread before, during, and after execution. I also looked at using a transaction which seems to support storage across threads but this doesn't seem to fit with my use case.I'm sure this has been answered before but I have not been able to find what I'm looking for. Thanks in advance.
--
You received this message because you are subscribed to the Google Groups "masstransit-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to masstransit-discuss+unsub...@googlegroups.com.
To post to this group, send email to masstrans...@googlegroups.com.