Aha, thanks!

May I suggest to whomever controls the docs that it be documented.

Sounds like the right thing is to watch in the run() method.

On Nov 4, 12:23 pm, Alexander Azarov <[email protected]> wrote:
> Yes, I do understand.
>
> There is ProtocolHandler object in ClientImpl and it is ThreadLocal:
>
> https://github.com/RTykulsker/JavaBeanstalkClient/blob/master/src/mai...
>
> Which means a new ProtocolHandler gets initialized watching "default"
> tube only, when you call ClientImpl methods from another thread.
>
> On 4 ноя, 06:29, Dan Frankowski <[email protected]> wrote:
>
> > Does anyone understand why I am seeing the following behavior in
> > JavaBeanstalkClient?
>
> > Consumer watches a particular tube (mytube) in its constructor, then in
> > run() (new thread) all of a sudden it is watching the default tube again! If
> > I watch mytube in run() it sticks. Output and code below.
>
> > Ubuntu 10.4
> > beanstalk version 1.4.3-1
> > Java BeanstalkClient 1.2.2
>
> > All latest I can get.
>
> > Dan
>
> > *Output:
> > *
> > 20101103 22:17:16 INFO: watching [mytube]
> > 20101103 22:17:16 INFO: watching [mytube]
> > 20101103 22:17:16 INFO: watching [default]
>
> > *Code:
> > *
>
> > import java.util.logging.Logger;
>
> > import com.surftools.BeanstalkClient.Client;
> > import com.surftools.BeanstalkClientImpl.ClientImpl;
>
> > public class Foo5 {
> >     private static Logger logger = Logger.getLogger(Foo5.class.getName());
> >     private static final String TUBE_NAME = "mytube";
>
> >     private static class Consumer implements Runnable {
> >         private Client client;
>
> >         public Consumer() {
> >             client = new ClientImpl("localhost", 11300);
> >             watch();
> >         }
>
> >         private void watch() {
> >             client.watch(TUBE_NAME);  // for reserve()
> >             client.ignore("default"); // Don't get tasks from "default"
> > queue
> >             logWatching();  // mytube
> >         }
>
> >         public void logWatching() {
> >             logger.info("watching " + client.listTubesWatched());
>
> >         }
>
> >         @Override
> >         public void run() {
> >           // watch();     // Uncomment this to watch mytube
> >           logWatching();  // default?!  why?
> >         }
> >     }
>
> >     public static void main(String[] args) throws Exception {
> >         Consumer consumer = new Consumer();
> >         consumer.logWatching();  // mytube
> >         new Thread(consumer).start();
> >     }
>
> > }
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"beanstalk-talk" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/beanstalk-talk?hl=en.

Reply via email to