You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@activemq.apache.org by pPolak <al...@centrum.sk> on 2009/09/10 13:37:43 UTC

C# client stops receiving messages after getting ~400 of them

Hi,

 I need help with this scenario:
* two clients connecting to the same broker, one written in JAVA, the other
one in C#
* there are two queues, SentByJava and SentByCSharp
* both clients have a consumer and a producer
* JAVA producer sends messages to the SentByJava queue, C# producer sends
messages to the SentByCSharp queue
* JAVA consumer gets messages from the SentByCSharp queue, C# consumer gets
messages from the SentByJava queue

JAVA client works fine. C# client has a problem with its consumer: after
some time the consumer stops getting messages. "Some time" is  less than 10
seconds from start, about 400 messages are usually successfully received. It
does not matter whether the JAVA client is running or not, nor does it
matter whether the C# client's producer is running or not. It happens even
when I run only the C# client with producer part commented out.

I use this url to connect: failover:(tcp://WSSK809001:61616)
The consumer runs in its own thread and basically just loops and gets
messages:

      private void ConsumeMessages()
      {
         while (!stopRequested)
         {
            Thread.Sleep(10);
            IMessage message =
consumer.Receive(TimeSpan.FromMilliseconds(100));
            if (message != null)
            {
               //trigger the OnMessageReceived event
               OnMessageReceived(message);
            }
         }

I really have no idea what to do with this :( I tried increasing the
Thread.Sleep() milliseconds to 100 - did not help.

Did any of you experience something like this? Thanx for any help.

Peter.
-- 
View this message in context: http://www.nabble.com/C--client-stops-receiving-messages-after-getting-%7E400-of-them-tp25381671p25381671.html
Sent from the ActiveMQ - User mailing list archive at Nabble.com.


RE: C# client stops receiving messages after getting ~400 of them

Posted by pPolak <al...@centrum.sk>.
Hi,

  thank you, I tried it, but it did not work :(

  P.


ravindrabtp wrote:
> 
> 
> Hi,
> 
>   Try changing policyentry in your activemq.xml for queues. Don't put any
> memory limit, if you have to handle lot of messages.
> 
>                 <policyEntries>
> 			  <policyEntry queue=">"/>
>                     <policyEntry topic=">" memoryLimit="5mb"/>
>                 </policyEntries>
> 
> All the best.
> 

-- 
View this message in context: http://www.nabble.com/C--client-stops-receiving-messages-after-getting-%7E400-of-them-tp25381671p25382201.html
Sent from the ActiveMQ - User mailing list archive at Nabble.com.


RE: C# client stops receiving messages after getting ~400 of them

Posted by ravindra <ra...@btpsoft.com>.
Hi,

  Try changing policyentry in your activemq.xml for queues. Don't put any
memory limit, if you have to handle lot of messages.

                <policyEntries>
			  <policyEntry queue=">"/>
                    <policyEntry topic=">" memoryLimit="5mb"/>
                </policyEntries>

All the best.

-----Original Message-----
From: pPolak [mailto:alanko@centrum.sk] 
Sent: Thursday, September 10, 2009 5:27 PM
To: users@activemq.apache.org
Subject: Re: C# client stops receiving messages after getting ~400 of them



pPolak wrote:
> 
> (...)
> I use this url to connect: failover:(tcp://WSSK809001:61616)
> (...)
> 

 - sorry, that "WSSK809001" is the network name of my computer.
-- 
View this message in context:
http://www.nabble.com/C--client-stops-receiving-messages-after-getting-%7E40
0-of-them-tp25381671p25381931.html
Sent from the ActiveMQ - User mailing list archive at Nabble.com.





Re: C# client stops receiving messages after getting ~400 of them

Posted by pPolak <al...@centrum.sk>.

pPolak wrote:
> 
> (...)
> I use this url to connect: failover:(tcp://WSSK809001:61616)
> (...)
> 

 - sorry, that "WSSK809001" is the network name of my computer.
-- 
View this message in context: http://www.nabble.com/C--client-stops-receiving-messages-after-getting-%7E400-of-them-tp25381671p25381931.html
Sent from the ActiveMQ - User mailing list archive at Nabble.com.


Re: C# client stops receiving messages after getting ~400 of them

Posted by pPolak <al...@centrum.sk>.
SOLVED! (or so it seems :-))

As I said, all messages were the same except for the two-digit number at the
end. Of course, there is only 100 numbers with two digits so naturally there
were duplicated messages - and this was the main problem. As soon as I've
set the connection's AcknowledgementMode to DupsOkAcknowledge the problem
disappeared.

Maybe it will helped someone in the future...
-- 
View this message in context: http://www.nabble.com/C--client-stops-receiving-messages-after-getting-%7E400-of-them-tp25381671p25424146.html
Sent from the ActiveMQ - User mailing list archive at Nabble.com.


Re: C# client stops receiving messages after getting ~400 of them

Posted by pPolak <al...@centrum.sk>.

Timothy Bish wrote:
> 
> If you could provide a short but complete sample app that demonstrate
> the problem that would help to diagnose what the issue might be.
> 
> Regards
> Tim.
> 

Hi Tim,

  yeah, that's a good idea. I've found out that this simple app can
reproduce the error:

__________________________________
using System;
using Apache.NMS.ActiveMQ;
using Apache.NMS;
using Apache.NMS.ActiveMQ.Commands;

namespace ConsoleApplication1
{
   class Program
   {
      static void Main(string[] args)
      {
         ConnectionFactory connectionFactory = new
ConnectionFactory("failover:(tcp://localhost:61616)");
         IConnection connection = connectionFactory.CreateConnection();
         ISession session = connection.CreateSession();
         IMessageConsumer consumer = session.CreateConsumer(new
ActiveMQQueue("FrqQueueSentByJava"));
         for (int i = 0; i < 10000; i++)
         {
            IMessage message = consumer.Receive();
            if (message is ITextMessage)
            {
               Console.WriteLine("Content: " +
((ITextMessage)message).Text);
            }
         }
      }
   }
}
__________________________________

Prerequisites: there are several thousands of messages in the queue (already
generated, the generation doesn't run any more. Only this consumer is
running). The messages' content is this:

__________________________________
01234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567Hello,
C# world#11!
__________________________________

...that "11" at the end is a random number between 1 and 100. The messages
were generated by a Java app.

This is my activemq.xml:

__________________________________
<beans
  xmlns="http://www.springframework.org/schema/beans"
  xmlns:amq="http://activemq.apache.org/schema/core"
  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-2.0.xsd
  http://activemq.apache.org/schema/core
http://activemq.apache.org/schema/core/activemq-core.xsd">

    <!-- Allows us to use system properties as variables in this
configuration file -->
    <bean
class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer"/>

    <broker xmlns="http://activemq.apache.org/schema/core"
brokerName="client3" persistent="false" useJmx="true">

        <!-- Use the following to configure how ActiveMQ is exposed in JMX
-->
        <managementContext>
            <managementContext connectorPort="9999"/>
        </managementContext>

        <!-- The store and forward broker networks ActiveMQ will listen to
-->
        <networkConnectors>
            <!-- by default just auto discover the other brokers -->
            <networkConnector name="nc" uri="multicast://default"
dynamicOnly="true" conduitSubscriptions="false"
decreaseNetworkConsumerPriority="true" />
        </networkConnectors>


        <!-- The transport connectors ActiveMQ will listen to -->
        <transportConnectors>
            <transportConnector uri="tcp://localhost:61616"
discoveryUri="multicast://default"/>
        </transportConnectors>

        <destinationPolicy>
           <policyMap>
             <policyEntries>
                <policyEntry queue="FrqQueueSentByCSharp.>"
memoryLimit="512mb" producerFlowControl="false" useCache="false">
                  <dispatchPolicy>
                    <roundRobinDispatchPolicy />
                  </dispatchPolicy>
                  <subscriptionRecoveryPolicy>
                    <timedSubscriptionRecoveryPolicy recoverDuration="10000"
/>
                  </subscriptionRecoveryPolicy>
                  <pendingMessageLimitStrategy>
                    <constantPendingMessageLimitStrategy limit="10"/>
                  </pendingMessageLimitStrategy>
                </policyEntry>
                <policyEntry queue="FrqQueueSentByJava.>"
memoryLimit="512mb" producerFlowControl="false" useCache="false">
                  <dispatchPolicy>
                    <roundRobinDispatchPolicy />
                  </dispatchPolicy>
                  <subscriptionRecoveryPolicy>
                    <timedSubscriptionRecoveryPolicy recoverDuration="10000"
/>
                  </subscriptionRecoveryPolicy>
                  <pendingMessageLimitStrategy>
                    <constantPendingMessageLimitStrategy limit="10"/>
                  </pendingMessageLimitStrategy>
                </policyEntry>
             </policyEntries>
           </policyMap>
        </destinationPolicy>

    </broker>

    <!-- An embedded servlet engine for serving up the Admin console -->
    <jetty xmlns="http://mortbay.com/schemas/jetty/1.0">
        <connectors>
            <nioConnector port="8162"/>
        </connectors>

        <handlers>
            <webAppContext contextPath="/admin"
resourceBase="${activemq.base}/webapps/admin" logUrlOnStart="true"/>
        </handlers>
    </jetty>
</beans>
__________________________________


If anyone can help me, you will save my life :) Thank you very, very much.

  Peter
-- 
View this message in context: http://www.nabble.com/C--client-stops-receiving-messages-after-getting-%7E400-of-them-tp25381671p25397622.html
Sent from the ActiveMQ - User mailing list archive at Nabble.com.


Re: C# client stops receiving messages after getting ~400 of them

Posted by Timothy Bish <ta...@gmail.com>.
On Thu, 2009-09-10 at 05:29 -0700, pPolak wrote:
> Maybe this will help someone: 
> 
> when I run that C# client, I check the
> http://localhost:8162/admin/queues.jsp and I see that the number of pending
> messages is lowered by some amount. Not lowering continuously by 1, but
> lowered once by ~400. 
> 
> Then the C# client is receiving messages for a few seconds (number of
> pending messages is constant) then it freezes. But the pending messages
> number does not change any more. Isn't it weird? I turned the cache off for
> both queues, but it stays the same.

If you could provide a short but complete sample app that demonstrate
the problem that would help to diagnose what the issue might be.

Regards
Tim.


-- 
Tim Bish
http://fusesource.com
http://timbish.blogspot.com/




Re: C# client stops receiving messages after getting ~400 of them

Posted by pPolak <al...@centrum.sk>.
Maybe this will help someone: 

when I run that C# client, I check the
http://localhost:8162/admin/queues.jsp and I see that the number of pending
messages is lowered by some amount. Not lowering continuously by 1, but
lowered once by ~400. 

Then the C# client is receiving messages for a few seconds (number of
pending messages is constant) then it freezes. But the pending messages
number does not change any more. Isn't it weird? I turned the cache off for
both queues, but it stays the same.
-- 
View this message in context: http://www.nabble.com/C--client-stops-receiving-messages-after-getting-%7E400-of-them-tp25381671p25382435.html
Sent from the ActiveMQ - User mailing list archive at Nabble.com.