Blocked when trying to create QueueClient
Hi Guys,
Recently we are facing a timeout: "Response did not arrive on time in 00:01:00 for message"
Here is the detailed of error:
EventName="MessageEvent" Message="[2018-01-17 07:43:15.900 GMT 15 ERROR 101212 Runtime.Scheduler.WorkerPoolThread/0 10.96.138.81:11111] !!!!!!!!!! Worker pool thread Runtime.Scheduler.WorkerPoolThread/0 (ManagedThreadId=16) has been busy for long time: Executing Task Id=1 Status=Running for 00:09:26.4995991 on WorkItem=WorkItemGroup:Name=[Activation: xxxx Placement=RandomPlacement],WorkGroupStatus=Running Executing for 00:09:26.4995991. WorkItemGroup Details: WorkItemGroup:Name=[Activation: Placement=RandomPlacement],WorkGroupStatus=Running. Currently QueuedWorkItems=2; Total EnQueued=7; Total processed=4; Quantum expirations=0; TaskRunner=ActivationTaskScheduler-13:Queued=2; Detailed SchedulingContext=<[Activation:xxxx Placement=RandomPlacement State=Valid NonReentrancyQueueSize=0 EnqueuedOnDispatcher=1 InFlightCount=0 NumRunning=0 IdlenessTimeSpan=00:09:39.5444282 CollectionAgeLimit=02:00:00]>. " TraceSource="WaWorkerHost.exe"
after add tracing, we found that it's blocked at line of:
QueueClient.CreateFromConnectionString(connectionString, queueName)
The strange is that it's only blocked when running in a cloud service, while no block found if running locally.
Here are the detailed info of the environment:
Orleans: 1.2.3
WindowsAzure.ServiceBus: 3.2.2
is there any graceful way to resolve it?
Many Thanks
Below code is working fine... var result = await Task.Run(() => QueueClient.CreateFromConnectionString(connectionString, queueName));
using Task.Run, which meaning running with .net thread pool
any risk? Thanks
should be fine. Why do you think there's risk?
What is this QueueClient, where are you creating it?
And also a side note, 1.2.3 is pretty early version, recommend to update to newer version. there's a lot of improvement in 1.4 and 1.5, in perf, programming model, bug fix and etc
the QueueClient is a client of Azure Service Bus to create a queue client before sending message to Azure Queue. the creation code will be finally called inside a grain.
https://dotnet.github.io/orleans/Documentation/Advanced-Concepts/External-Tasks-and-Grains.html clearly stated that Task.Run will be running with .net thread pool, instead of Orlean scheduler.
suppose it will be back to Orleans Scheduler after the call, then there is no risk.
Is this QueueClient code in your grain code? or it is just your client code?
Yeah you will be fine. it will just be back to Orleans Scheduler after the call. Assuming the code is in a grain code, then you will also lose Orleans turn-based concurrency guarantees on that. But I assume this is not important to you?
Thanks. @xiazen the code is in a non-grain class.
public class QueueService : IQueueService { public async Task SendMessageAsync() { var queueClient= await CreateQueueClientFromConnectionStringAsync(connectionString, queueName); //send message with async method await queueClient.SendAsync(objBrokeredMessage); }
private static async Task<QueueClient> CreateQueueClientFromConnectionStringAsync(string connectionString, string queueName)
{
//only can be run with .net thread pool
var queueClient= await Task.Run(() => QueueClient.CreateFromConnectionString(connectionString, queueName));
return queueClient;
}
}
In grain call it to send a message to queue in a grain method. await queueService.SendMessageAsync(); //do something else
from //do something else, it will back to Orleans schedular.
yeah it looks fine. Best luck !
close this since the issue seems resolved. feel free to reopen it if further question occurs.