I am working on an Azure Service Fabric project which reads a message from ActiveMQ using Apache.NMS .NET library and creating durable consumer to read message from specific from ActiveMQ.
I am able to read the message and everything is working fine, but I am getting some warning as following.
'System.RAP' reported Warning for property 'IStatelessServiceInstance.OpenDuration'. The api IStatelessServiceInstance.Open on node _Node_0 is stuck.
This warning results in erroring the service, so I need to remove that warning.
Anybody why it's giving me the warning.
Here is a snapshot of how I am reading the message.
try
{
ITopic dest = AMQSession.GetTopic(TopicName);
using (IMessageConsumer consumer = AMQSession.CreateDurableConsumer(dest, SubscriptionName, MessageSelector, false))
{
IMessage message;
while ((message = consumer.Receive()) != null)
{
ITextMessage txtMsg = message as ITextMessage;
}
}
}
catch (Exception ex)
{
Close();
}
finally
{
Close();
}
This problem is almost certainly caused by the fact that your code here can block forever. Specifically,
consumer.Receive()
will block forever if no message arrives. As the documentation states:Also, even if a message does arrive the
while
loop ensures that the containing method will never return.I recommend you specify a timeout when attempting to consume messages. If the timeout elapses then
Receive
will returnnull
and the loop will be broken and the code will no longer be blocked.