Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ScheduledExecutorService scheduler = Executors.newSingleThreadScheduledExecutor();
- final BlockingQueue <ResponseType> q = new ArrayBlockingQueue<>(10);
- final Callable<ResponseType> action = () -> {
- ResponseMessage pollResponse = client.Revocation();
- if (pollResponse.getErrorData().equalsIgnoreCase("QueueIsNotReady")) {
- scheduler.shutdown();
- return getResponse(pollResponse, ELPTSRevocationResponse.class);
- }
- return null;
- };
- scheduler.scheduleAtFixedRate((Runnable) () -> {
- try {
- q.put(action.call());
- } catch (Exception e) {
- e.printStackTrace();
- }
- }, 0, 60, TimeUnit.SECONDS); // do smth every min
- while(q.isEmpty()){
- // System.out.println(q);
- }
- return q.take();
Add Comment
Please, Sign In to add comment