none
Azure Service Bus Issues RRS feed

  • Question

  • Hi Experts,

    Here is my query.

    I am sending a message to Azure Service Bus from Web API on Cloud/from my local and every second message is hanging.

    If i am waiting for 1-2 minutes and try trying to send again and its working for the first time and second time again hanging at this step.

    Client.Send(message);

    Below is the code.  However when I am trying to send using Service Bus Explorer, its working just fine.. I can send multiple messages at the same time.  

    Do you guys know what could be the issue? 

     ServiceBusEnvironment.SystemConnectivity.Mode = ConnectivityMode.Https;

                MessagingFactorySettings factorySettings = new MessagingFactorySettings()
                {
                    TokenProvider = TokenProvider.CreateSharedAccessSignatureTokenProvider(sasKeyName, sasKey),
                    OperationTimeout = TimeSpan.FromSeconds(1),
                };

                var stream = GenerateStreamFromString(messageBody);


                BrokeredMessage message = new BrokeredMessage(stream) { ContentType = "application/json" };
                try
                {
                    MessagingFactory messagingFactory = MessagingFactory.Create(sbUri, factorySettings);
                    QueueClient Client = messagingFactory.CreateQueueClient(queuename, ReceiveMode.PeekLock);
                    Client.Send(message);
                    message.Abandon();
                    Client.Close();
                    messagingFactory.Close();
                }


    Thanks, Varun

    Thursday, February 22, 2018 4:44 PM

All replies

  • Why are you invoking Abandon() on the message?

    Abandon is used for receive operations when you want to just skip a message.

    Since you're sending the message....don't do that! :)

    Thursday, February 22, 2018 4:48 PM
  • Hi John,

    Sure , i was try if that help but without last 3 lines of code as well, it is showing the same behaviour.

    Do you have any idea what could be the cause ?

    Thanks,

    Varun


    Thanks, Varun

    Friday, February 23, 2018 7:39 AM
  • The Service Bus docs have a lot of code samples.  Try those first and then modify to suit your needs.

    Get started with Service Bus queues

    You can jump to Section 3.

    Friday, February 23, 2018 12:17 PM