Azure Service Bus client: Best way to wait for server response?

Hi,
I have a web service that needs to send a request on Azure Service Bus and wait for the response. The web service must operate synchronous as seen from the web service client, that is:
public Response WebServiceMethod(Request)
senderQueueClient.Send(Request);
// wait for response from receiverQueueClient
// and return to web serviuce client
return response;
This can be solved using mutexes that are updated in "receiverClientQueue.OnMessage". But that is hard work and if I Google the matter, I find several options to deal with this - especially when using .NET 4.5.  And there are also some built-in
stuff in the QueueClient.
But how to do this best? Can someone point me in the right (easy) direction?
Werner

Hi,
May I know what are you use queue to achieve? can you give us further information for a better help.
Regards

Similar Messages

  • How to make my object to wait for server response

    Hi ,
    I need some one suggestions on thread concepts.
    First Let me know my scenario is fit for thread concept.
    is it possible then how I can reach to solution.
    I have scenario like
    I send a request to server and server is taking some time to process the request.
    if I am calling the method on server it showing no results bez i know server takes some time.
    for that my calling method has to be wait for some time.
    Thanks
    Babu H

    Hi ,
    Let me give more information about that between my java class and server
    i have the bridge library which is also written in other than java.
    for that i used the njawin tool make as java wrapper class and accessing the java wrapper class(Bridge Server).
    the java wrapper class has post_request and poll_response methods so that why i 'm using only these methods in my java class to access the server.
    exactly I don't which technology is resided in Brdige server and actual Server bez that has been developed some one.
    poll_respnse means server has posted the response to client.
    Thanks
    Babu H

  • Jakarta HTTPClient , dont wont to wait for a response.

    Hi there.
    I wonder if I can do that , I want to send a post\get request to another server but I don�t want to wait for a response from it.
    Actually, I want to continue with my program regardless to the response and don�t want to be delayed while waiting.
    How can I do it?
    Hope I made myself clear, thanks.
    Shlomi

    spawn a Thread that will send the request. When it's time to process the response, check the Thread to see if any response was returned from the server.
    example
    public class MyThread extends Thread{
        private String response = null;
        private int status = 0;
        private boolean complete = false;
        public void run(){
             // TODO: et the response from the server
             // set the response and status and complete (synchronize all variable when doing this)
        public boolean isComplete(){
            return complete;
        public String getStatus(){ return status; }
        public String getResponse(){ return response; }
    public class Demo(){
        public static void main(String args[]){
            // do some work
            MyThread thread = new MyThread();
            thread.start();
            // do some more work (don't wait for server response
            // now it's time to get the response
            while (!thread.isComplete()){
                try{   Thread.sleep(1000); } // sleep for 1 second
                catch (Exception e){ }
            String response = thread.getResponse();

  • Azure Service Bus Relay & Impersonation

    Hi All,
    I am currently investigating the use of Azure Service Bus Relay for a project, testing has gone well so far and I have a service and client communicating via the service bus relay.
    Currently the client and server are able to take part in two way communication, whereby the client invokes a method and a response is sent back to the client, the problem I have is that I now
    want the service to impersonate the user calling the methods, but only for some of the methods available in the service.  Is this possible over a service bus relay connection? if so, how can this be achieved. 
    I have been able to get this working when calling the service over a non-service bus binding (using basic authentication over SSL), but this fails when binding to the service bus relay, I believe because the HTTP context is lost between the client and
    server when communicating via the intermediary (in this case the service bus)
    Thanks in advance for the advice.
    Chris

    Hi,
    I would suggest that you contact to Azure Support for respective subscription
    Please refer following to know how to submit support ticket
    http://blogs.msdn.com/b/mast/archive/2013/01/22/windows-azure-customer-support-offerings-live-how-to-contact-microsoft-windows-azure-technical-support.aspx
    hope this helps

  • Azure service bus queue: Why do I keep getting a MessageLockLostException?

    I read a post that dealt with the same problem I'm having. It is located at https://social.msdn.microsoft.com/Forums/en-US/069653b5-c233-4942-85b2-9eb50b3865c7/azure-service-bus-subscription-how-do-i-delete-the-message-when-i-receive-a?forum=servbus
    I'm calling message.Complete() and I'm getting the MessageLockLostException but the difference with my issue is that I used the code that someone posted to fix the issue and it isn't working for me. I have pasted my full code below to show you how my program
    is working. What am I doing wrong and/or how do I fix this issue?
    static void Main(string[] args)
    try
    string connectionString = CloudConfigurationManager.GetSetting("Microsoft.ServiceBus.ConnectionString");
    QueueClient client = QueueClient.CreateFromConnectionString(connectionString, "OoplesQueue");
    var actionBlock = new ActionBlock<BrokeredMessage>(async message =>
    await processCalculations(message),
    new ExecutionDataflowBlockOptions
    MaxDegreeOfParallelism = Environment.ProcessorCount
    var produceMessagesTask = Task.Run(async () => await
    ProduceBrokeredMessagesAsync(client,
    actionBlock));
    produceMessagesTask.Wait();
    catch (Exception ex)
    Console.WriteLine(ex.Message);
    Console.WriteLine(ex.StackTrace);
    private static async Task ProduceBrokeredMessagesAsync(QueueClient client,
    ActionBlock<BrokeredMessage> actionBlock)
    BrokeredMessage message;
    while ((message = await client.ReceiveAsync()) != null)
    await actionBlock.SendAsync(message);
    public static ConnectionMultiplexer connection;
    public static IDatabase cache;
    public static async Task processCalculations(BrokeredMessage message)
    var brokeredMessageRenewCancellationTokenSource = new CancellationTokenSource();
    try
    if (message != null)
    if (connection == null || !connection.IsConnected)
    connection = await ConnectionMultiplexer.ConnectAsync("connectionString");
    //connection = ConnectionMultiplexer.Connect("ConnectionString,SyncTimeout=10000,ConnectTimeout=10000");
    cache = connection.GetDatabase();
    var brokeredMessageRenew = Task.Run(async () =>
    while (!brokeredMessageRenewCancellationTokenSource.Token.IsCancellationRequested)
    //Based on LockedUntilUtc property to determine if the lock expires soon
    if (DateTime.UtcNow > message.LockedUntilUtc.AddSeconds(-10))
    // If so, we repeat the message
    await message.RenewLockAsync();
    }, brokeredMessageRenewCancellationTokenSource.Token);
    string sandpKey = message.Properties["sandp"].ToString();
    string dateKey = message.Properties["date"].ToString();
    string symbolclassKey = message.Properties["symbolclass"].ToString();
    string stockdataKey = message.Properties["stockdata"].ToString();
    string stockcomparedataKey = message.Properties["stockcomparedata"].ToString();
    var sandpTask = cache.GetAsync<List<StockData>>(sandpKey);
    var dateTask = cache.GetAsync<DateTime>(dateKey);
    var symbolinfoTask = cache.GetAsync<SymbolInfo>(symbolclassKey);
    var stockdataTask = cache.GetAsync<List<StockData>>(stockdataKey);
    var stockcomparedataTask = cache.GetAsync<List<StockMarketCompare>>(stockcomparedataKey);
    await Task.WhenAll(sandpTask, dateTask, symbolinfoTask,
    stockdataTask, stockcomparedataTask);
    List<StockData> sandp = sandpTask.Result;
    DateTime date = dateTask.Result;
    SymbolInfo symbolinfo = symbolinfoTask.Result;
    List<StockData> stockdata = stockdataTask.Result;
    List<StockMarketCompare> stockcomparedata = stockcomparedataTask.Result;
    StockRating rating = performCalculations(symbolinfo, date, sandp, stockdata, stockcomparedata);
    if (rating != null)
    saveToTable(rating);
    await message.CompleteAsync();
    else
    Console.WriteLine("Message " + message.MessageId + " Completed!");
    await message.CompleteAsync();
    catch (TimeoutException time)
    Console.WriteLine(time.Message);
    catch (MessageLockLostException locks)
    Console.WriteLine(locks.Message);
    catch (RedisConnectionException redis)
    Console.WriteLine("Start the redis server service!");
    catch (MessagingCommunicationException communication)
    Console.WriteLine(communication.Message);
    catch (Exception ex)
    Console.WriteLine(ex.Message);
    Console.WriteLine(ex.StackTrace);
    finally
    // Lock is stopped renewing task
    brokeredMessageRenewCancellationTokenSource.Cancel();

    Below check assumes there's no clock skew between you and the Service Bus server. If there's a time difference more than 10 seconds then you may end up with renew attempts after message expires.
    if (DateTime.UtcNow
    > message.LockedUntilUtc.AddSeconds(-10))
    And I suggest you to add a sleep in the renew loop. It's an overkill to make this check a million times every second. Doing this once a second should be fine.

  • BizTalk 2013 SB-Messaging Adapter: Unable to receive messages from a Azure service bus Subscription

    Hi,
    I am trying to receive messages from a Azure service bus subscription using SB-Messaging Adapter in BizTalk Server 2013 but getting the following error.
    "The token provider was unable to provide a security token while accessing 'https://overcasb-sb.accesscontrol.windows.net/WRAPv0.9/'.
    Error Code: 407 Proxy Authentication Required. The ISA Server requires authorization to fulfill the request. Access to the Web Proxy filter is denied. (12209)
    It seems the error is related with Service Bus Authentication and Authorization with the Access Control Service. Can anybody help me out if I am missing something here? 
    Also for consuming the AWSB (namespace, topic name, subscription name, Issuer name, Issuer Key) I have referred the following link
    http://soa-thoughts.blogspot.in/2013/02/biztalk-server-2013-new-adapters-series.html
    Thanks!
    Regards,
    Gautam
    gautam

    Hi,
    When I am trying to receive the same messages from a Azure service bus subscription using .net (C#) client,
    BusSubscriberbusSubscriber =
    newBusSubscriber("TestTopic2",
    "Endpoint=sb://overcasb.servicebus.windows.net/;SharedSecretIssuer=owner;SharedSecretValue=wqYlT4yHZimeUZacH+1V1hj/ZrKu7zK9ELaaLYDxqjc=",
    "AssetMovement",
    "AssetMovement");
    I am getting the same error here also.
    "The token provider was unable to provide a security token while accessing 'https://overcasb-sb.accesscontrol.windows.net/WRAPv0.9/'.
    Error Code: 407 Proxy Authentication Required. The ISA Server requires authorization to fulfill the request. Access to the Web Proxy filter is denied. (12209)
    By setting  <defaultProxy useDefaultCredentials="true" /> in appconfig, I got rid of the above error. And now its working fine with .net(C#) client.
    <configuration>
      <system.net>
        <defaultProxy useDefaultCredentials="true" />
      </system.net>
    </configuration>
    The same setting I tried in BTSNTSvc.exe config file and ofcourse restarted the host instance but still getting the same error. Any help?
    gautam

  • Some concept confused for Azure Service Bus EventHub

    Currently, I’m trying to use the Azure Service Bus Event hub and I have some concepts a little bit confused:
    I have create an event hub (our requirement is send 10Kb data per seconds to the event hub), the hub include 10 partitions, then we receive the data using the
    EventHubReceiver, when I create the instance for the EventHubReceiver, it need the
    PartitionId, so I want to know which partitionId is needed?
     I guess all the Partitions have the same data which I sended, is it right?
    Is the PartitionId equals PartitionKey? My understanding is the PartitionId is the indicator for the Partitions in the Event Hub, the PartitionKey is the indicator for the device which send the data, so one Partition can contains many partitonIds,
    is it right?
    When we receive data from hub, we need set the Consumer Group, so what is the relationship between EventHub and Consumer group?
    When we use the EventProcessorHost to receive data, we do not to set the PartitionId, so the data we got is the all PartitionData?
    When we call the PartitionContext.CheckpointAsync(), the Event hub will do the things to release the Events(delete, clear or sth) by itself, we needn’t do it in our code,
    is it right?
    Is there a diagram to show the relationship for concepts of the EventHub?
    Thanks a lot!

    I'd ask them over here.
    Azure forums on MSDN
    Regards, Dave Patrick ....
    Microsoft Certified Professional
    Microsoft MVP [Windows]
    Disclaimer: This posting is provided "AS IS" with no warranties or guarantees , and confers no rights.

  • Which Nuget Package for Azure Service Bus can I use for Windows Store apps?

    Hi,
    I want to use the Azure Service Bus Topics. I have an app that needs to subscribe to the Service bus Topic. The Nuget-Package for Azure Service Bus is not applicable for Windows Store Apps (I get an error during install), thats why I used the Windows Azure
    Service Bus managed for Windows Store. Unfortunatelly this API throws a Serialization Exception when I create a subscription. What can I do to use the Service bus in Windows store apps?
    Thats how I try to create the subscription:
    await Microsoft.WindowsAzure.Messaging.Subscription.CreateAsync(TOPIC_NAME, SUBSCRIPTION_NAME, CONNECTION_STRING);

    Yes this is the one I used.
    But creating a subscription with the code above throws the SerializationException mentioned in this question:
    http://social.msdn.microsoft.com/Forums/de-DE/1acb887e-d5f1-4bfb-8eb9-f8ce7390ae7b/microsoftwindowsazuremessagingsubscriptioncreateasync-throws-an?forum=servbus&prof=required.
    Maybe I do something wrong? Do I Need to do something before creating the subscription?
    I haven't found any sample that shows how you can subscribe to a Topic and receive Messages using the restricted Api for winrt :(
    Any suggestions?

  • Receive location using SBMessaging adapter disabled when Azure service bus is down

    Does anybody experience  SBMessaging receive locations are disabled when Azure service bus is unavailable with a MessagingCommunicationException?  Is this an expected behavior / 'by design'? We see this exception a few times a day.  I don't
    see any retry attempts based on the event log.  Our current solution is to have a powershell script that enables the receive location if it's disabled.  This script runs every 15 minutes.  Below is a sample of the error in the event log.
    The receive location "Warnings_SB_New" with URL "XXXXXX" is shutting down. Details:"System.ServiceModel.EndpointNotFoundException: Error during communication with Service Bus. Check the connection information, then retry. --->
    Microsoft.ServiceBus.Messaging.MessagingCommunicationException: Error during communication with Service Bus. Check the connection information, then retry. ---> System.ServiceModel.CommunicationObjectFaultedException: Internal Server Error: The server did
    not provide a meaningful reply; this might be caused by a premature session shutdown..TrackingId:bb29d71c-a4d5-430c-a2d9-8a2e3acfad1d, Timestamp:5/9/2014 2:38:19 AM

    Hi R. de Veen,
    Below as the script we used with BTS2013.  We created a command line and setup a scheduled task.  Again, we don't use this script with BTS2013R2 since we do not have this issue with BTS2013 R2.
    # Sample from https://github.com/tomasr/bts-ps-scripts/blob/master/bts-ports.ps
    # declare our parameters: the action to take
    param(
    [string] $action=$(throw 'need action'),
    [string] $name
    $ctpRLs = @(
    'Errors_SB_New'
    #,'Error_OldTopic_OldLoggingDB'
    ,'Information_SB_New'
    ,'Warnings_SB_New'
    #,'Information_NewTopic_OldLoggingDB'
    ,'Critical_SB_New'
    #'Critical_OldTopic_OldLoggingDB'
    # functions for pinging receive locations
    function uti-ping-recv-loc
    foreach ($rl in $ctpRLs)
    Write-Host "`n"
    if (( $rl -eq '') -or ($rl -eq $null))
    throw "Receive location cannot be blank."
    #Validate if this is a valid receive location
    $recvloc = get-wmiobject MSBTS_ReceiveLocation `
    -namespace 'root\MicrosoftBizTalkServer' `
    -filter "Name='$rl'"
    if ($recvloc -eq $null)
    Write-Host "'$rl' does not exist. Skipping..." -foregroundcolor red -backgroundcolor black
    else
    Write-Host "Ping '$rl'..."
    if ($recvloc.IsDisabled)
    Write-Host "Restarting '$rl'..."
    bts-set-recv-loc-status -name $rl -status 'enable'
    Start-Sleep -s 10
    if ($recvloc.IsDisabled)
    Write-Host "Failed to enable $rl. Check the event log for more information." -foregroundcolor red -backgroundcolor black
    else
    Write-Host "'$rl' is enabled."
    else
    Write-Host "'$rl' is enabled."
    $i++
    Write-Host "`nComplete!!!`n`n" -foregroundcolor green -backgroundcolor black
    # enable or disable the specified
    # receive location
    function bts-set-recv-loc-status($name, $status)
    $recvloc = get-wmiobject MSBTS_ReceiveLocation `
    -namespace 'root\MicrosoftBizTalkServer' `
    -filter "Name='$name'"
    switch ( $status )
    'disable' { [void]$recvloc.Disable() }
    'enable' { [void]$recvloc.Enable() }
    # controls a send port
    function bts-set-send-port-status($name, $status)
    $sendport = get-wmiobject MSBTS_sendPort `
    -namespace 'root\MicrosoftBizTalkServer' `
    -filter "Name='$name'"
    switch ( $status )
    'start' { [void]$sendport.Start() }
    'stop' { [void]$sendport.Stop() }
    'enlist' { [void]$sendport.Enlist() }
    'unenlist' { [void]$sendport.UnEnlist() }
    function is-valid-opt($check, $options)
    foreach ( $val in $options )
    if ( $check -eq $val ) {
    return $true
    # main script
    switch ( $action )
    'ping-recv-loc' {
    uti-ping-recv-loc
    Write-Host "`n"
    Write-Host "Syntax: .\RestartELCRLs.ps1 ping-recv-loc"
    Write-Host "`n"

  • New MBP - Best way to care for battery?

    Not sure if this is necessary anymore, but I am receiving my new MBP in the mail later today. What is the best way to care for the battery? Should I plug the MBP into the wall for an amount of time before turning it on, or at least wait until it is fully charged before turning it on for the first time? Is anything like that even necessary anymore?
    Thanks,
    Keith

    Here's what Apple recommends:
    http://www.apple.com/batteries/notebooks.html
    Best use is frequently and lightly. Be sure to calibrate your battery every two months or so:
    http://docs.info.apple.com/article.html?artnum=86284
    Hope this helps...

  • Custom IAC applications the best way to go for putting R/3 screens on web?

    Hi all,
    I am trying to figure out whether a Custom IAC would be a best way to go for putting custom developed R/3 transaction on the web. We want to put the R/3 transactions on the web but want to completely customize the look and feel of it. Is IAC the best way to go for it? will this work with any kind of transactions?
    cheer,
    i028982

    Hello,
    The ITS might not be the "best" way, but it sure would be an easy way.  If the transaction and screens are already created in the R/3 then you could just go to SE80 and create HTML templates to see if it will do what you want.  Steps:
    1. Transaction SE80
    2. Choose "Internet Service"
    3. Type in a custom developed z* name
    4. Right-click on the z* name and choose Create > Theme
    5. Create theme 99 (standard theme)
    6. Right-click on the z* name again and choose Create > Template
    7. Type in all information, theme number, program name and screen number.  Play with the "Generation Style" to see which one would better fit your transaction.
    After creating the screens you can publish to your ITS and give it a test.  Maybe this is all you need, if so, it would be fast and readily available.
    Best regards,
    Edgar Chuang

  • What is the best way to prepare for CERTIFICATION?

    what is the best way to prepare for CERTIFICATION?
    what is needed?
    where can i read more about it?

    Hi,
    Do as much as possible exercises based on your course material(which will be more than enough).
    If you know (some) Java and have understand the basics of OOP then this is enough for the exam.
    And do not forget:
    it is a multiple-choice test meaning that you see the possible answers.
    Either a single answer is correct (then you will have radio-buttons) or several answers are correct
    (then you will have checkboxes; in this case almost all questions will have more than one correct answer).
    You can refer to the topics for the certification
    https://websmp102.sap-ag.de/~sapidp/011000358700000499112003E
    Some links which might help
    /message/213564#213564 [original link is broken]
    /message/514469#514469 [original link is broken]
    /message/1315746#1315746 [original link is broken]
    /message/1736299#1736299 [original link is broken]
    /message/1736299#1736299 [original link is broken]
    /message/257122#257122 [original link is broken]
    /message/130164#130164 [original link is broken]
    /message/1916905#1916905 [original link is broken]
    /thread/167254 [original link is broken]
    /message/213564#213564 [original link is broken]
    /message/1315746#1315746 [original link is broken]
    <b>
    you try www.sapdoamin.com
    They provide Certification simulation questions which are veryuseful and a must try site.</b>
    Yes more questions comes on OOPS so get your OOPS concepts very clear.
    You don't need to do extensive coding in OOPS.
    Just get the concepts clear and i am sure the certification will be a cake walkthrough.
    All the best and good luck with your ABAP Accreditation.

  • How to call a ALSB Proxy Service and don't wait for his response. Publish M

    Hi,
    I have a Proxy Service called PS1 that will invoke and another Proxy service Called PS_ProcessingNode that invokes 10 differents webservices during the orchestration and takes about 2 minuts.
    I would like that if invoke PS1 that will invokes PS_ProcessingNode (asyncronously) and immediatly PS1 will return "OK" (don't wait for the response of PS_ProcessingNode) .
    For simulate this scenario I am testing with:
    - PS_Processing is a WSDL without response that has a JavaCallout with a Sleeper of 10 seconds.
    - PS invokes with "Publish action" to PS_ProcessingNode but is waiting for PS_Processsing finish. I don't want this beahivour.
    How I can do it for PS doesn't wait for the response of the PS_ProcessingNode?
    Thanks.

    - PS invokes with "Publish action" to PS_ProcessingNode but is waiting for PS_Processsing finish. I don't want this behavior.
    I'm glad you have a solution using JMS. But still Publish action should not wait for response. If you are seeing that behavior, you can contact Support with an SR to get it fixed.
    Manoj

  • What would the best way to go for an virtual grid?

    I need a 3 x 8 virtual grid that I can change values to:
    Red
    Blue
    Spoiler
    what would the best way to go for this objective?
    Thanks!

    I need a 3 x 8 virtual grid that I can changevalues
    to:
    Red
    Blue
    Spoiler
    what would the best way to go for this objective?
    Thanks!Create a Grid and a Tile class. A
    Grid has a 2D array of Tile objects an
    a Tile has an attribute called Color and, say,
    an x- and y-point. Program some appropriate methods.
    Done.
    Thanks for trying, but Nanook already gave the correct answer in reply 1.Is it possible to restrict these? to like a 8 x 3 grid ?
    or should i use an if statement?

  • What is the best way to export for use on internet?

    what is the best way to export for use on internet?

    It depends. Is this for a personal web site or for a site like YouTube, Vimeo or Facebook?
    For YouTube, Vimeo and Facebook, use Publish & Share/Computer/AVCHD using one of the YouTube presets.

Maybe you are looking for

  • Data In R/3 is present but not in BW

    Hi experts i got thiss problem in last extraction i have 5 fields in r/3 which having data but in BW one feild is not getting data remain 4 r showing data what could be the problem ? n how to solve it?plz let me know Thanks in advance. bye jay

  • Problems accessing Objects created by JSF

    I have a JSF page: <h:form id="LoginForm">           <tr><td><h:outputText value="#{msg.username}"/></td>                <td><h:inputText id="username" value="#{userBean.username}" validator="#{loginValidator.validateUsername}" required="true"/></td>

  • Incrementing the sub jobs

    <jobs> <job> <joblines> <jobline firstfield="a" secondfield="b"> <jobline firstfield="c" secondfield="d"> </joblines> </job> <job> <joblines> <jobline firstfield="e" secondfield="f"> </joblines> </job> <job> <joblines> <jobline firstfield="g" secondf

  • Contact Person Re-assignment

    Hi, Currently i have, lets say a Contact Person code A assigned to Customer B. Then this Contact Person is being transfered to another site which in our system is represented as a different Customer Code. My question, is there a way to re-assign this

  • Confused with hotspots/slices

    Hi, totally new to this. Perhaps someone could help me: I have Fireworks and Dreamweaver CS3. I have an image I created in Fireworks and within that image I am trying to create a navigation bar using just text. I thought that I could just make rectan