Hello,
I'm trying to implement a monitoring system where my element monitors multiple other elements (let's call them Master-Slave), so I chose to use InterApp. I followed the InterApp documentation and did the following:
1. Created a NuGet solution which serves as the Message API.
public class GetChain : Message
{
public GetChain() : base()
{
}public PolarizationType Type { get; set; }
}public class GetChainResult : Message
{
public GetChainResult() : base()
{
}public ChainState[] ActiveChains { get; set; }
public PolarizationType PolarizationType { get; set; }
}
2. Created the logic in my "Master" protocol which is sending the request message to one of the slaves with a timeout of 30 seconds. The message gets correctly processed in the Executor in the "Slave" protocol. I also made sure the ReturnAddress data is correct.
// Master protocol sending the message
var responses = command.Send(protocol.SLNet.RawConnection, ddaAgentId, ddaElementId, 9000000, new TimeSpan(0, 0, 30), knownTypes);
3. The Executor in the "Slave" protocol returns the Message with the correct Guid and sends it back like this:
foreach (var message in receivedCall.Messages)
{
if (message.TryExecute(protocol, protocol, msgToExecutor, out Message returnMessage))
{
protocol.Log($"QA{protocol.QActionID}|Execute successful", LogType.Information, LogLevel.NoLogging);
}if (returnMessage != null)
{
protocol.Log("QA" + protocol.QActionID + "|Run|Sending return message with GUID '" + returnMessage.Guid + "'.", LogType.DebugInfo, LogLevel.NoLogging);returnMessage.Send(
protocol.SLNet.RawConnection,
receivedCall.ReturnAddress.AgentId,
receivedCall.ReturnAddress.ElementId,
receivedCall.ReturnAddress.ParameterId,
knownTypes);
}
}
And the message contains the correct Guid:
2023/08/07 14:58:21.322|SLManagedScripting.exe|ManagedInterop|DBG|0|62|QA9000000|Run|Sending return message with GUID '9396cc0a-e5f2-4b7f-b5fe-3c8c9ff99924'.
4. The command.Send throws a TimeoutException:
2023/08/07 14:58:51.606|SLManagedScripting.exe|ManagedInterop|ERR|0|53|QA9000|9001|Run|Exception thrown:
System.TimeoutException: Timeout while waiting on responses: 9396cc0a-e5f2-4b7f-b5fe-3c8c9ff99924
I've logged the parameter 9000001, where the return message should come, and it contains the correct data, with the correct GUIDs; however, I can't see the data in the responses parameter from step 2.
Am I doing something wrong? The documentation seems straightforward about sending a return message.
Hi Benjamin,
The reason why your response didn't seem to arrive is because the way you configured the "ReturnAddress" field.
You've specified the sender element information for the "returnAddress" while instead you should have use the destination element reference.
The documentation was not yet crystal clear on that, but we've updated to make things more clear: InterApp classes | DataMiner Docs
IMPORTANT
The parameter selected with the ReturnAddress must not be on the source element (the parameter 9000001 on the destination element is recommended). If you use a parameter on the element you are sending from, you will cause deadlocks. This happens because the sending QAction waits on a response, but the response cannot be set to the parameter because there is a QAction running (i.e. the one waiting on the response).
Let us know if you need any further help.
Thank you Thijs for helping me with this and for the explanation