コード例 #1
0
      @Override
      public void onMessage(String channel, String message) {
        logger.trace("Redis Subscriber ({}):  Received message: {}", id, message);

        if (checkPayload) {
          Assert.assertTrue(NATS_PAYLOAD.equals(message));
        }

        if (tallyMessage() == testCount) {
          logger.debug("Redis Subscriber ({}):  Received {} messages.  Completed.", id, testCount);
          this.unsubscribe();
        }
      }
コード例 #2
0
    @Override
    public void run() {

      try {

        logger.debug("NATS Publisher ({}):  Starting", id);

        io.nats.client.Connection c = new ConnectionFactory().createConnection();

        for (int i = 0; i < testCount; i++) {
          c.publish(subject, NATS_PAYLOAD.getBytes());
          tallyMessage();
        }
        c.flush();

        logger.debug("NATS Publisher ({}):  Published {} messages.", id, testCount);

        setComplete();
      } catch (Exception ex) {
        ex.printStackTrace();
      }
    }