HttpContext.Current is not available to set the current SendContext

186 views
Skip to first unread message

Krzysztof Koźmic

unread,
Aug 11, 2011, 7:56:19 PM8/11/11
to masstransit-discuss
Hi,

I have an IIS hosted WCF service that gets the exception with message
mentioned above.

It has AspNetCompatibilityRequirementsMode.Required, but the exception
occurs in InboundMsmqTransport, in using(context.CreateScope()) call on
my foo_control_subscriptions queue.

I'm not sure I understand it enough, but it seems to me that there's an
assumption that if the bus is used from an app hosted in IIS the
HttpContext is always available and for some reason in this particular
case (managing subscribers) it assumption seems to be wrong.

Am I missing something, can I somehow workaround this?

I'm running latest build from TeamCity

Krzysztof

Travis Smith

unread,
Aug 11, 2011, 9:09:12 PM8/11/11
to masstrans...@googlegroups.com
Chris wrote this stuff, I think he'll have to comment on it; I'm not
sure here. I don't want you to think that I didn't see when I'm
answering your other stuff. I've never bothered using a bus in the
scope of a web service, it's always been one-way inbound message
writing.

-Travis

2011/8/11 Krzysztof Koźmic <krzyszto...@gmail.com>:

> --
> You received this message because you are subscribed to the Google Groups
> "masstransit-discuss" group.
> To post to this group, send email to masstrans...@googlegroups.com.
> To unsubscribe from this group, send email to
> masstransit-dis...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/masstransit-discuss?hl=en.
>
>

Chris Patterson

unread,
Aug 11, 2011, 10:18:25 PM8/11/11
to masstrans...@googlegroups.com
This is broken in the NuGet package, but has been fixed in the develop branch. I'll likely put another beta on NuGet before the weekend.

Krzysztof Koźmic

unread,
Aug 11, 2011, 10:24:38 PM8/11/11
to masstrans...@googlegroups.com
I'm not using the nuget - I'm on the build from TeamCity and it does
certainly still occur (in the MassTransit package (build 2.0.0.395)).
Should I be using MassTransit (develop) build 2.0.0.68 instead?

What's the difference between them?
I'd appreciate an official build with the fix, some people on my team
strongly oppose using non-release builds.

cheers,
Krzysztof

Krzysztof Koźmic

unread,
Aug 11, 2011, 10:31:58 PM8/11/11
to masstrans...@googlegroups.com
I just tried to get the develop version from teamcity to test that, but
the build has no artifacts #sadpanda

Krzysztof

On 12/08/2011 12:18 PM, Chris Patterson wrote:

Chris Patterson

unread,
Aug 11, 2011, 10:47:09 PM8/11/11
to masstrans...@googlegroups.com
Looks like the build failed, but it didn't get picked up by TeamCity as failed. Ugh.

Krzysztof Koźmic

unread,
Aug 12, 2011, 3:09:27 AM8/12/11
to masstrans...@googlegroups.com
I just tried the latest build from 30minutes ago and this one is not
working at all.

Yes - the exception is gone but the message never makes it to the
receiver. There's no exception or no other indication what might be wrong.

Krzysztof

Chris Patterson

unread,
Aug 12, 2011, 8:21:47 AM8/12/11
to masstrans...@googlegroups.com
When you say not working at all, what does that mean?

Also, if you could provide a log4net output of the test you performed, that would give some indication of what is happening.

Using the WebRequestReply sample, I've verified that it works in a web context, so I'm not sure what else could be going on without some logs.

Krzysztof Koźmic

unread,
Aug 12, 2011, 8:24:25 AM8/12/11
to masstrans...@googlegroups.com
Hi,

not working as in the message does not get posted/received. Not too sure
at which point it's failing.

I'll try to get logs on monday.

cheers,
Krzysztof

Chris Patterson

unread,
Aug 12, 2011, 8:43:53 AM8/12/11
to masstrans...@googlegroups.com
If you can throw the sample code up on GitHub or something, I could work it into a sample for WCF usage and use it to verify the transactional functionality within WCF. I don't know a whole lot about WCF though, I've managed to avoid it quite well.

Krzysztof Koźmic

unread,
Aug 12, 2011, 8:48:08 AM8/12/11
to masstrans...@googlegroups.com
sigh,

I was afraid you were going to ask for that. Getting a full reproduction
of the setup (WPF client talking to IIS hosted WCF service which posts a
message via MT to console app (eventually windows service)) might take
some time...

