asp.net web api - Managing huge request with wep abi and parallelizing other jobs in the meantime -


i've web api has deal 200 request in second. main job of web api application is:

  • get request
  • go , find answer cache system (redis or whatever)
  • return result
  • send request azure event hub (for making hourly calculations)

the last step needs done without blocking answer. app needs answer fast in mean time has send request information azure event hub.

im doing with:

public httpresponsemessage post(ourdatamodel datamodel) {     //1 - answer cache     var resultdata = companyfactory.getdata(datamodel);      //2 - sending data azure event hub      var asyncresult = task.run(() => new azureeventhub().senddata(resultdata));     .....      //3 return result     return request.createresponse((httpstatuscode)responsetype.ok, json(resultdata ).content); } 

azure sender method:

public async task<int> senddata(mainmodel data) {    //create event list --> result list<eventdata> events    ...    eventhubclient eventhubclient = eventhubclient.createfromconnectionstring(connstring);     client.sendbatch(events);     client.close();     return 1;//i dont know im doing code :) } 

this implementation not actually. supposed is, answering many results without delay but, lately im getting many errors event hubs. says;

"the operation did not complete within allocated time 00:00:00 object sasl0. more information on exception types , proper exception handle.."

or

"a task canceled."

strangely, happens every 2-3 days , lasts 10-15 mins goes fine again.

i have 2 questions:

  1. do need improve implementation (probably yes because it's fire&forget)? why? how?

  2. why im getting these errors?

i hope made myself clear. thank you.


Comments

Popular posts from this blog

asynchronous - C# WinSCP .NET assembly: How to upload multiple files asynchronously -

aws api gateway - SerializationException in posting new Records via Dynamodb Proxy Service in API -

asp.net - Problems sending emails from forum -