Details
Description
We have a production envrionment like below:
1. Client UI start, subscribe to server, the topic
2. That topic has a lot of messages coming, 60 messages per second
3. But, we want to close the connect before close the UI
4. After we debug into, found the process hang up at the session close portion.
Sample code:
public bool ReceiveUpdateMessageFromServer()
{
bool result = false;
try
{
StartConnection();
Console.WriteLine("Update connection started...");
sessionUpdate = connectionRec.CreateSession(AcknowledgementMode.AutoAcknowledge);
Console.WriteLine("Update session created...");
if (!connectionRec.IsStarted)
connectionRec.Start();
if (this.strTesterID != "")
{ topicConsumer = sessionUpdate.GetTopic(this.strUpdateTopic); string strJMSSelector = "TESTERID='" + this.strTesterID + "'"; consumerUpdate = sessionUpdate.CreateConsumer(topicConsumer, strJMSSelector); }else if (consumerUpdate == null)
{ destinationRec = sessionUpdate.GetTopic(this.strUpdateTopic); consumerUpdate = sessionUpdate.CreateConsumer(destinationRec); }Console.WriteLine("Consumer started ...");
Console.WriteLine("Update session started...");
consumerUpdate.Listener += (message =>
);
result = true;
}
catch (Exception exMsgRec)
{
if (!exMsgRec.Message.Contains("already connected"))
}
finally
{
}
return result;
}
public void StopReceiveUpdateMessageFromServer()
{
try
{
#region Consumer Close
if (consumerUpdate != null)
{
try
catch (Exception exClose)
{ if (exClose.Message != "Object reference not set to an instance of an object.") throw exClose; }consumerUpdate.Dispose();
consumerUpdate = null;
}
#endregion
#region Session Close
if (sessionUpdate != null)
{
try
{ sessionUpdate.Close(); Console.WriteLine("Session stopped..."); }
catch (Exception exClose)
{ if (exClose.Message != "Object reference not set to an instance of an object.") throw exClose; }
//# The process hang up here, don't why
sessionUpdate.Dispose();
sessionUpdate = null;
}
#endregion
#region Connection Close
lock (this)
{
if (connectionRec != null)
{
try
catch (Exception exClose)
{ if (exClose.Message != "Object reference not set to an instance of an object.") throw exClose; } connectionRec.Dispose();
connectionRec = null;
}
}
#endregion
if (destinationRec != null)
{ destinationRec = null; }if (factoryRec != null)
{ factoryRec = null; } }
catch (Exception exRecMessage)
}