I'll see if I can find some time to do that on monday.

krzysztof

Chris Patterson

unread,
Aug 12, 2011, 9:02:56 AM8/12/11
to masstrans...@googlegroups.com
Which is why a log is the easier solution. :)

Krzysztof Koźmic

unread,
Aug 12, 2011, 9:04:37 AM8/12/11
to masstrans...@googlegroups.com
:) most certainly

David Christiansen

unread,
Aug 15, 2011, 11:28:37 AM8/15/11
to masstrans...@googlegroups.com
Hi All,
I don't know if it helps but I have created a 'blank' sample solution that includes WCF client / server with the startings of MassTransit integration here: 


It really is a blank canvas but should hopefully make things a bit quicker to get a WCF/Castle/NH/MassTransit Request-Response sample pulled together.


DC

2011/8/12 Krzysztof Koźmic <krzyszto...@gmail.com>
:) most certainly
To post to this group, send email to masstransit-discuss@googlegroups.com.
To unsubscribe from this group, send email to masstransit-discuss+unsub...@googlegroups.com.

For more options, visit this group at http://groups.google.com/group/masstransit-discuss?hl=en.

--
You received this message because you are subscribed to the Google Groups "masstransit-discuss" group.
To post to this group, send email to masstransit-discuss@googlegroups.com.
To unsubscribe from this group, send email to masstransit-discuss+unsub...@googlegroups.com.

For more options, visit this group at http://groups.google.com/group/masstransit-discuss?hl=en.

--
You received this message because you are subscribed to the Google Groups "masstransit-discuss" group.
To post to this group, send email to masstransit-discuss@googlegroups.com.
To unsubscribe from this group, send email to masstransit-discuss+unsub...@googlegroups.com.

For more options, visit this group at http://groups.google.com/group/masstransit-discuss?hl=en.

--
You received this message because you are subscribed to the Google Groups "masstransit-discuss" group.
To post to this group, send email to masstransit-discuss@googlegroups.com.
To unsubscribe from this group, send email to masstransit-discuss+unsub...@googlegroups.com.

For more options, visit this group at http://groups.google.com/group/masstransit-discuss?hl=en.

--
You received this message because you are subscribed to the Google Groups "masstransit-discuss" group.
To post to this group, send email to masstransit-discuss@googlegroups.com.
To unsubscribe from this group, send email to masstransit-discuss+unsub...@googlegroups.com.

For more options, visit this group at http://groups.google.com/group/masstransit-discuss?hl=en.


--
You received this message because you are subscribed to the Google Groups "masstransit-discuss" group.
To post to this group, send email to masstransit-discuss@googlegroups.com.
To unsubscribe from this group, send email to masstransit-discuss+unsub...@googlegroups.com.

For more options, visit this group at http://groups.google.com/group/masstransit-discuss?hl=en.




--

DCCreativeLogo.gif

<David.Christiansen/>

davidchristiansen.com

skype: davidchristiansen

sharpsts.codeplex.com :: dotnetopenauth.net :: dccreativedesign.co.uk


image001.jpg

Paul L

unread,
Aug 17, 2011, 2:16:40 PM8/17/11
to masstransit-discuss
Also, as a small test, I set the HttpContext.Current manually before
the call to Subscribe:

