You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@activemq.apache.org by sulong <su...@gmail.com> on 2009/04/02 11:26:04 UTC

client is blocked after sending 5082 messages

Hi all,I am testing the activemq to learn how to use it. I write a simple
single thread jms client to send 10000 messages, but it is blocked at the
5083rd message. I use:

activemq 5.2
jvm  1.5
ubuntu 8.10

and the program is simple :


public class Sender {
    public static void main(String[] args) {
         ConnectionFactory cf = new ActiveMQConnectionFactory("tcp://
10.1.94.237:6000");
         Connection conn = null;
         Session s = null;
         try {
             conn = cf.createConnection();

             s = conn.createSession(false, Session.AUTO_ACKNOWLEDGE);
             s.run();
             MessageProducer sender =
s.createProducer(s.createQueue("jms_test"));
             for (int i = 0; i < 10000; i++) {
                TextMessage tm = s.createTextMessage();
                tm.setText(String.valueOf(i));
                sender.send(tm);
             }

             System.out.println("Done.");
         }catch (JMSException e) {
             e.printStackTrace();
         } finally {
             if (conn != null) {
                 try {
                     conn.close();
                 } catch (Exception e) {
                     e.printStackTrace();
                 }
             }

             if (s != null) {
                 try {
                     s.close();
                 } catch (Exception e) {
                     e.printStackTrace();
                 }
             }
         }
    }
}

anyone knows why it is blocked? Thanks

Re: client is blocked after sending 5082 messages

Posted by sulong <su...@gmail.com>.
Thanks!

On Thu, Apr 2, 2009 at 6:14 PM, Gary Tully <ga...@gmail.com> wrote:

> Just came across this useful blog entry on flow
> control<
> http://blog.kovyrin.net/2009/01/23/activemq-tips-flow-control-and-stalled-producers-problem/
> >from
> Homo-Adminus <http://blog.kovyrin.net/> who had a similar experience. It
> is
> worth a read.
>
> 2009/4/2 Gary Tully <ga...@gmail.com>
>
> > you are seeing producer flow control in action<
> http://activemq.apache.org/producer-flow-control.html>.
> > The objective of producer flow control is to ensure that an entire
> > connection is not blocked when the memory limit of a destination is
> reached.
> > The broker and producer communicate to push back on the producer when the
> > memory limit is approaching. The memory limit defaults to 64m.
> >
> > If producer flow control is disabled, (see the policy entry in the link
> > above) once the queue memory limit is reached and system memory limit is
> > reached, a queues messages will be spooled to disk and the memory will be
> > released for more messages, which will in turn get spooled to disk.
> >
> >
> > 2009/4/2 sulong <su...@gmail.com>
> >
> > Hi all,I am testing the activemq to learn how to use it. I write a simple
> >> single thread jms client to send 10000 messages, but it is blocked at
> the
> >> 5083rd message. I use:
> >>
> >> activemq 5.2
> >> jvm  1.5
> >> ubuntu 8.10
> >>
> >> and the program is simple :
> >>
> >>
> >> public class Sender {
> >>    public static void main(String[] args) {
> >>         ConnectionFactory cf = new ActiveMQConnectionFactory("tcp://
> >> 10.1.94.237:6000");
> >>         Connection conn = null;
> >>         Session s = null;
> >>         try {
> >>             conn = cf.createConnection();
> >>
> >>             s = conn.createSession(false, Session.AUTO_ACKNOWLEDGE);
> >>             s.run();
> >>             MessageProducer sender =
> >> s.createProducer(s.createQueue("jms_test"));
> >>             for (int i = 0; i < 10000; i++) {
> >>                TextMessage tm = s.createTextMessage();
> >>                tm.setText(String.valueOf(i));
> >>                sender.send(tm);
> >>             }
> >>
> >>             System.out.println("Done.");
> >>         }catch (JMSException e) {
> >>             e.printStackTrace();
> >>         } finally {
> >>             if (conn != null) {
> >>                 try {
> >>                     conn.close();
> >>                 } catch (Exception e) {
> >>                     e.printStackTrace();
> >>                 }
> >>             }
> >>
> >>             if (s != null) {
> >>                 try {
> >>                     s.close();
> >>                 } catch (Exception e) {
> >>                     e.printStackTrace();
> >>                 }
> >>             }
> >>         }
> >>    }
> >> }
> >>
> >> anyone knows why it is blocked? Thanks
> >>
> >
> >
> >
> > --
> > http://blog.garytully.com
> >
> > Open Source SOA
> > http://FUSESource.com
> >
>
>
>
> --
> http://blog.garytully.com
>
> Open Source SOA
> http://FUSESource.com
>

Re: client is blocked after sending 5082 messages

Posted by Gary Tully <ga...@gmail.com>.
Just came across this useful blog entry on flow
control<http://blog.kovyrin.net/2009/01/23/activemq-tips-flow-control-and-stalled-producers-problem/>from
Homo-Adminus <http://blog.kovyrin.net/> who had a similar experience. It is
worth a read.

2009/4/2 Gary Tully <ga...@gmail.com>

> you are seeing producer flow control in action<http://activemq.apache.org/producer-flow-control.html>.
> The objective of producer flow control is to ensure that an entire
> connection is not blocked when the memory limit of a destination is reached.
> The broker and producer communicate to push back on the producer when the
> memory limit is approaching. The memory limit defaults to 64m.
>
> If producer flow control is disabled, (see the policy entry in the link
> above) once the queue memory limit is reached and system memory limit is
> reached, a queues messages will be spooled to disk and the memory will be
> released for more messages, which will in turn get spooled to disk.
>
>
> 2009/4/2 sulong <su...@gmail.com>
>
> Hi all,I am testing the activemq to learn how to use it. I write a simple
>> single thread jms client to send 10000 messages, but it is blocked at the
>> 5083rd message. I use:
>>
>> activemq 5.2
>> jvm  1.5
>> ubuntu 8.10
>>
>> and the program is simple :
>>
>>
>> public class Sender {
>>    public static void main(String[] args) {
>>         ConnectionFactory cf = new ActiveMQConnectionFactory("tcp://
>> 10.1.94.237:6000");
>>         Connection conn = null;
>>         Session s = null;
>>         try {
>>             conn = cf.createConnection();
>>
>>             s = conn.createSession(false, Session.AUTO_ACKNOWLEDGE);
>>             s.run();
>>             MessageProducer sender =
>> s.createProducer(s.createQueue("jms_test"));
>>             for (int i = 0; i < 10000; i++) {
>>                TextMessage tm = s.createTextMessage();
>>                tm.setText(String.valueOf(i));
>>                sender.send(tm);
>>             }
>>
>>             System.out.println("Done.");
>>         }catch (JMSException e) {
>>             e.printStackTrace();
>>         } finally {
>>             if (conn != null) {
>>                 try {
>>                     conn.close();
>>                 } catch (Exception e) {
>>                     e.printStackTrace();
>>                 }
>>             }
>>
>>             if (s != null) {
>>                 try {
>>                     s.close();
>>                 } catch (Exception e) {
>>                     e.printStackTrace();
>>                 }
>>             }
>>         }
>>    }
>> }
>>
>> anyone knows why it is blocked? Thanks
>>
>
>
>
> --
> http://blog.garytully.com
>
> Open Source SOA
> http://FUSESource.com
>



-- 
http://blog.garytully.com

Open Source SOA
http://FUSESource.com

Re: client is blocked after sending 5082 messages

Posted by Gary Tully <ga...@gmail.com>.
you are seeing producer flow control in
action<http://activemq.apache.org/producer-flow-control.html>.
The objective of producer flow control is to ensure that an entire
connection is not blocked when the memory limit of a destination is reached.
The broker and producer communicate to push back on the producer when the
memory limit is approaching. The memory limit defaults to 64m.

If producer flow control is disabled, (see the policy entry in the link
above) once the queue memory limit is reached and system memory limit is
reached, a queues messages will be spooled to disk and the memory will be
released for more messages, which will in turn get spooled to disk.


2009/4/2 sulong <su...@gmail.com>

> Hi all,I am testing the activemq to learn how to use it. I write a simple
> single thread jms client to send 10000 messages, but it is blocked at the
> 5083rd message. I use:
>
> activemq 5.2
> jvm  1.5
> ubuntu 8.10
>
> and the program is simple :
>
>
> public class Sender {
>    public static void main(String[] args) {
>         ConnectionFactory cf = new ActiveMQConnectionFactory("tcp://
> 10.1.94.237:6000");
>         Connection conn = null;
>         Session s = null;
>         try {
>             conn = cf.createConnection();
>
>             s = conn.createSession(false, Session.AUTO_ACKNOWLEDGE);
>             s.run();
>             MessageProducer sender =
> s.createProducer(s.createQueue("jms_test"));
>             for (int i = 0; i < 10000; i++) {
>                TextMessage tm = s.createTextMessage();
>                tm.setText(String.valueOf(i));
>                sender.send(tm);
>             }
>
>             System.out.println("Done.");
>         }catch (JMSException e) {
>             e.printStackTrace();
>         } finally {
>             if (conn != null) {
>                 try {
>                     conn.close();
>                 } catch (Exception e) {
>                     e.printStackTrace();
>                 }
>             }
>
>             if (s != null) {
>                 try {
>                     s.close();
>                 } catch (Exception e) {
>                     e.printStackTrace();
>                 }
>             }
>         }
>    }
> }
>
> anyone knows why it is blocked? Thanks
>



-- 
http://blog.garytully.com

Open Source SOA
http://FUSESource.com