@Override
    public void run() {
        if (this.state.compareAndSet(NEW, RUNNING)) {
            try {
                renameThread("RUNNING");
                this.threadRef.set(Thread.currentThread());
                this.jedis.sadd(key(WORKERS), this.name);
                this.jedis.set(key(WORKER, this.name, STARTED), new SimpleDateFormat(DATE_FORMAT).format(new Date()));
                this.listenerDelegate.fireEvent(WORKER_START, this, null, null, null, null, null);
                loadRedisScripts();
                poll();
            } catch (Exception ex) {
                LOG.error("Uncaught exception in worker run-loop!", ex);
                this.listenerDelegate.fireEvent(WORKER_ERROR, this, null, null, null, null, ex);
            } finally {
                renameThread("STOPPING");
                this.listenerDelegate.fireEvent(WORKER_STOP, this, null, null, null, null, null);
                this.jedis.srem(key(WORKERS), this.name);
                this.jedis.del(key(WORKER, this.name), key(WORKER, this.name, STARTED), key(STAT, FAILED, this.name),
                        key(STAT, PROCESSED, this.name));
                this.jedis.quit();
                this.threadRef.set(null);
            }
        } else if (RUNNING.equals(this.state.get())) {
            throw new IllegalStateException("This WorkerImpl is already running");
        } else {
            throw new IllegalStateException("This WorkerImpl is shutdown");
        }
    }
@ Override public void run ( ) { if ( this . state . compareAndSet ( NEW , RUNNING ) ) { try { renameThread ( "RUNNING" ) ; this . threadRef . set ( Thread . currentThread ( ) ) ; this . jedis . sadd ( key ( WORKERS ) , this . name ) ; this . jedis . set ( key ( WORKER , this . name , STARTED ) , new SimpleDateFormat ( DATE_FORMAT ) . format ( new Date ( ) ) ) ; this . listenerDelegate . fireEvent ( WORKER_START , this , null , null , null , null , null ) ; loadRedisScripts ( ) ; poll ( ) ; } catch ( Exception ex ) { LOG . error ( "Uncaught exception in worker run-loop!" , ex ) ; this . listenerDelegate . fireEvent ( WORKER_ERROR , this , null , null , null , null , ex ) ; } finally { renameThread ( "STOPPING" ) ; this . listenerDelegate . fireEvent ( WORKER_STOP , this , null , null , null , null , null ) ; this . jedis . srem ( key ( WORKERS ) , this . name ) ; this . jedis . del ( key ( WORKER , this . name ) , key ( WORKER , this . name , STARTED ) , key ( STAT , FAILED , this . name ) , key ( STAT , PROCESSED , this . name ) ) ; this . jedis . quit ( ) ; this . threadRef . set ( null ) ; } } else if ( RUNNING . equals ( this . state . get ( ) ) ) { throw new IllegalStateException ( "This WorkerImpl is already running" ) ; } else { throw new IllegalStateException ( "This WorkerImpl is shutdown" ) ; } }
Starts this worker. Registers the worker in Redis and begins polling the queues for jobs.<br>
Stop this worker by calling end() on any thread.