コード例 #1
0
 @Override
 public void run() {
   try {
     while (running) {
       String result = consume();
       if (result != null) {
         send(result);
         rate.increment();
       } else if (running) {
         LOG.error(name + " Failed to consume!");
       }
     }
   } catch (Throwable e) {
     e.printStackTrace();
   }
 }
コード例 #2
0
  public synchronized void start() throws JMSException {
    if (!running) {
      rate.reset();
      running = true;
      if (!connectionPerMessage) {
        connection = factory.createConnection();
        connection.start();
        session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
        consumer = session.createConsumer(getConsumeDestination());
        producer = session.createProducer(getSendDestination());
        producer.setDeliveryMode(this.deliveryMode);
      }

      Thread t = new Thread(this);
      t.setName(name);
      t.start();
    }
  }