TextWriter output = new StringWriter();
HttpContext.Current = new HttpContext(new HttpRequest("", "http://
localhost", ""), new HttpResponse(output));

Not sure if that proves anything, but may help?



On Aug 15, 4:28 pm, David Christiansen <da...@davidchristiansen.com>
wrote:
> Hi All,
> I don't know if it helps but I have created a 'blank' sample solution that
> includes WCF client / server with the startings of MassTransit integration
> here:
>
> https://github.com/DavidChristiansen/MassTransit-WCFRequestResponseSa...
>
> It really is a blank canvas but should hopefully make things a bit quicker
> to get a WCF/Castle/NH/MassTransit Request-Response sample pulled together.
>
> DC
>
> 2011/8/12 Krzysztof Koźmic <krzysztof.koz...@gmail.com>
> >>>>>>>>>>> It has AspNetCompatibilityRequirement**sMode.Required, but the
> >>>>>>>>>>> exception occurs in InboundMsmqTransport, in using(context.CreateScope())
> >>>>>>>>>>> call on my foo_control_subscriptions queue.
>
> >>>>>>>>>>> I'm not sure I understand it enough, but it seems to me that
> >>>>>>>>>>> there's an assumption that if the bus is used from an app hosted in IIS the
> >>>>>>>>>>> HttpContext is always available and for some reason in this particular case
> >>>>>>>>>>> (managing subscribers) it assumption seems to be wrong.
>
> >>>>>>>>>>> Am I missing something, can I somehow workaround this?
>
> >>>>>>>>>>> I'm running latest build from TeamCity
>
> >>>>>>>>>>> Krzysztof
>
> >>>>>>>>>>> --
> >>>>>>>>>>> You received this message because you are subscribed to the
> >>>>>>>>>>> Google Groups "masstransit-discuss" group.
> >>>>>>>>>>> To post to this group, send email to masstransit-discuss@**
> >>>>>>>>>>> googlegroups.com <masstrans...@googlegroups.com>.
> >>>>>>>>>>> To unsubscribe from this group, send email to
> >>>>>>>>>>> masstransit-discuss+**unsub...@googlegroups.com<masstransit-discuss%2Bun­subs...@googlegroups.com>
> >>>>>>>>>>> .
> >>>>>>>>>>> For more options, visit this group athttp://groups.google.com/*
> >>>>>>>>>>> *group/masstransit-discuss?hl=**en<http://groups.google.com/group/masstransit-discuss?hl=en>
> >>>>>>>>>>> .
>
> >>>>>>>>>>>  --
> >>>>>>>>> You received this message because you are subscribed to the Google
> >>>>>>>>> Groups "masstransit-discuss" group.
> >>>>>>>>> To post to this group, send email to masstransit-discuss@**
> >>>>>>>>> googlegroups.com <masstrans...@googlegroups.com>.
> >>>>>>>>> To unsubscribe from this group, send email to masstransit-discuss+
> >>>>>>>>> **unsub...@googlegroups.com<masstransit-discuss%2Bunsubscribe@googlegrou­ps.com>
> >>>>>>>>> .
> >>>>>>>>> For more options, visit this group athttp://groups.google.com/**
> >>>>>>>>> group/masstransit-discuss?hl=**en<http://groups.google.com/group/masstransit-discuss?hl=en>
> >>>>>>>>> .
>
> >>>>>>>>>  --
> >>>>>>> You received this message because you are subscribed to the Google
> >>>>>>> Groups "masstransit-discuss" group.
> >>>>>>> To post to this group, send email to masstransit-discuss@**
> >>>>>>> googlegroups.com <masstrans...@googlegroups.com>.
> >>>>>>> To unsubscribe from this group, send email to masstransit-discuss+**
> >>>>>>> unsub...@googlegroups.com<masstransit-discuss%2Bunsubscribe@googlegroups­.com>
> >>>>>>> .
> >>>>>>> For more options, visit this group athttp://groups.google.com/**
> >>>>>>> group/masstransit-discuss?hl=**en<http://groups.google.com/group/masstransit-discuss?hl=en>
> >>>>>>> .
>
> >>>>>>>  --
> >>>>> You received this message because you are subscribed to the Google
> >>>>> Groups "masstransit-discuss" group.
> >>>>> To post to this group, send email to masstransit-discuss@**
> >>>>> googlegroups.com <masstrans...@googlegroups.com>.
> >>>>> To unsubscribe from this group, send email to masstransit-discuss+**
> >>>>> unsub...@googlegroups.com<masstransit-discuss%2Bunsubscribe@googlegroups­.com>
> >>>>> .
> >>>>> For more options, visit this group athttp://groups.google.com/**
> >>>>> group/masstransit-discuss?hl=**en<http://groups.google.com/group/masstransit-discuss?hl=en>
> >>>>> .
>
> >>>>>  --
> >>> You received this message because you are subscribed to the Google Groups
> >>> "masstransit-discuss" group.
> >>> To post to this group, send email to masstransit-discuss@**
> >>> googlegroups.com <masstrans...@googlegroups.com>.
> >>> To unsubscribe from this group, send email to masstransit-discuss+**
> >>> unsub...@googlegroups.com<masstransit-discuss%2Bunsubscribe@googlegroups­.com>
> >>> .
> >>> For more options, visit this group athttp://groups.google.com/**
> >>> group/masstransit-discuss?hl=**en<http://groups.google.com/group/masstransit-discuss?hl=en>
> >>> .
>
> > --
> > You received this message because you are subscribed to the Google Groups
> > "masstransit-discuss" group.
> > To post to this group, send email to masstransit-discuss@**
> > googlegroups.com <masstrans...@googlegroups.com>.
> > To unsubscribe from this group, send email to masstransit-discuss+**
> > unsub...@googlegroups.com<masstransit-discuss%2Bunsubscribe@googlegroups­.com>
> > .
> > For more options, visit this group athttp://groups.google.com/**
> > group/masstransit-discuss?hl=**en<http://groups.google.com/group/masstransit-discuss?hl=en>
> > .
>
> --
>
> **
> *
>
> [image: DCCreativeLogo.gif]
>
> <David.Christiansen/>
>
> davidchristiansen.com
>
> skype: davidchristiansen
>
> **
>
> **
>
> sharpsts.codeplex.com :: dotnetopenauth.net :: dccreativedesign.co.uk
>
> *
>
>  image001.jpg
> 1KViewDownload

Paul L

unread,
Aug 17, 2011, 2:09:57 PM8/17/11
to masstransit-discuss
I'm have a similar issue, I have just got the latest bins and I'm
trying out MassTransit for the first time - I'm also a newbie to MSMQ,
so it could be me being stupid. I'm not sure why an HttpContext would
be needed for messaging? I am not using WCF, I simply have a web-
application which I want to handle messages in the background, I am
creating the bus and subscribing in the Application_Start (so the
HttpContext doesn't exist yet).

This is the stack-trace:

at
MassTransit.Context.HttpContextContextStorageProvider.set_SendContext(ISendContext
value) in d:\BuildAgent-03\work\8d1373c869590c5b\src\MassTransit
\Context\HttpContextContextStorageProvider.cs:line 46
at
MassTransit.Context.ContextStorage.set_CurrentSendContext(ISendContext
value) in d:\BuildAgent-03\work\8d1373c869590c5b\src\MassTransit
\Context\ContextStorage.cs:line 51
at MassTransit.Context.ContextScope.FromSendContext[T]
(ISendContext`1 context) in d:\BuildAgent-03\work\8d1373c869590c5b\src
\MassTransit\Context\ContextScope.cs:line 53
at MassTransit.ContextScopeExtensions.CreateScope[T](ISendContext`1
context) in d:\BuildAgent-03\work\8d1373c869590c5b\src\MassTransit
\Context\ContextScopeExtensions.cs:line 29
at MassTransit.SendExtensions.Send[T](IEndpoint endpoint, T
message, Action`1 contextCallback) in d:\BuildAgent-03\work
\8d1373c869590c5b\src\MassTransit\SendExtensions.cs:line 34
at
MassTransit.Services.Subscriptions.Client.SubscriptionCoordinator.Send[T]
(T message) in d:\BuildAgent-03\work\8d1373c869590c5b\src\MassTransit
\Services\Subscriptions\Client\SubscriptionCoordinator.cs:line 251
at
MassTransit.Services.Subscriptions.Client.SubscriptionCoordinator.SendAddSubscription(SubscriptionInformation
info) in d:\BuildAgent-03\work\8d1373c869590c5b\src\MassTransit
\Services\Subscriptions\Client\SubscriptionCoordinator.cs:line 394
at
MassTransit.Services.Subscriptions.Client.SubscriptionCoordinator.SubscribedTo[TMessage]
(Uri endpointUri) in d:\BuildAgent-03\work\8d1373c869590c5b\src
\MassTransit\Services\Subscriptions\Client
\SubscriptionCoordinator.cs:line 177
at
MassTransit.Services.Subscriptions.SubscriptionPublisher.SubscribedTo[TMessage]
() in d:\BuildAgent-03\work\8d1373c869590c5b\src\MassTransit\Services
\Subscriptions\SubscriptionPublisher.cs:line 53
at
MassTransit.Pipeline.Configuration.InboundPipelineConfigurator.<>c__DisplayClass2`1.<SubscribedTo>b__1(ISubscriptionEvent
x) in d:\BuildAgent-03\work\8d1373c869590c5b\src\MassTransit\Pipeline
\Configuration\InboundPipelineConfigurator.cs:line 56
at System.Collections.Generic.List`1.ForEach(Action`1 action)
at
MassTransit.Util.RegistrationList`1.<>c__DisplayClass8.<Each>b__7(List`1
x) in d:\BuildAgent-03\work\8d1373c869590c5b\src\MassTransit\Util
\RegistrationList.cs:line 51
at
Magnum.Threading.ReaderWriterLockedObject`1.<>c__DisplayClass1.<ReadLock>b__0(ReaderWriterLockContext
x) in d:\Builds\MassTransit-Magnum\src\Magnum\Threading
\ReaderWriterLockedObject.cs:line 56
at Magnum.Threading.ReaderWriterLockContext.ReadLock(Action`1
action) in d:\Builds\MassTransit-Magnum\src\Magnum\Threading
\ReaderWriterLockContext.cs:line 52
at Magnum.Threading.ReaderWriterLockedObject`1.ReadLock(Action`1
action) in d:\Builds\MassTransit-Magnum\src\Magnum\Threading
\ReaderWriterLockedObject.cs:line 57
at MassTransit.Util.RegistrationList`1.Each(Action`1 action) in d:
\BuildAgent-03\work\8d1373c869590c5b\src\MassTransit\Util
\RegistrationList.cs:line 52
at
MassTransit.Pipeline.Configuration.InboundPipelineConfigurator.SubscribedTo[TMessage]
() in d:\BuildAgent-03\work\8d1373c869590c5b\src\MassTransit\Pipeline
\Configuration\InboundPipelineConfigurator.cs:line 58
at
MassTransit.SubscriptionConnectors.HandlerSubscriptionConnector`1.Connect(IInboundPipelineConfigurator
configurator, HandlerSelector`1 handler) in d:\BuildAgent-03\work
\8d1373c869590c5b\src\MassTransit\Configuration\SubscriptionConnectors
\HandlerSubscriptionConnector.cs:line 32
at
MassTransit.HandlerSubscriptionExtensions.<>c__DisplayClass1`1.<SubscribeHandlerSelector>b__0(IInboundPipelineConfigurator
x) in d:\BuildAgent-03\work\8d1373c869590c5b\src\MassTransit
\Configuration\HandlerSubscriptionExtensions.cs:line 92
at MassTransit.Pipeline.InboundMessagePipeline.Configure[TResult]
(Func`2 configureCallback) in d:\BuildAgent-03\work\8d1373c869590c5b
\src\MassTransit\Pipeline\InboundMessagePipeline.cs:line 49
at MassTransit.ServiceBus.Configure(Func`2 configure) in d:
\BuildAgent-03\work\8d1373c869590c5b\src\MassTransit
\ServiceBus.cs:line 208
at
MassTransit.HandlerSubscriptionExtensions.SubscribeHandlerSelector[T]
(IServiceBus bus, HandlerSelector`1 handler) in d:\BuildAgent-03\work
\8d1373c869590c5b\src\MassTransit\Configuration
\HandlerSubscriptionExtensions.cs:line 92
at MassTransit.HandlerSubscriptionExtensions.SubscribeHandler[T]
(IServiceBus bus, Action`1 handler) in d:\BuildAgent-03\work
\8d1373c869590c5b\src\MassTransit\Configuration
\HandlerSubscriptionExtensions.cs:line 53
at MedDBase.RemoteClientServices.MsmqMessageQueue.Subscribe[T]
(Int32 chamber, Action`1 handler) in C:\DevTeam\Branches\Programmers
\Paul\Tests\AppTest.RemoteClientServices\TestApp.RemoteClientServices
\MessageQueue.cs:line 60

The bus is being generated as per the example code:

var bus = ServiceBusFactory.New(sbc =>
{
sbc.UseMsmq();
sbc.VerifyMsmqConfiguration();
sbc.UseMulticastSubscriptionClient();
sbc.ReceiveFrom(name);
});

Then when I subscribe I get the exception:

bus.SubscribeHandler<T>(handler);

Paul L

unread,
Aug 17, 2011, 3:38:17 PM8/17/11
to masstransit-discuss
Ok, got the latest using NuGet and all is good. Move along now... ;-)

Chris Patterson

unread,
Aug 17, 2011, 5:35:46 PM8/17/11
to masstrans...@googlegroups.com
I was going to say, from that call stack, I knew that was the old build. :)

Glad you got it working!

On Wed, Aug 17, 2011 at 2:38 PM, Paul L <p.l...@gmail.com> wrote:
Ok, got the latest using NuGet and all is good.  Move along now... ;-)
--
You received this message because you are subscribed to the Google Groups "masstransit-discuss" group.
To post to this group, send email to masstrans...@googlegroups.com.
To unsubscribe from this group, send email to masstransit-dis...@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages