RobotStudio event

Message Queue Timeout

Hi,

I am using PCSDK and message queues for communication beween a .Net application and rapid module. The following unit test is used to validate the timeout when waiting to receive a message. The intention of the test is to send a message to the rapid module and wait for a reply, since the rapid module is configured to not send any response the IpcQueue.Receive call should stop with a timeout (1000ms).

In this scenario the receive method will never return with a timeout, does anybody know why the timeout will not happen? Is it probably an issue of the receive method?


[TestMethod, Timeout(30000)]

public void TimeoutExample()

{

NetworkScanner scanner = new NetworkScanner();

Controller abbController = ControllerFactory.CreateFrom(scanner.GetControllers(NetworkScannerSearchCriterias.Real)[0]);

IpcQueue sendQueue = abbController.Ipc.GetQueue("RMQ_T_ROB_R");

IpcQueue receiveQueue;

if (abbController.Ipc.Exists("PC_SDK_Q"))

{

receiveQueue = abbController.Ipc.GetQueue("PC_SDK_Q");

abbController.Ipc.DeleteQueue(receiveQueue.QueueId);

receiveQueue = abbController.Ipc.CreateQueue("PC_SDK_Q", 5, Ipc.IPC_MAXMSGSIZE);

}

else

{

receiveQueue = abbController.Ipc.CreateQueue("PC_SDK_Q", 5, Ipc.IPC_MAXMSGSIZE);

}

receiveQueue = abbController.Ipc.GetQueue("PC_SDK_Q");

IpcMessage sendMessage = new IpcMessage();

sendMessage.SetData(new UTF8Encoding().GetBytes("RapidRoutineParameter;[\"Timeout\",FALSE]"));

sendMessage.Sender = receiveQueue.QueueId; sendQueue.Send(sendMessage);

IpcMessage receiveMessage = new IpcMessage();

Stopwatch stopwatch = new Stopwatch();

stopwatch.Start(); IpcReturnType returnType = receiveQueue.Receive(1000, receiveMessage); stopwatch.Stop();

Console.WriteLine(new UTF8Encoding().GetString(receiveMessage.Data));

Assert.AreEqual(1000, stopwatch.ElapsedMilliseconds, 1000); Assert.IsTrue(returnType == IpcReturnType.Timeout); }