public synchronized void handleTimeout() { if (!resumedByApplication) { if (timeoutHandler != null) { timeoutHandler.handleTimeout(this); } else { cont.setObject(new ServiceUnavailableException()); } } }
private synchronized boolean doResumeFinal(Object response) { inMessage.getExchange().put(AsyncResponse.class, this); cont.setObject(response); resumedByApplication = true; if (!initialSuspend) { cont.resume(); } else { initialSuspend = false; } return true; }
public synchronized void handleTimeout() { if (!resumedByApplication) { if (pendingTimeout != null) { setAsyncResponseOnExchange(); cont.suspend(pendingTimeout); pendingTimeout = null; } else if (timeoutHandler != null) { timeoutHandler.handleTimeout(this); } else { cont.setObject(new ServiceUnavailableException()); } } }
private synchronized void doResume(Object response) throws IllegalStateException { checkCancelled(); checkSuspended(); inMessage.getExchange().put(AsyncResponse.class, this); cont.setObject(response); resumedByApplication = true; if (!initialSuspend) { cont.resume(); } else { initialSuspend = false; } }
public String sayHi(String firstName, String secondName) { Continuation continuation = getContinuation(firstName); if (continuation == null) { throw new RuntimeException("Failed to get continuation"); } synchronized (continuation) { if (continuation.isNew()) { Object userObject = secondName != null && secondName.length() > 0 ? secondName : null; continuation.setObject(userObject); long timeout = 20000; if (secondName.startsWith("to:")) { timeout = Long.parseLong(secondName.substring(3)); } suspendInvocation(firstName, continuation, timeout); } else { StringBuilder sb = new StringBuilder(); sb.append(firstName); // if the actual parameter is not null if (secondName != null && secondName.length() > 0) { String surname = continuation.getObject().toString(); sb.append(' ').append(surname); } // System.out.println("Saying hi to " + sb.toString()); return "Hi " + sb.toString(); } } // unreachable return null; }
@GET @Path("{id}") public String handleContinuationRequest(@PathParam("id") String id) { Continuation continuation = getContinuation(id); if (continuation == null) { throw new RuntimeException("Failed to get continuation"); } synchronized (continuation) { if (continuation.isNew()) { continuation.setObject(id); suspendInvocation(id, continuation); } else { String savedId = continuation.getObject().toString(); if (!savedId.equals(id)) { throw new RuntimeException("SavedId is wrong"); } return books.get(savedId); } } // unreachable return null; }
public String sayHi(String firstName, String secondName) { Continuation continuation = getContinuation(firstName); if (continuation == null) { throw new RuntimeException("Failed to get continuation"); } synchronized (continuation) { if (continuation.isNew()) { Object userObject = secondName != null && secondName.length() > 0 ? secondName : null; continuation.setObject(userObject); long timeout = 20000; if (secondName.startsWith("to:")) { timeout = Long.parseLong(secondName.substring(3)); } suspendInvocation(firstName, continuation, timeout); } else { StringBuilder sb = new StringBuilder(); sb.append(firstName); // if the actual parameter is not null if (secondName != null && secondName.length() > 0) { String surname = continuation.getObject().toString(); sb.append(' ').append(surname); } // System.out.println("Saying hi to " + sb.toString()); return "Hi " + sb.toString(); } } // unreachable return null; }
continuation.setObject(userObject); suspended = true; continuation.suspend(2000);
public String sayHi(String firstName, String secondName) { Continuation continuation = getContinuation(firstName); if (continuation == null) { throw new RuntimeException("Failed to get continuation"); } synchronized (continuation) { if (continuation.isNew()) { Object userObject = secondName != null && secondName.length() > 0 ? secondName : null; continuation.setObject(userObject); suspendInvocation(firstName, continuation); } else { if (!continuation.isResumed() && !"Fred".equals(firstName)) { throw new RuntimeException("No timeout expected"); } StringBuilder sb = new StringBuilder(); sb.append(firstName); // if the actual parameter is not null if (secondName != null && secondName.length() > 0) { String surname = continuation.getObject().toString(); sb.append(' ').append(surname); } //System.out.println("Saying hi to " + sb.toString()); return "Hi " + sb.toString(); } } // unreachable return null; }
public String sayHi(String firstName, String secondName) { Continuation continuation = getContinuation(firstName); if (continuation == null) { throw new RuntimeException("Failed to get continuation"); } synchronized (continuation) { if (continuation.isNew()) { Object userObject = secondName != null && secondName.length() > 0 ? secondName : null; continuation.setObject(userObject); suspendInvocation(firstName, continuation); } else { if (!continuation.isResumed()) { throw new RuntimeException("No timeout expected"); } StringBuilder sb = new StringBuilder(); sb.append(firstName); // if the actual parameter is not null if (secondName != null && secondName.length() > 0) { String surname = continuation.getObject().toString(); sb.append(' ').append(surname); } //System.out.println("Saying hi to " + sb.toString()); return "Hi " + sb.toString(); } } // unreachable return null; }
continuation.setObject(future); if (future.isDone()) { return getResponse(future, successFactory, errorFactory);
continuation.setObject(message); if (continuation.suspend(-1)) { continuations.put(mn, continuation);
continuation.setObject(camelExchange);
continuation.setObject(camelExchange); cxfRsConsumer.getAsyncProcessor().process(camelExchange, new AsyncCallback() { public void done(boolean doneSync) {