@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; }
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; }
if (continuation.isNew()) { if (suspended) { throw new RuntimeException("Was already suspended");
public int doubleIt(int numberToDouble) throws DoubleItFault { Continuation continuation = getContinuation(numberToDouble); if (continuation == null) { throw new RuntimeException("Failed to get continuation"); } synchronized (continuation) { if (continuation.isNew()) { continuation.suspend(5000); } else { if (numberToDouble == 0) { throw new DoubleItFault("0 can't be doubled!"); } return numberToDouble * 2; } } // unreachable return 0; }
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; }
if(continuation.isNew()) {
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; } }
if (cont != null && config.isInOrder() && !cont.isNew()) { return waitInQueue(mn, canSkip, message, cont);
private Object asyncInvoke(Exchange cxfExchange, final Continuation continuation) { log.trace("asyncInvoke continuation: {}", continuation); synchronized (continuation) { if (continuation.isNew()) { final org.apache.camel.Exchange camelExchange = prepareCamelExchange(cxfExchange);
Continuation continuation = continuationProvider .getContinuation(); if (continuation.isNew()) { continuation.suspend(timeout * 1000); CxfBcConsumer.this.messages.put(exchange
private Object asyncInvoke(Exchange cxfExchange, final Object serviceObject, Method method, Object[] paramArray, final Continuation continuation, Object response) throws Exception { synchronized (continuation) { if (continuation.isNew()) { final org.apache.camel.Exchange camelExchange = prepareExchange(cxfExchange, method, paramArray, response);