You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@curator.apache.org by Donald Laidlaw <do...@me.com> on 2014/07/02 14:01:01 UTC
DistributedQueue - subscriber not receiving all messages
Hi All,
Despite the advice not to use Zookeeper for queues, I thought I would try
it for a very low volume application rather than install a dedicated
messaging system. I already had zookeeper, so it seemed like a decent fit.
I create a DistributedQueue<T> for my type and provide the serializer, path,
client, and the consumer interface. I then start it and immediately
receive any messages that are already in the queue.
Meanwhile in another JVM (same machine) I connect to the same path with a
DistributedQueue<T> with a null consumer interface parameter and send new
messages. Those messages never get consumed by the consumer I created earlier.
I can start the zookeeper shell and actually see the messages in the path.
So I know the messages are there. If I stop the original consumer (stop the whole
JVM, not just the DistributedQueue object)and start it again then it
will consume the messages that were waiting there.
I don't think this is the expected behavior, and I am not sure why it is
happening. Can anyone see something I missed?
Java 8 on Mac OSX Mavericks, fully updated
Zookeeper 3.4.6
Curator 2.4.2
The Code ...
QueueBuilder<NodeStateEvent> builder = QueueBuilder.builder(
curatorFramework,
queueConsumer,
new JsonQueueSerializer<>(NodeStateEvent.class),
queuePath);
DistributedQueue<NodeStateEvent> queue = builder.buildQueue();
queue.start();
// At this point events already in the queue arrive and are processed by the
// queueConsumer without any issues. However, no newly queued events are
// ever received.
Don Laidlaw
866 Cobequid Rd.
Lower Sackville, NS
B4C 4E1
Phone: 1-902-576-5185
Cell: 1-902-401-6771
Re: DistributedQueue - subscriber not receiving all messages
Posted by Donald Laidlaw <do...@me.com>.
I stopped zookeeper and deleted all its data and started fresh.
Now, I am receiving queued events in the consumer as expected. No code changes!
For some reason there must have been a problem with either the zookeeper data or the instance that was running. This is very strange indeed. I will see if it happens again and report it.
Thanks,
-Don
> Well, I don't think the producer side is consuming them, because I can see the messages when using the command line client. But here is the producer code:
>
> managerNodeStateQueue = QueueBuilder.builder(curatorFramework,
> null,
> new JsonQueueSerializer<>(NodeStateEvent.class),
> queuePath).buildQueue();
> managerNodeStateQueue.start();
> ...
> managerNodeStateQueue.put(new NodeStateEvent("Running"));
>
> With the command line client I can "ls /manager/nodeStateQueue" and see the messages. They stay in the queue after they are written. I need to stop and start the JVM of the consumer to actually consume them.
>
> The queuePath variable is set to "/manager/nodeStateQueue".
>
> Thanks for looking.
>
Re: DistributedQueue - subscriber not receiving all messages
Posted by Jordan Zimmerman <jo...@jordanzimmerman.com>.
I’ll bet you had a bad node in queue’s path. If you look at the logs there will be a message regarding these. See this Tech Note: https://cwiki.apache.org/confluence/display/CURATOR/TN7
From: Donald Laidlaw donlaidlaw@me.com
Reply: user@curator.apache.org user@curator.apache.org
Date: July 2, 2014 at 8:33:40 AM
To: user@curator.apache.org user@curator.apache.org
Subject: Re: DistributedQueue - subscriber not receiving all messages
I stopped zookeeper and deleted all its data and started fresh.
Now, I am receiving queued events in the consumer as expected. No code changes!
For some reason there must have been a problem with either the zookeeper data or the instance that was running. This is very strange indeed. I will see if it happens again and report it.
Thanks,
-Don
Well, I don't think the producer side is consuming them, because I can see the messages when using the command line client. But here is the producer code:
managerNodeStateQueue = QueueBuilder.builder(curatorFramework,
null,
new JsonQueueSerializer<>(NodeStateEvent.class),
queuePath).buildQueue();
managerNodeStateQueue.start();
...
managerNodeStateQueue.put(new NodeStateEvent("Running"));
With the command line client I can "ls /manager/nodeStateQueue" and see the messages. They stay in the queue after they are written. I need to stop and start the JVM of the consumer to actually consume them.
The queuePath variable is set to "/manager/nodeStateQueue".
Thanks for looking.
Re: DistributedQueue - subscriber not receiving all messages
Posted by Donald Laidlaw <do...@me.com>.
I stopped zookeeper and deleted all its data and started fresh.
Now, I am receiving queued events in the consumer as expected. No code changes!
For some reason there must have been a problem with either the zookeeper data or the instance that was running. This is very strange indeed. I will see if it happens again and report it.
Thanks,
-Don
> Well, I don't think the producer side is consuming them, because I can see the messages when using the command line client. But here is the producer code:
>
> managerNodeStateQueue = QueueBuilder.builder(curatorFramework,
> null,
> new JsonQueueSerializer<>(NodeStateEvent.class),
> queuePath).buildQueue();
> managerNodeStateQueue.start();
> ...
> managerNodeStateQueue.put(new NodeStateEvent("Running"));
>
> With the command line client I can "ls /manager/nodeStateQueue" and see the messages. They stay in the queue after they are written. I need to stop and start the JVM of the consumer to actually consume them.
>
> The queuePath variable is set to "/manager/nodeStateQueue".
>
> Thanks for looking.
>
Re: DistributedQueue - subscriber not receiving all messages
Posted by Jordan Zimmerman <jo...@jordanzimmerman.com>.
I don’t see an issue from that code snippet. What does the producer side look like? Maybe the producer is taking the messages?
-Jordan
From: Donald Laidlaw donlaidlaw@me.com
Reply: user@curator.apache.org user@curator.apache.org
Date: July 2, 2014 at 5:01:38 AM
To: user@curator.apache.org user@curator.apache.org
Subject: DistributedQueue - subscriber not receiving all messages
Hi All,
Despite the advice not to use Zookeeper for queues, I thought I would try
it for a very low volume application rather than install a dedicated
messaging system. I already had zookeeper, so it seemed like a decent fit.
I create a DistributedQueue<T> for my type and provide the serializer, path,
client, and the consumer interface. I then start it and immediately
receive any messages that are already in the queue.
Meanwhile in another JVM (same machine) I connect to the same path with a
DistributedQueue<T> with a null consumer interface parameter and send new
messages. Those messages never get consumed by the consumer I created earlier.
I can start the zookeeper shell and actually see the messages in the path.
So I know the messages are there. If I stop the original consumer (stop the whole
JVM, not just the DistributedQueue object)and start it again then it
will consume the messages that were waiting there.
I don't think this is the expected behavior, and I am not sure why it is
happening. Can anyone see something I missed?
Java 8 on Mac OSX Mavericks, fully updated
Zookeeper 3.4.6
Curator 2.4.2
The Code ...
QueueBuilder<NodeStateEvent> builder = QueueBuilder.builder(
curatorFramework,
queueConsumer,
new JsonQueueSerializer<>(NodeStateEvent.class),
queuePath);
DistributedQueue<NodeStateEvent> queue = builder.buildQueue();
queue.start();
// At this point events already in the queue arrive and are processed by the
// queueConsumer without any issues. However, no newly queued events are
// ever received.
Don Laidlaw
866 Cobequid Rd.
Lower Sackville, NS
B4C 4E1
Phone: 1-902-576-5185
Cell: 1-902-401-6771