activemq-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Jim Gomes <e.se...@gmail.com>
Subject Re: Posibble bud in .net C# client
Date Thu, 06 Jan 2011 16:35:23 GMT
Hi Adam,

Could you take these functions and put them together with the main driver
function that you describe?  It seems like the core problem you are
describing hinges upon the main loop driver, not necessarily on these
utility functions.  A small test application that can duplicate the problem
you are having would help tremendously.

Oh, and when you are able to get the file together, make sure it's in a
format that someone else can easily recreate the file.  Either as an
attachment somewhere, or else pasted inline without line-numbers.  The
line-numbers would have to be removed, and that's very tedious to do.

Thanks,
Jim

On Thu, Jan 6, 2011 at 8:24 AM, Adam Kaminiecki <adamka@dgt.com.pl> wrote:

> Hi,
>
> I'm just testing .net C# client especially failover mode and I found
> somethink disquieting. Memory usage is growing very fast when I'm connecting
> to broker and disconnecting 10times per second and always after connection
> send one message on topic.
> I'm using  broker version 5.4.2 and client 1.4.1.
>
> connection code
>
>  1. public void AmqConnect()
>  2.      {
>  3. if (string.IsNullOrEmpty(AmqUrl)) throw new
>     ApplicationException("AmqUrl null or empty");
>  4. if (string.IsNullOrEmpty(AmqQue)) throw new
>     ApplicationException("AmqQue null or empty");
>  5.        MyFactory = new ConnectionFactory(AmqUrl);
>  6.
>  7.        {
>  8. try
>  9.          {
>  10.            MyConnection = MyFactory.CreateConnection() as Connection;
>  11.
>  12. if (MyConnection != null)
>  13.            {
>  14.              MyConnection.AsyncSend = true;
>  15.              MyConnection.AsyncClose = true;
>  16.              MyConnection.AcknowledgementMode =
>     AcknowledgementMode.AutoAcknowledge;
>  17.              MyConnection.ProducerWindowSize = 1024000;
>  18.              MyConnection.SendAcksAsync = true;
>  19.              MyConnection.ExceptionListener +=
>     ConnectionExceptionListener;
>  20.              Mysession = MyConnection.CreateSession() as Session;
>  21.
>  22. if (Mysession != null)
>  23.              {
>  24.                MyDestination = Mysession.GetTopic(AmqQue) as
>     ActiveMQDestination;
>  25.
>  26.                MyProducer =
>     Mysession.CreateProducer(MyDestination) as MessageProducer;
>  27. if (MyProducer != null) MyProducer.DeliveryMode =
>     MsgDeliveryMode.NonPersistent;
>  28.                MyConsumer =
>     Mysession.CreateConsumer(MyDestination) as MessageConsumer;
>  29.
>  30. if (MyConsumer == null)
>  31.                {
>  32.                  Mysession.Dispose();
>  33.                  MyConnection.Dispose();
>  34.                  Er = "Error:AMQ Consumer nullable.";
>  35. return;
>  36.                }
>  37.
>  38. while (MyConsumer.ReceiveNoWait() != null)
>  39.                {
>  40.                }
>  41.
>  42.                MyConsumer.Listener += OnMassage;
>  43.                MyConnection.Start();
>  44.              }
>  45. else
>  46.              {
>  47.                MyConnection.Dispose();
>  48.                Er = "Error:AMQ Session nullable.";
>  49.              }
>  50.            }
>  51. else
>  52.            {
>  53.
>  54.              Er = "Error:AMQ Connection nullable.";
>  55.            }
>  56.          }
>  57. catch (Exception ex)
>  58.          {
>  59.            Er = "Error:AMQ Connection Error.";
>  60. if (AmqClientStatusError != null) AmqClientStatusError("AMQ
>     Error:" + ex);
>  61.          }
>  62.        }
>  63.      }
>
> Sending message
>
>  1. public void Send(object o)
>  2.      {
>  3.        (new MySendDelegate(MySend)).BeginInvoke(o, null, null);
>  4.      }
>  5.
>
>  1. public void MySend(object o)
>  2.      {
>  3. try
>  4.        {
>  5. if (Mysession != null)
>  6.          {
>  7.           ActiveMQMessage request =
>     Mysession.CreateObjectMessage(o) as ActiveMQObjectMessage;
>  8. if (MyProducer != null)
>  9.            {
>  10. if (request != null)
>  11.              {
>  12.                MyProducer.Send(request);
>  13. if (AmqClientStatusDebug != null) AmqClientStatusDebug("Object
>     sent:" + o);
>  14.              }
>  15.            }
>  16.          }
>  17.        }
>  18. catch (Exception ex)
>  19.        {
>  20. if (AmqClientStatusError != null) AmqClientStatusError("AMQ
>     Error:" + ex);
>  21.        }
>
>
> Closing:
>
>  1. public void Close()
>  2.      {
>  3. try
>  4.        {
>  5. if (MyProducer != null)
>  6.          {
>  7.            MyProducer.Dispose();
>  8.          }
>  9. if (MyConsumer != null)
>  10.          {
>  11.            MyConsumer.Listener -= OnMassage;
>  12.            MyConsumer.Close();
>  13.          }
>  14.
>  15.
>  16. if (MyConnection != null)
>  17.          {
>  18. if (MyConnection.IsStarted)
>  19.              MyConnection.Stop();
>  20.            MyConnection.Close();
>  21.            MyConnection.ExceptionListener -=
>     ConnectionExceptionListener;
>  22.
>  23.
>  24.          }
>  25.        }
>  26. catch (Exception ex)
>  27.        {
>  28. if (AmqClientStatusError != null) AmqClientStatusError("AMQ
>     Error:" + ex);
>  29.        }
>  30.      }
>
>
> I'm using it 10times per second with failover url. Timer in windows forms
> applications use method colse then connect and send one message.
> But connections are not close correctly and consume of memory is growing
> FAST!
> Am I doing something wrong or is a bug?
>
>
> Regards,
> Adam
>
>
> --
> This message has been scanned for viruses and
> dangerous content by MailScanner, and is
> believed to be clean.
>
>

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message