NServiceBus 5.0.0: InvalidOperationException on processing bus events from Azure ServiceBus

297 views
Skip to first unread message

Rob Levine

unread,
Oct 11, 2014, 11:02:21 AM10/11/14
to particula...@googlegroups.com
Helpful information to include
Product name: NServiceBus
Version: NSB 5.0.0 with NServiceBus.Azure.Transports.WindowsAzureServiceBus 6.0.0 / NSB 5.0.1 with NServiceBus.Azure.Transports.WindowsAzureServiceBus 6.0.1
Stacktrace:
2014-10-11 15:51:00.224 INFO  NServiceBus.Unicast.Transport.TransportReceiver Failed to process message
System.InvalidOperationException: This operation is only supported for a message receiver in 'PeekLock' receive mode.
   at Microsoft.ServiceBus.Messaging.BrokeredMessage.ThrowIfNotLocked()
   at Microsoft.ServiceBus.Messaging.BrokeredMessage.Complete()
   at NServiceBus.Azure.Transports.WindowsAzureServiceBus.BrokeredMessageExtensions.SafeComplete(BrokeredMessage msg) in c:\BuildAgent\work\9e81da84cea5f13f\src\NServiceBus.Azure.Transports.WindowsAzureServiceBus\Utils\BrokeredMessageExtensions.cs:line 16
   at NServiceBus.Azure.Transports.WindowsAzureServiceBus.AzureServiceBusDequeueStrategy.TryProcessMessage(Object obj) in c:\BuildAgent\work\9e81da84cea5f13f\src\NServiceBus.Azure.Transports.WindowsAzureServiceBus\Receiving\AzureServiceBusDequeueStrategy.cs:line 157

Description:

I have a simple Client and Server test application. The client sends a single command using Bus.Send. This is processed by a Saga on the server which, in return, publishes an event to be handled by the client.
The client send, server receive and server publish all work correctly. 
However, when the client handler receives the message, the Handle method executes, but the above exception is logged after the handler has completed executing.

This is an extremely simple test app with minimal configuration. Both client and server endpoints are as follows have the following configurations:

    public class EndpointConfig : IConfigureThisEndpoint, AsA_Server
    {
        public void Customize(BusConfiguration configuration)
        {
            configuration.Conventions().DefiningCommandsAs(t => t.Namespace != null && t.Namespace.EndsWith("Commands"));
            configuration.Conventions().DefiningEventsAs(t => t.Namespace != null && t.Namespace.EndsWith("Events"));

            configuration.UseTransport<AzureServiceBusTransport>();
            configuration.UsePersistence<InMemoryPersistence>();
        }
    }

[the client specifies AsA_Client, not AsA_Server].

Both specify a working AzureServiceBusQueueConfig connection string in their app.config, plus the client also specifies the following endpoint mapping:

    <MessageEndpointMappings>
      <add Messages="NSBAzure.Messages" Type="NSBAzure.Messages.Events.NotifyUserReceived" Endpoint="nsbazure.server" />
    </MessageEndpointMappings>

Have I missed some configuration or misunderstood how this should work, or is this a bug in the Azure Service Bus event handling?

Thanks,

Rob

Sean Feldman

unread,
Oct 13, 2014, 12:47:21 PM10/13/14
to particula...@googlegroups.com
Hi Rob,
What version of Microsoft Azure ServiceBus assembly you're using?

Rob Levine

unread,
Oct 13, 2014, 3:46:55 PM10/13/14
to particula...@googlegroups.com
Hi Sean,

I'm using the 2.4.4.0 NuGet package (specifically, the dll is version 2.4.40930.0).

I think I saw the same problem with 2.2.0.0 too.

Thanks,

Rob

Sean Feldman

unread,
Oct 14, 2014, 12:51:06 AM10/14/14
to particula...@googlegroups.com
Hi Rob,

I have tried your scenario and it's working. 2 differences I spotted:
  1. AsA_Server doesn't exist any more. Use AsA_Worker instead (or AsA_Host for dynamic host).
  2. Your messages mapping didn't have command mapped. I assume you just omitted it.
Could you create a reproduction of your issue in a public repo?

Yves Goeleven

unread,
Oct 14, 2014, 3:23:22 AM10/14/14
to particula...@googlegroups.com
@Rob Which host are you using? Sounds like the regular nsb host exe, right?

In that case AsA_Server is still what you want, (@sean AsA_Worker and AsA_Host are part of the azure hosting infrastructure)

It sounds like there is something wrong when running transactionless receives... I'll look into this a bit deeper

Rob Levine

unread,
Oct 14, 2014, 3:28:11 AM10/14/14
to particula...@googlegroups.com

Hi Yves and Sean,

Thanks for replying.
Yves: yes, I'm using the regular nsb host for both client and server.

If I get a chance later, I'll post a gist if you think that might help.

Thanks,

--
You received this message because you are subscribed to a topic in the Google Groups "Particular Software" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/particularsoftware/05Q5vD5p9Ms/unsubscribe.
To unsubscribe from this group and all its topics, send an email to particularsoftw...@googlegroups.com.
To post to this group, send email to particula...@googlegroups.com.
Visit this group at http://groups.google.com/group/particularsoftware.
To view this discussion on the web visit https://groups.google.com/d/msgid/particularsoftware/5ed07371-b99d-4304-b914-3b679325743a%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Yves Goeleven

unread,
Oct 14, 2014, 3:41:22 AM10/14/14
to particula...@googlegroups.com
Just got confirmation, AsA_Client is not running transactionally...

then this is a bug that requires fixing... you can work around it for now by enabling transactions (or using AsA_server)


Yves Goeleven

unread,
Oct 14, 2014, 5:49:12 AM10/14/14
to particula...@googlegroups.com
Rob,

You can find version 6.0.2 on nuget, which addresses this issue, which no longer calls complete on transactionless receives

Kind regards,
Yves

Rob Levine

unread,
Oct 14, 2014, 2:19:45 PM10/14/14
to particula...@googlegroups.com
Hi Yves,

Thanks for that - I can confirm my client behaves correctly with the update.

Thanks again,

Rob

Yves Goeleven

unread,
Oct 16, 2014, 6:15:17 AM10/16/14
to particula...@googlegroups.com
Glad to hear!
Reply all
Reply to author
Forward
0 new messages