axis-java-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Akhila (JIRA)" <j...@apache.org>
Subject [jira] Commented: (AXIS2-4085) While loop doesnot exit while running echo non blocking client
Date Wed, 05 Nov 2008 05:01:44 GMT

    [ https://issues.apache.org/jira/browse/AXIS2-4085?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12645152#action_12645152
] 

Akhila commented on AXIS2-4085:
-------------------------------

hi ,
 
thanks for your reply , i gave these methods only while defiinig testCallBack class that implement
axisCallback method . the full class is given below .
package userguide.clients;

 

import javax.mail.MessageContext;
import org.apache.axiom.om.OMElement;
import org.apache.axis2.AxisFault;
import org.apache.axis2.addressing.EndpointReference;
import org.apache.axis2.client.Options;
import org.apache.axis2.client.ServiceClient;
import org.apache.axis2.client.async.AsyncResult;
import org.apache.axis2.client.async.AxisCallback;
import org.apache.axis2.client.async.Callback;

/**
 * Sample for asynchronous single channel non-blocking service invocation.
 * Message Exchage Pattern IN-OUT
 */
public class EchoNonBlockingClient {
    private static EndpointReference targetEPR = new EndpointReference("http://localhost:8080/axis2/services/MyService");
    public static void main(String[] args) {
        ServiceClient sender = null;
        try {
            OMElement payload = ClientUtil.getEchoOMElement();
            Options options = new Options();
            options.setTo(targetEPR);
            options.setAction("urn:echo");
          TestCallback axisCallback = new TestCallback( " Call Back 1 "  ) ;
             sender = new ServiceClient();
            sender.setOptions(options);
            sender.sendReceiveNonBlocking( payload, axisCallback );
             System.out.println( " after service client ") ;
            //Wait till the callback receives the response.
            // axisCallback.onComplete( ) ;
           while (  ! axisCallback.isComplete( ) )  {
    //            Thread.sleep(1000);
                 Thread.sleep(10);
            }

          //  System.out.println( " completed ") ;

            //Callback to handle the response
 /*      Callback callback = new Callback() {
                public void onComplete(AsyncResult result) {
                    System.out.println(result.getResponseEnvelope());
                }

                public void onError(Exception e) {
                    e.printStackTrace();
                }
            };

            //Non-Blocking Invocation
            sender = new ServiceClient();
            sender.setOptions(options);
            sender.sendReceiveNonBlocking(payload, callback);

            //Wait till the callback receives the response.
            while (!callback.isComplete()) {
                Thread.sleep(1000);
            } */

        } catch (AxisFault axisFault) {
            axisFault.printStackTrace();
        } catch (Exception ex) {
            ex.printStackTrace();
        } finally {
            try {
                sender.cleanup();
            } catch (AxisFault axisFault) {
                //
            }
        }
        
 

    }
    
    static class TestCallback implements  AxisCallback {

        String name = null;
        private boolean _complete = false ;
        public TestCallback ( ) {
          //      this.name = name;
        }
        public TestCallback (String name) {
                this.name = name;
          }

        public void onError (Exception e) {
                e.printStackTrace();
        }

        public void onComplete() {
             System.out.println( " message transmission complete ") ;
            _complete = true;
        }
        
        public boolean isComplete() {
            return _complete;
        }

        public void onMessage(org.apache.axis2.context.MessageContext arg0) {
        /*    System.out.println( "we received a message" ) ;
            System.out.println( "Axis message " + arg0.getAxisMessage( ) ) ;
              System.out.println( " Axis operation " + arg0.getAxisOperation( ) ) ;
              System.out.println( " Axis service " + arg0.getAxisService( ) ) ;
              System.out.println( " Current message " + arg0.getCurrentMessageContext() )
;
               System.out.println( " InComming Trans port Name " + arg0.getIncomingTransportName()
) ;
                System.out.println( " Message ID  " + arg0.getMessageID() ) ;
                 System.out.println( " Saop Action  " + arg0.getSoapAction( ) ) ;*/
                    System.out.println( " Call Back   " + name + "got Result " + arg0.getEnvelope()
) ;
           //       onComplete( ) ;
            //throw new UnsupportedOperationException("Not supported yet.");
        }

        public void onFault(org.apache.axis2.context.MessageContext arg0) {
            
        }
        }
}


thanks & regards

akhila




> While loop doesnot exit while running echo non blocking client 
> ---------------------------------------------------------------
>
>                 Key: AXIS2-4085
>                 URL: https://issues.apache.org/jira/browse/AXIS2-4085
>             Project: Axis 2.0 (Axis2)
>          Issue Type: Bug
>          Components: samples
>    Affects Versions: 1.4.1
>         Environment: Windows XP Professional Vesion 2002 SP-2 , NetBeans 6.1
>            Reporter: Akhila
>            Priority: Critical
>
> public class EchoNonBlockingClient {
>     private static EndpointReference targetEPR = new EndpointReference("http://localhost:8080/axis2/services/MyService");
>     public static void main(String[] args) {
>         ServiceClient sender = null;
>         try {
>             OMElement payload = ClientUtil.getEchoOMElement();
>             Options options = new Options();
>             options.setTo(targetEPR);
>             options.setAction("urn:echo");
>           TestCallback axisCallback = new TestCallback( " Call Back 1 "  ) ;
>              sender = new ServiceClient();
>             sender.setOptions(options);
>             sender.sendReceiveNonBlocking( payload, axisCallback );
>             //Wait till the callback receives the response.
>            while (  ! axisCallback.isComplete( ) )  {
>               Thread.sleep(1000);
>             }
> While running  this program ( echo-nonblocking client ( using axisCallback interface
instead of Callback ) )  , it goes to infinite loop in     while (  ! axisCallback.isComplete(
) )  {
>               Thread.sleep(1000);
>             }

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


---------------------------------------------------------------------
To unsubscribe, e-mail: axis-dev-unsubscribe@ws.apache.org
For additional commands, e-mail: axis-dev-help@ws.apache.org


Mime
View raw message