Examples of JedisPubSub


Examples of redis.clients.jedis.JedisPubSub

    }

    @Test
    public void subscribeLazily() throws UnknownHostException, IOException,
      InterruptedException {
  final JedisPubSub pubsub = new JedisPubSub() {
      public void onMessage(String channel, String message) {
    unsubscribe(channel);
      }

      public void onSubscribe(String channel, int subscribedChannels) {
View Full Code Here

Examples of redis.clients.jedis.JedisPubSub

  jedis.subscribe(pubsub, SafeEncoder.encode("foo"));
    }

    @Test(expected = JedisConnectionException.class)
    public void unsubscribeWhenNotSusbscribed() throws InterruptedException {
  JedisPubSub pubsub = new JedisPubSub() {
      public void onMessage(String channel, String message) {
      }

      public void onPMessage(String pattern, String channel,
        String message) {
      }

      public void onSubscribe(String channel, int subscribedChannels) {
      }

      public void onUnsubscribe(String channel, int subscribedChannels) {
      }

      public void onPUnsubscribe(String pattern, int subscribedChannels) {
      }

      public void onPSubscribe(String pattern, int subscribedChannels) {
      }
  };
  pubsub.unsubscribe();
    }
View Full Code Here

Examples of redis.clients.jedis.JedisPubSub

    }
      }
  });
  t.start();
  try {
      jedis.subscribe(new JedisPubSub() {
    public void onMessage(String channel, String message) {
        try {
      // wait 0.5 secs to slow down subscribe and
      // client-output-buffer exceed
      // System.out.println("channel - " + channel +
View Full Code Here

Examples of redis.clients.jedis.JedisPubSub

      throws InterruptedException {

  final AtomicReference<String> newmaster = new AtomicReference<String>(
    "");

  sentinelJedis.psubscribe(new JedisPubSub() {

      @Override
      public void onMessage(String channel, String message) {
      }
View Full Code Here

Examples of redis.clients.jedis.JedisPubSub

    PubSubService service = new PubSubService();
    service.publish(13, "test", "16:16 message");
  }
  public void testSub(){
    PubSubService service = new PubSubService();
    service.subscribe(13, new JedisPubSub() {

      @Override
      public void onMessage(String channel, String message) {
        System.out.println(channel + " received:" + message);
       
View Full Code Here

Examples of redis.clients.jedis.JedisPubSub

   
    tblclmnNewColumn_2 = new TableColumn(table, SWT.NONE);
    tblclmnNewColumn_2.setWidth(100);
    tblclmnNewColumn_2.setText(RedisClient.i18nFile.getText(I18nFile.MESSAGE));
   
    final JedisPubSub callback = new JedisPubSub() {

      @Override
      public void onMessage(String channel, String message) {
        messageReceived(table, channel, message);
      }

      private void messageReceived(final Table table,
          final String channel, final String message) {
        Display.getDefault().asyncExec(new Runnable() {
            public void run() {
              TableItem item = new TableItem(table, SWT.None);
            SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss:SSS", Locale.getDefault());
            String time = df.format(new Date());
            String[] str = new String[]{time, channel, message};
            item.setText(str);
            table.setSelection(item);
             
            }
        });
       
      }

      @Override
      public void onPMessage(String pattern, String channel,
          String message) {
        messageReceived(table, channel, message);
      }

      @Override
      public void onSubscribe(String channel,
          int subscribedChannels) {
        // TODO Auto-generated method stub
       
      }

      @Override
      public void onUnsubscribe(String channel,
          int subscribedChannels) {
        // TODO Auto-generated method stub
       
      }

      @Override
      public void onPUnsubscribe(String pattern,
          int subscribedChannels) {
        // TODO Auto-generated method stub
       
      }

      @Override
      public void onPSubscribe(String pattern,
          int subscribedChannels) {
        // TODO Auto-generated method stub
       
      }
     
    };
   
    final Thread t = new Thread(new Runnable() {
        public void run() {
          PubSubService subscribe = new PubSubService();
          subscribe.subscribe(id, callback, subChannel);
        }
    });
    t.start();
   
    tbtmSubItem.addDisposeListener(new DisposeListener() {
      @Override
      public void widgetDisposed(DisposeEvent e) {
        callback.punsubscribe();
      }
    });
   
    return tbtmSubItem;
  }
View Full Code Here

Examples of redis.clients.jedis.JedisPubSub

    logger = Logger.getLogger(CNSRedisPubSubTest.class);
  }
 
  //@Test
  public void testRedisPubSub() {
    JedisPubSub jedisPubSub = setupSubscriber();
    try {
      setupCNSMessagePublisher();
      logger.info("Finished starting setupCNSMessagePublisher");
      publishLatch.countDown();
      logger.info("Finished publish latch countdown");
      messageReceivedLatch.await();
      logger.info("Waiting for message receive");
    if (! messageContainer.iterator().next().equals(message)) {
      logger.info("published message did not match received message");
      fail("published message did not match received message");
    } else {
      logger.info("message received and matched published message");
    }
    jedisPubSub.unsubscribe();
    } catch (InterruptedException ie) {
      fail("interrupted " + ie);
    }
  }
View Full Code Here

Examples of redis.clients.jedis.JedisPubSub

    }, "publisherThread").start();
  }
 
  private JedisPubSub setupSubscriber() {
   
    final JedisPubSub jedisPubSub = new JedisPubSub() {
      @Override
      public void onUnsubscribe(String channel, int subscribedChannels) {
        logger.info("onUnsubscribe channel=" + channel);
      }
View Full Code Here

Examples of redis.clients.jedis.JedisPubSub

  }
 
  private void startSubscriber(final CountDownLatch startLatch, final CountDownLatch completionCounter) {
    final Jedis jedis = newJedisClient();
   
    JedisPubSub pubSub = new JedisPubSub() {
      @Override public void onUnsubscribe(String channel, int subscribedChannels) {
        //print("onUnsubscribe on "+channel);
      }
     
      @Override public void onSubscribe(String channel, int subscribedChannels) {
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.