Package org.talend.esb.mep.requestcallback.feature

Examples of org.talend.esb.mep.requestcallback.feature.CallContext


        System.out.println("*** seekBookInBasement request (Request-Callback operation) was received ***");
        System.out.println("****************************************************************************");

        showSeekBookInBasementRequest(body);

        CallContext ctx = CallContext.getCallContext(wsContext.getMessageContext());

        System.out.println("Info from CallContext:");
        System.out.println("- Call ID is " + ctx.getCallId());

        /**** Storing Call Context *** */
        System.out.println("Storing CallContext:");

        CallContextStore<CallContext> ccs = new CallContextStore<CallContext>();
        String callContextKey;
        try {
            callContextKey = ccs.saveObject(ctx);
            System.out.println("- callContext saved with key: " + callContextKey);
        } catch (Exception e) {
            callContextKey = null;
            System.out.println("Auxiliary Storage Service seems to be unavailable.");
            System.out.println("Proceeding without storing the CallContext.");
        }

        if (callContextKey != null) {
            /**** Restoring Call Context *** */
            System.out.println("Restoring CallContext:");
            ctx = ccs.getStoredObject(callContextKey);
            System.out.println("- callContext restored");

            System.out.println("Info from restored CallContext:");
            System.out.println("- Call ID is " + ctx.getCallId());

            /**** Remove Call context ***/
            ccs.removeStoredObject(callContextKey);
        }

        List<String> authorsLastNames = body.getAuthorLastName();
        if (authorsLastNames != null && authorsLastNames.size() > 0) {
            String authorsLastName = authorsLastNames.get(0);
            if (authorsLastName != null && authorsLastName.length() > 0
                    && !"Stripycat".equalsIgnoreCase(authorsLastName)) {

                SeekBookError e = prepareException("No book available from author "
                        + authorsLastName);

                System.out.println("No book available from author "
                        + authorsLastName);
                System.out
                        .println("\nSending business fault (SeekBook error) with parameters:");

                Utils.showSeekBookError(e);

                LibraryConsumer libraryConsumer = ctx.createCallbackProxy(LibraryConsumer.class);
                libraryConsumer.seekBookInBasementFault(e.getFaultInfo());

                if (callContextKey != null) {
                    /**** Removing Call Context *** */
                    System.out.println("Removing CallContext:");
                    ccs.removeStoredObject(callContextKey);
                    System.out.println("- callContext removed");
                }
                return;
            }
        }

        ListOfBooks result = new ListOfBooks();
        BookType book = new BookType();
        result.getBook().add(book);
        PersonType author = new PersonType();
        book.getAuthor().add(author);
        author.setFirstName("John");
        author.setLastName("Stripycat");
        Calendar dateOfBirth = new GregorianCalendar(202, Calendar.MAY, 17);
        author.setDateOfBirth(dateOfBirth.getTime());
        book.getTitle().add("Hunting basement inhabitants");
        book.getPublisher().add("Dusty Edition");
        book.setYearPublished("2013");

        System.out.println("Book(s) is found:");

        showSeekBookResponse(result);

        ctx.setupCallbackProxy(callbackResponseClient);
        callbackResponseClient.seekBookInBasementResponse(result);

        book.getTitle().set(0, "Hunting more basement inhabitants");
        book.setYearPublished("2014");

        showSeekBookResponse(result);

        ctx.setupCallbackProxy(callbackResponseClient);
        callbackResponseClient.seekBookInBasementResponse(result);

        if (callContextKey != null) {
            /**** Removing Call Context *** */
            System.out.println("Removing CallContext:");
View Full Code Here


        System.out.println("*** seekBookInBasementResponse response (Request-Callback operation) was received ***");
        System.out.println("*************************************************************************************\n");

        Utils.showBooks(body);

        CallContext ctx = CallContext.getCallContext(wsContext.getMessageContext());
        System.out.println("Info from CallContext:");
        if (ctx == null) {
          System.out.println("- no CallContext");
        } else {
          System.out.println("- Call ID is " + ctx.getCallId());
          System.out.println("- Callback ID is " + ctx.getCallbackId());
        }
        responses.offer(body);
    }
View Full Code Here

        System.out.println("*** seekBookInBasementFault response (Request-Callback operation) was received ******");
        System.out.println("*************************************************************************************\n");

        Utils.showExceptionFrame(exception);

        CallContext ctx = CallContext.getCallContext(wsContext.getMessageContext());
        System.out.println("Info from CallContext:");
        if (ctx == null) {
          System.out.println("- no CallContext");
        } else {
          System.out.println("- Call ID is " + ctx.getCallId());
          System.out.println("- Callback ID is " + ctx.getCallbackId());
        }
        responses.offer(exception);
    }
View Full Code Here

    final AddressingProperties maps = getAddressingProperties(message);
    if (maps == null) {
      throw new IllegalStateException(
          "Request-Callback enabled but no WS-Addressing headers set. ");
    }
    CallContext ctx = new CallContext();
    message.put(RequestCallbackFeature.CALLCONTEXT_PROPERTY_NAME, ctx);
    final QName operationName = QName.valueOf(maps.getAction().getValue());
    if (!isGenericOperation(operationName)) {
      ctx.setOperationName(operationName);
    }
    ctx.setCallId(valueOf(callHeader));
    if (callbackHeader != null) {
      ctx.setCallbackId(valueOf(callbackHeader));
    }
    ctx.setRequestId(maps.getMessageID().getValue());
    ctx.setReplyToAddress(maps.getReplyTo().getAddress().getValue());
    ctx.setCorrelationId(getCorrelationId(message));

    // Try to get SAM flowId in request message
    // to store it in CallContext for subsequent use
    // in callback message
    if (callbackHeader == null) {
View Full Code Here

  }

  @Override
  public String createObjectKey(E ctxObj) {
    if(ctxObj instanceof CallContext){
      CallContext ctx = (CallContext)ctxObj;
      String key = ctx.getCallId();
      return prettifyCallContextKey(key);
    }
   
    return null;
  }
View Full Code Here

    }
   
    @Override
    public StreamSource invoke(StreamSource request) {
      try {
        CallContext context = CallContext.getCallContext(wsContext);
        assertNotNull("CallContext missing", context);
        QName opName = context.getOperationName();
        assertNotNull("Response action missing", opName);
          IncomingMessageHandler businessHandler = callbackMap.get(opName.getLocalPart());
          if (businessHandler == null) {
              throw new RuntimeException("Unknown callback operation: " + context.getOperationName().getLocalPart());
          }
          businessHandler.handleMessage(request, context);
      } catch (Exception e) {
        addError(e);
      } catch (AssertionError e) {
View Full Code Here

   
    @Override
    public StreamSource invoke(StreamSource request) {
      try {
          System.out.println("Service is invoked!!!");
          CallContext callContext = CallContext.getCallContext(wsContext);
          assertEquals(callContext.getOperationName().getLocalPart(), expectedOperation);
          businessHandler.handleMessage(request, callContext);
      } catch (Exception e) {
        addError(e);
      } catch (AssertionError e) {
        addError(e);
View Full Code Here

        throw new IllegalArgumentException("Unsupported type of endpoint. ");
      }
      doHandleRequestSoapMessage(message, callbackEndpointAddress);
      return;
    }
    final CallContext ctx = (CallContext) message.getContextualProperty(
        RequestCallbackFeature.CALLCONTEXT_PROPERTY_NAME);
    if (ctx != null) {
      doHandleCallbackSoapMessage(message, ctx);
      return;
    }
View Full Code Here

TOP

Related Classes of org.talend.esb.mep.requestcallback.feature.CallContext

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.