/**
  * customize the message
  *
  * @param message a SibMessage
  */
 protected void customizeMessage(SibMessage message) {
   try {
     message.setName(Randomizer.randomString(Randomizer.randomInteger(2, 45)));
   } catch (Exception ex) {
     ex.printStackTrace();
   }
 }
  /**
   * create a new SibTask
   *
   * @return a new SibTask
   */
  protected SibTask createTask() {
    int _length = 10000;

    try {
      _length = Randomizer.randomInteger(1000, 10000);
    } catch (Exception e) {
      e.printStackTrace();
    }

    final int length = _length;

    SibTask task =
        new AbstractSibTask() {
          public void _run() {
            long time = System.currentTimeMillis();

            while ((System.currentTimeMillis() - time) < length
                && !SibTaskStatus.STOPPED.equals(this.getStatus())) {

              /* determine progression */
              float ratio =
                  (Math.abs(((float) length) - ((float) (System.currentTimeMillis() - time))))
                      / ((float) length);
              ratio *= 100;
              ratio = 100 - ratio;

              this.setProgression((int) ratio);

              try {
                Thread.sleep(500);
              } catch (InterruptedException ex) {
                ex.printStackTrace();
              }
            }

            if (SibTaskStatus.STOPPED.equals(this.getStatus())) {
              logger.info(
                  "task '"
                      + this.getName()
                      + "' stopped with progression : "
                      + this.getProgression());
            } else {
              this.setProgression(100);
            }
          }
        };

    if (logger.isDebugEnabled()) {
      logger.debug(
          "launching task deterministic="
              + task.isDeterministic()
              + " stoppable="
              + task.isStoppable()
              + " length(ms)="
              + length);
    }

    return task;
  }