public synchronized boolean suspendContinuationIfNeeded() { if (!resumedByApplication && !isDone() && !cont.isPending() && !cont.isResumed()) { cont.suspend(AsyncResponse.NO_TIMEOUT); initialSuspend = false; return true; } return false; }
throw new RuntimeException("Was not suspended yet"); if (continuation.isResumed()) { throw new RuntimeException("It must be a timeout");
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; }
public SOAPMessage invoke(SOAPMessage request) { try { final MessageContext messageContext = ctx.getMessageContext(); ContinuationProvider contProvider = (ContinuationProvider) messageContext.get(ContinuationProvider.class.getName()); final Continuation continuation = contProvider.getContinuation(); if (continuation.isNew()) { continuation.suspend(5000); new Thread(new Runnable() { public void run() { try { continuation.resume(); } catch (Exception e) { e.printStackTrace(); } } }).start(); return null; } else if (!continuation.isResumed()) { continuation.reset(); throw new RuntimeException("time out"); } else { return resumeMessage(request); } } catch (SOAPFaultException e) { throw e; } }
} else if (!continuation.isTimeout() && continuation.isResumed()) { org.apache.camel.Exchange camelExchange = (org.apache.camel.Exchange)continuation.getObject(); try { } else if (continuation.isTimeout() || (!continuation.isResumed() && !continuation.isPending())) { org.apache.camel.Exchange camelExchange = (org.apache.camel.Exchange)continuation.getObject(); try {
.getExchangeId(), message); context.getDeliveryChannel().send(exchange); } else if (!continuation.isResumed()) { if (!continuation.isPending()) { messages.remove(exchange.getExchangeId());
return null; if (!continuation.isTimeout() && continuation.isResumed()) { cxfExchange.put(SUSPENED, Boolean.FALSE); org.apache.camel.Exchange camelExchange = (org.apache.camel.Exchange)continuation.getObject();