axis-java-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Antony Wilson <antonywil...@gmail.com>
Subject [Axis2] EchoNonBlockingDualClient problem
Date Fri, 10 Mar 2006 12:12:35 GMT

I have not been able to get the EchonNonBlockingDualClient example to 
work as described in the documentation.  In my setup, I have Axis2 
deployed to JBoss 4.0.3 and I have modified the 
userguide.example1.MyService to delay for about 10 seconds before 
responding (leaving the 'echo' method).  After packaging and deploying 
the MyService.aar to Axis2, I run EchoNonBlockingDualClient 
example...slightly modified to add a print statement within the while 
loop...like so

    public static void main(String[] args) {
        try {
            OMElement payload = ClientUtil.getEchoOMElement();

            Options options = new Options();
            options.setTo(targetEPR);
            options.setTransportInProtocol(Constants.TRANSPORT_HTTP);
            options.setUseSeparateListener(true);

            //Callback to handle the response
            Callback callback = new Callback() {
                public void onComplete(AsyncResult result) {
                    try {
                        StringWriter writer = new StringWriter();
                        
result.getResponseEnvelope().serialize(XMLOutputFactory.newInstance()
                                .createXMLStreamWriter(writer));
                        writer.flush();
                        System.out.println(writer.toString());


                    } catch (XMLStreamException e) {
                        onError(e);
                    }
                }

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

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

            //Wait till the callback receives the response.
            while (!callback.isComplete()) {
                System.out.println("waiting...");
                Thread.sleep(1000);
            }
            //Need to close the Client Side Listener.

We I run it the code appears to block/wait at the 
"sender.sendRecieveNonBlocking(...)" line for about 10 seconds. When the 
program continues,  I never see any print statements since the 
"callback.isComplete()" is true by the time it gets to that point in the 
code.  The really bizarre part is that if I use 
"options.setUseSeparateListener(false)"...the behavior is exactly what I 
was originally expecting...I see several "waiting..." print statements 
before the callback's onComplete is invoked.  My operational scenario 
requires a dual channel transport since my webservice calls can be 
really long...therefore using a single two-way transport (e.g., 
options.setUseSeparateListener(false)) is not a viable option.

Bottomline, I can't seem to get the two-way dual channel stuff 
(EchoNonBlockingDualClient) to work for me.  I must be missing something 
obvious...but I don't see what it is.  Any help would be appreciated.

Thanks,
Tony


Mime
View raw message