Guest User

Untitled

a guest
Jan 22nd, 2018
76
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.88 KB | None | 0 0
  1. ScheduledExecutorService scheduler = Executors.newSingleThreadScheduledExecutor();
  2. final BlockingQueue <ResponseType> q = new ArrayBlockingQueue<>(10);
  3.  
  4. final Callable<ResponseType> action = () -> {
  5. ResponseMessage pollResponse = client.Revocation();
  6. if (pollResponse.getErrorData().equalsIgnoreCase("QueueIsNotReady")) {
  7. scheduler.shutdown();
  8. return getResponse(pollResponse, ELPTSRevocationResponse.class);
  9. }
  10. return null;
  11. };
  12.  
  13. scheduler.scheduleAtFixedRate((Runnable) () -> {
  14. try {
  15. q.put(action.call());
  16. } catch (Exception e) {
  17. e.printStackTrace();
  18. }
  19. }, 0, 60, TimeUnit.SECONDS); // do smth every min
  20.  
  21. while(q.isEmpty()){
  22. // System.out.println(q);
  23. }
  24. return q.take();
Add Comment
Please, Sign In to add comment