Java Code Examples for org.springframework.scheduling.annotation.AsyncResult#forValue()

The following examples show how to use org.springframework.scheduling.annotation.AsyncResult#forValue() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: MessageServerCluster.java    From sctalk with Apache License 2.0 6 votes vote down vote up
@Async
public ListenableFuture<?> webrtcInitateCallReq(long fromId, long toId, long netId) {

    // FIXME
    // 从当前的通话中查看是否已存在
    // 如果存在,判断类型,返回给呼叫发起方
    IMAVCall avCall = userClientInfoManager.getCaller(fromId);

    // 如果不存在,则处理呼叫
    if (avCall == null) {
        avCall = userClientInfoManager.getCaller(toId);
        if (avCall != null) {
            // TODO Peer Busy
            return AsyncResult.forExecutionException(new Exception());
        }
        userClientInfoManager.addCaller(fromId, netId);
    } else {
        // TODO Self Busy

        return AsyncResult.forExecutionException(new Exception());
    }

    return AsyncResult.forValue("");
}
 
Example 2
Source File: MessageServerCluster.java    From sctalk with Apache License 2.0 6 votes vote down vote up
@Async
public ListenableFuture<?> webrtcInitateCallRes(long fromId, long toId, long netId) {

    // FIXME
    // 从当前的通话中查看是否已存在
    IMAVCall toAvCall = userClientInfoManager.getCalled(toId);
    if (toAvCall != null) {
        // 如果存在,返回给呼叫发起方
        // TODO 其他端,已经接受了 IMAVCallCancelReq
        return AsyncResult.forExecutionException(new Exception());
    }
    
    // 如果不存在,则处理呼叫
    userClientInfoManager.addCalled(toId, netId);
    return AsyncResult.forValue("");
}
 
Example 3
Source File: TestServiceImpl.java    From springBoot with MIT License 5 votes vote down vote up
@Async("asyncTaskExecutor")
@Override
public Future<String> asyncTask(String s) {
    long startTime = System.currentTimeMillis();
    try {
        //模拟耗时
        Thread.sleep(3000);
    } catch (InterruptedException e) {
        e.printStackTrace();
    }
    long endTime = System.currentTimeMillis();
    System.out.println(Thread.currentThread().getName() + ":Future<String> asyncTask(String s),耗时:" + (endTime - startTime));
    return AsyncResult.forValue(s);
}
 
Example 4
Source File: TestService.java    From spring-cloud-gray with Apache License 2.0 4 votes vote down vote up
@Async("taskExecutor")
public Future<Map> get(String version) {
    return AsyncResult.forValue(testClient.testGet(version));
}