Skip to content

Instantly share code, notes, and snippets.

@b1a9id

b1a9id/AsyncServiceImpl.java Secret

Last active Jul 9, 2021
Embed
What would you like to do?
asyncのAsyncServiceImpl.java
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.retry.annotation.Recover;
import org.springframework.retry.annotation.Retryable;
import org.springframework.scheduling.annotation.Async;
import org.springframework.stereotype.Service;
import com.b1a9idps.springasyncdemo.dto.request.AsyncRequest;
import com.b1a9idps.springasyncdemo.exception.FailedFileUploadException;
import com.b1a9idps.springasyncdemo.service.AsyncService;
@Service
public class AsyncServiceImpl implements AsyncService {
private static final Logger LOGGER = LoggerFactory.getLogger(AsyncServiceImpl.class);
@Override
@Async
public void save(AsyncRequest request) {
LOGGER.info("Start Async processing.(number = " + request.getNumber() + ")");
try {
Thread.sleep(5000);
LOGGER.info("Hi!.(number = " + request.getNumber() + ")");
} catch (InterruptedException e) {
LOGGER.error("thrown InterruptedException.");
}
LOGGER.info("End Async processing.(number = " + request.getNumber() + ")");
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment