/**
  * Offer a message that may have a synchronous consumer waiting.
  *
  * @param destination Queue name
  * @param message Received message. Can be NetFault or NetNotification
  */
 protected boolean offerPollResponse(String destination, NetMessage message) {
   synchronized (_syncSubscriptions) {
     SynchronousQueue<NetMessage> synchronousQueue = pendingPolls.get(destination);
     if (synchronousQueue != null) {
       return synchronousQueue.offer(message);
     }
     return false;
   }
 }
 public static void receive(@Observes Response response) throws InterruptedException {
   RESPONSE_RECEIVED.set(response);
   SYNCHRONIZER.offer(response, 10, TimeUnit.SECONDS);
 }
Exemple #3
0
 /**
  * Sends the given method call to this thread.
  *
  * @throws TimeoutException if this thread does not accept the request within a reasonable amount
  *     of time
  */
 private void sendRequest(String methodName, Object... arguments) throws Exception {
   if (!requestQueue.offer(
       new Request(methodName, arguments), TIMEOUT_MILLIS, TimeUnit.MILLISECONDS)) {
     throw new TimeoutException();
   }
 }