Exemplo n.º 1
0
  // asynchronously publish the given event to the ApplicationContext for 'count'
  // number of times
  protected void doPublish(final ApplicationEvent event, final int count) {
    Runnable publisher =
        new Runnable() {
          public void run() {
            for (int i = 0; i < count; i++) {
              context.publishEvent(event);
            }
          }
        };

    Executors.newSingleThreadExecutor().execute(publisher);
  }
Exemplo n.º 2
0
  // asynchronously send the payload to the given Mule URL for 'count' number of
  // times
  protected void doSend(final String url, final Object payload, final int count) {
    Runnable sender =
        new Runnable() {
          public void run() {
            try {
              MuleClient client = new MuleClient();
              for (int i = 0; i < count; i++) {
                client.send(url, payload, null);
              }
            } catch (UMOException ex) {
              fail(ExceptionUtils.getStackTrace(ex));
            }
          }
        };

    // execute in background
    Executors.newSingleThreadExecutor().execute(sender);
  }