Example usage for org.springframework.scheduling.annotation AsyncResult AsyncResult

List of usage examples for org.springframework.scheduling.annotation AsyncResult AsyncResult

Introduction

In this page you can find the example usage for org.springframework.scheduling.annotation AsyncResult AsyncResult.

Prototype

public AsyncResult(@Nullable V value) 

Source Link

Document

Create a new AsyncResult holder.

Usage

From source file:dk.clanie.actor.SecondTestActorImpl.java

@Override
public Future<?> methodCalledByFirstActor(int arg) {
    process("methodCalledByFirstActor", arg);
    return new AsyncResult<Object>(null);
}

From source file:mx.com.gaby.service.AsynchronousService.java

@Async
public void sendMails(int totalMails) {
    for (int i = 1; i <= totalMails; i++) {
        try {//  w w w  .  j ava2  s.c o  m
            serializeFile();
            sendMail(i);
            result = new AsyncResult<ResultAsyncDTO>(
                    new ResultAsyncDTO(i, "Enviados " + i + " de " + totalMails, totalMails, true));
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
    }
}

From source file:com.orange.clara.cloud.servicedbdumper.filer.compression.GzipCompressing.java

@Async
public Future<Boolean> gunziptIt(OutputStream outputStream, InputStream inputStream) throws IOException {
    logger.debug("Start uncompressing...");
    GZIPInputStream gzis = new GZIPInputStream(inputStream);
    ByteStreams.copy(gzis, outputStream);

    outputStream.flush();/*from ww w  .  ja v a  2s.c  om*/
    outputStream.close();
    gzis.close();
    inputStream.close();
    logger.debug("Finish uncompressing");
    return new AsyncResult<Boolean>(true);
}

From source file:dk.clanie.actor.FirstTestActorImpl.java

@Override
public Future<?> methodReturningFuture(int arg) {
    process("methodReturningFuture", arg);
    return new AsyncResult<Object>(null);
}

From source file:ru.xxlabaza.test.aspectj.MyService.java

@Async
public Future<Boolean> doSomeAsync() throws InterruptedException {
    val myPojo = new MyPojo();
    myPojo.setName("Popa");
    myPojo.setAge(13);/*from w  w  w.  j av a2s  .c o  m*/

    Thread.sleep(3000L);
    log.info("Delyed HELLO WORLD!");

    val notBean = new NotBean();
    notBean.doSomeUseful("Hello from not a bean");

    log.error("Pojo name '{}', age {}", myPojo.getName(), myPojo.getAge());

    return new AsyncResult<>(Boolean.TRUE);
}

From source file:com.javiermoreno.springcloud.IntegracionWebservices.java

@Async
public Future<Integer> obtenerStockAsync(String referencia) throws IOException {
    // Atiende qu bonito: indicas el nombre del servicio y restTemplate es capaz de recuperar su @
    String stockURL = "http://stockservice/productos/" + referencia + "/stock";
    String stockResponseBody = restTemplate.getForObject(stockURL, String.class);
    JsonNode stockJson = objectMapper.readTree(stockResponseBody);
    int unidadesDisponibles = stockJson.get("unidadesDisponibles").asInt();
    return new AsyncResult<>(unidadesDisponibles);
}

From source file:com.curso.beans.ServicioAsincrono.java

@Async
public Future<Double> factorial(Integer numero) {
    System.out.println(//  w w w . ja  va  2  s .c  o m
            "En metodo factorial de " + getClass().getName() + " en el hilo " + Thread.currentThread());
    return new AsyncResult<>(factorialUtil(numero));
}

From source file:eu.cloudscale.showcase.servlets.helpers.PaymentService.java

@Async
public Future<String> callPaymentService(String distribution, String attr1, String attr2, String attr3) {
    try {//from  www .  jav  a 2s.c  o m
        ExecutorService executor = Executors.newFixedThreadPool(1);
        String url = this.getUrl(distribution, attr1, attr2, attr3);
        Future<Response> response = executor.submit(new Request(new URL(url)));
        InputStream input = response.get().getBody();
        executor.shutdown();

        String body = IOUtils.toString(input, "UTF-8");
        return new AsyncResult<String>(body);
    } catch (MalformedURLException e) {
        e.printStackTrace();
    } catch (InterruptedException e) {
        e.printStackTrace();
    } catch (ExecutionException e) {
        e.printStackTrace();
    } catch (IOException e) {
        e.printStackTrace();
    }
    return null;
}

From source file:com.orange.clara.cloud.servicedbdumper.task.asynctask.DeleteDumpTask.java

@Async
@Transactional(propagation = Propagation.REQUIRES_NEW)
public Future<Boolean> runTask(Integer jobId) throws AsyncTaskException {
    Job job = this.jobRepo.findOne(jobId);
    this.deleter.deleteAll(job.getDbDumperServiceInstance());
    this.jobFactory.createJobDeleteDbDumperServiceInstance(job.getDbDumperServiceInstance());

    job.setJobEvent(JobEvent.FINISHED);/*from  w w w  . j  a v  a 2  s  .  c  o  m*/
    jobRepo.save(job);
    return new AsyncResult<Boolean>(true);
}

From source file:com.javiermoreno.springcloud.IntegracionWebservices.java

@Async
public Future<Producto> obtenerFichaCatalogoAsync(String referencia) {
    String catalogoURL = "http://catalogoservice/catalogo/referencias/" + referencia;
    Producto producto = restTemplate.getForObject(catalogoURL, Producto.class);
    return new AsyncResult<>(producto);
}