Examples of AsyncResponseHandler


Examples of async.AsyncResponseHandler

        return;
      }

      WSIFOperation op = port.createOperation("getAddressFromName");

      AsyncResponseHandler abHandler = new AsyncResponseHandler(1);
      // 1 async call

      WSIFMessage inMsg = op.createInputMessage();
      inMsg.setObjectPart("name", "fred");

      WSIFMessage outmsg = op.createOutputMessage();
      WSIFMessage faultMsg = op.createFaultMessage();

      WSIFMessage context = op.getContext();
      context.setObjectPart(
        WSIFConstants.CONTEXT_JMS_PREFIX + "JMSReplyTo",
        TestUtilities.getWsifProperty("wsif.async.replytoq"));

      if ("SOAPJMSPort2".equals(portName)
        || "NativeJmsPort2".equals(portName)) {
        inMsg.setObjectPart("asyncTimeout", "" + spa2);
      }
      if ("SOAPJMSPort3".equals(portName)
        || "NativeJmsPort3".equals(portName)
        || "SOAPJMSPort6".equals(portName)
        || "NativeJmsPort6".equals(portName)) {
        context.setObjectPart(
          WSIFConstants.WSIF_PROP_ASYNC_TIMEOUT,
          "" + spa3);
      }

      op.setContext(context);

      WSIFCorrelationId id =
        op.executeRequestResponseAsync(inMsg, abHandler);
      assertTrue(
        "null correlation id returned from async request!",
        id != null);

      int i = 30;
      while (i-- > 0 && !abHandler.isDone()) {
        System.out.println("waiting for async responses - " + i);
        try {
          Thread.sleep(1000);
        } catch (InterruptedException ex) {
        }
View Full Code Here

Examples of async.AsyncResponseHandler

      //   assertTrue( "exception executing request: " + ex.getMessage(), false );
      //}
  }

  private WSIFMessage doAsyncOp(WSIFOperation op, WSIFMessage input, WSIFMessage context) throws WSIFException{
      AsyncResponseHandler handler = new AsyncResponseHandler(1); // 2 async calls
      context.setObjectPart( WSIFConstants.CONTEXT_JMS_PREFIX + "JMSReplyTo",
                             TestUtilities.getWsifProperty("wsif.async.replytoq") );
      op.setContext( context );
      WSIFCorrelationId id = op.executeRequestResponseAsync(input, handler);

      int i = 5// 15 seconds timout
      while ( i-- > 0 && !handler.isDone() ) {
         System.out.println( "async requests sent, waiting for responses - " + i );
       try {
        Thread.sleep(3000);
       } catch (InterruptedException ex) {}
      }
      assertTrue( "no response to async operation!", i > 0 ); // no responses in time
      return handler.getOutputs()[0];
  }
View Full Code Here

Examples of async.AsyncResponseHandler

              return;
            }   

            WSIFOperation op = port.createOperation( "getAddressFromName" );
           
            AsyncResponseHandler abHandler = new AsyncResponseHandler( 1 ); // 1 async call

            WSIFMessage inMsg = op.createInputMessage();
            inMsg.setObjectPart( "name", name );

            WSIFMessage outmsg = op.createOutputMessage();
            WSIFMessage faultMsg = op.createFaultMessage();

            WSIFMessage context = op.getContext();
            context.setObjectPart( WSIFConstants.CONTEXT_JMS_PREFIX + "JMSReplyTo",
                                   TestUtilities.getWsifProperty("wsif.async.replytoq") );
            op.setContext( context );

            WSIFCorrelationId id = op.executeRequestResponseAsync(inMsg, abHandler);
            assertTrue("null correlation id returned from async request!", id != null );

            int i = 10;
            while (i-- > 0 && !abHandler.isDone()) {
                System.out.println( "waiting for async responses - " + i );
                try {
                    Thread.sleep(3000);
                } catch (InterruptedException ex) {
                }
            }
            assertTrue("no response from async operation!",i > 0); // no responses in time

            WSIFMessage[] faults = abHandler.getFaults();
            WSIFMessage[] outputs = abHandler.getOutputs();
            Address respAddr = (Address) outputs[0].getObjectPart("address");
            assertTrue("incorrect address response!", addr.equals(respAddr));

       } catch (Exception ex) {
           ex.printStackTrace();
View Full Code Here

Examples of com.dragome.services.interfaces.AsyncResponseHandler

          asyncCallback.onError();
        }

        public void onSuccess(S result)
        {
          AsyncResponseHandler asyncResponseHandler= createRemoteServiceByWebSocket(AsyncResponseHandler.class);
          String id= (String) ScriptHelper.eval("this.javaId", this);
          asyncResponseHandler.pushResponse((String) result, id);
        }
      };
    }
    else
      result= (AsyncCallback<S>) asyncCallback;
View Full Code Here

Examples of com.dragome.services.interfaces.AsyncResponseHandler

          asyncCallback.onError();
        }

        public void onSuccess(S result)
        {
          AsyncResponseHandler asyncResponseHandler= createRemoteServiceByWebSocket(AsyncResponseHandler.class);
          String id= (String) ScriptHelper.eval("this.javaId", this);
          asyncResponseHandler.pushResponse((String) result, id);
        }
      };
    }
    else
      result= (AsyncCallback<S>) asyncCallback;
View Full Code Here

Examples of org.apache.tuscany.sca.core.invocation.AsyncResponseHandler

    if( responseHandler == null )
      throw new ServiceRuntimeException("JavaAsyncResponseInvoker - no Future matches the RELATES_TO id: " + relatesID);
   
    // Invoke the response handler with the content of the message
    // - in the case of a Java implementation, the response handler is a Future...
    AsyncResponseHandler future = (AsyncResponseHandler) responseHandler;
   
    Object payload = msg.getBody();
    Object response;
    if( payload == null ) {
      System.out.println("Returned response message was null");
    } else {
            if (payload.getClass().isArray()) {
                response = ((Object[])payload)[0];
            } else {
                response = payload;
            } // end if
            if( response.getClass().equals(AsyncFaultWrapper.class)) {
              future.setWrappedFault((AsyncFaultWrapper) response );
            } else if ( response instanceof Throwable ) {
              future.setFault( (Throwable)response );
            } else {
              future.setResponse(response);
            } // end if
    } // end if

  } // end method invokeAsyncResponse
View Full Code Here

Examples of org.apache.tuscany.sca.core.invocation.AsyncResponseHandler

    if( responseHandler == null )
      throw new ServiceRuntimeException("JavaAsyncResponseInvoker - no Future matches the RELATES_TO id: " + relatesID);
   
    // Invoke the response handler with the content of the message
    // - in the case of a Java implementation, the response handler is a Future...
    AsyncResponseHandler future = (AsyncResponseHandler) responseHandler;
   
    Object payload = msg.getBody();
    Object response;
    if( payload == null ) {
      System.out.println("Returned response message was null");
    } else {
            if (payload.getClass().isArray()) {
                response = ((Object[])payload)[0];
            } else {
                response = payload;
            } // end if
            if( response.getClass().equals(AsyncFaultWrapper.class)) {
              future.setWrappedFault((AsyncFaultWrapper) response );
            } else if ( response instanceof Throwable ) {
              future.setFault( (Throwable)response );
            } else {
              future.setResponse(response);
            } // end if
    } // end if

  } // end method invokeAsyncResponse
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.