You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@activemq.apache.org by Adam Kaminiecki <ad...@dgt.com.pl> on 2011/01/05 14:51:44 UTC

Java client

Hi,

Can anybody help me what is the latest version of java client? and from 
where I can download it?


Regards,
Adam

-- 
This message has been scanned for viruses and
dangerous content by MailScanner, and is
believed to be clean.


Re: Java client

Posted by Dejan Bosanac <de...@nighttale.net>.
Hi Adam,

ActiveMQ doesn't have separated client as the client can embed the
broker. What you need for starters is activemq-core module (and it's
dependencies). The easiest is to use maven and have it included in
your project like this:

    <dependency>
      <groupId>org.apache.activemq</groupId>
      <artifactId>activemq-core</artifactId>
      <version>5.4.2</version>
    </dependency>



Cheers
--
Dejan Bosanac
-----------------
FuseSource - The experts in open source integration and messaging.
Email: dejanb@fusesource.com
Web: http://fusesource.com
Twitter:  http://twitter.com/dejanb
ActiveMQ in Action - http://www.manning.com/snyder/
Blog - http://www.nighttale.net



On Wed, Jan 5, 2011 at 2:51 PM, Adam Kaminiecki <ad...@dgt.com.pl> wrote:
> Hi,
>
> Can anybody help me what is the latest version of java client? and from
> where I can download it?
>
>
> Regards,
> Adam
>
> --
> This message has been scanned for viruses and
> dangerous content by MailScanner, and is
> believed to be clean.
>
>

Re: Posibble bud in .net C# client

Posted by Jim Gomes <e....@gmail.com>.
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 <ad...@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.
>
>

Posibble bud in .net C# client

Posted by Adam Kaminiecki <ad...@dgt.com.pl>.
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.