Return-Path: X-Original-To: apmail-avro-user-archive@www.apache.org Delivered-To: apmail-avro-user-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 6E96ED65F for ; Sat, 22 Dec 2012 00:56:55 +0000 (UTC) Received: (qmail 58378 invoked by uid 500); 22 Dec 2012 00:56:54 -0000 Delivered-To: apmail-avro-user-archive@avro.apache.org Received: (qmail 58141 invoked by uid 500); 22 Dec 2012 00:56:54 -0000 Mailing-List: contact user-help@avro.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: user@avro.apache.org Delivered-To: mailing list user@avro.apache.org Received: (qmail 58133 invoked by uid 99); 22 Dec 2012 00:56:54 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Sat, 22 Dec 2012 00:56:54 +0000 X-ASF-Spam-Status: No, hits=2.2 required=5.0 tests=HTML_MESSAGE,RCVD_IN_DNSWL_LOW,SPF_NEUTRAL X-Spam-Check-By: apache.org Received-SPF: neutral (nike.apache.org: local policy) Received: from [209.85.160.41] (HELO mail-pb0-f41.google.com) (209.85.160.41) by apache.org (qpsmtpd/0.29) with ESMTP; Sat, 22 Dec 2012 00:56:44 +0000 Received: by mail-pb0-f41.google.com with SMTP id xa7so3021153pbc.14 for ; Fri, 21 Dec 2012 16:56:22 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=x-received:date:from:to:message-id:subject:x-mailer:mime-version :content-type:x-gm-message-state; bh=ICRQWWn4mmMeD5fVWmzCV+zWkEGrmOxGS1vIJZsPWWs=; b=e5yHeuDhwJLnYGWYYHB/R55Le+76D5GZLSvQnS6iiAA4FYf2NwRmDynw+/PJOd5LCh VW/AhJRpRInbY3GiV0sgEDK+GCOs47WAi6tf++4Dyflp3vSVNgvpIcGzVEEK8GPI+mDq Y7CU0PgCYcRpWU4pOEOPbDzg85Wp3Mtk9QKAaDHIS7rkIbzM5QL3LwpF7XFAz3S6m7OP x+oYWQ8pqiW9jNY0kluyTl5F6P9Trw/IhqqZSRLQXamHMIun4wY8GA9qRaXXUb1vuI7N xDGiUPKMl1kNzYmYb99PY+brwjdSbeTgVHVmxz9aBAyB+pltMqJJAujEQ1mVaEaSHxxW ryfw== X-Received: by 10.68.241.136 with SMTP id wi8mr44826495pbc.95.1356137782270; Fri, 21 Dec 2012 16:56:22 -0800 (PST) Received: from [10.50.1.114] (50-79-154-237-static.hfc.comcastbusiness.net. [50.79.154.237]) by mx.google.com with ESMTPS id w5sm8250786pax.28.2012.12.21.16.56.19 (version=TLSv1/SSLv3 cipher=OTHER); Fri, 21 Dec 2012 16:56:21 -0800 (PST) Date: Fri, 21 Dec 2012 16:56:17 -0800 From: Mike Machado To: user@avro.apache.org Message-ID: Subject: Re: Async Client Not Working X-Mailer: sparrow 1.6.3 (build 1172) MIME-Version: 1.0 Content-Type: multipart/alternative; boundary="50d50531_5895f5fa_3f7" X-Gm-Message-State: ALoCoQl1y72XjQa9TXVZ9Y23oAHUZ98tMRJmfu41Y623CrMNaNOT9Gb51dajnj44fK68k28Tjnz9 X-Virus-Checked: Checked by ClamAV on apache.org --50d50531_5895f5fa_3f7 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Content-Disposition: inline > Can you please provide complete code for a test that fails=3F Thanks=21= Here is a single class that builds upon one of the common avro examples o= ut there on the web, showing that async is not working: package com.example.avrotest1; import java.io.IOException; import java.net.InetSocketAddress; import org.apache.avro.ipc.specific.SpecificRequestor; import org.apache.avro.ipc.specific.SpecificResponder; import org.apache.avro.util.Utf8; import example.proto.Mail; import example.proto.Message; import org.apache.avro.ipc.Callback; import org.apache.avro.ipc.NettyServer; import org.apache.avro.ipc.NettyTransceiver; import org.apache.avro.ipc.Server; /** * Start a server, attach a client, and send a message. */ public class ExampleProto =7B public static class MailImpl implements Mail =7B // in this simple example just return details of the message public Utf8 send(Message message) =7B System.out.println(=22Sending message=22); try =7B Thread.sleep(5000); =7D catch (InterruptedException e) =7B // TODO Auto-generated catch block e.printStackTrace(); =7D return new Utf8(=22Sending message to =22 + message.getTo().t= oString() + =22 from =22 + message.get=46rom().toString() + =22 with body =22 + message.getBody().toString()); =7D =7D private static Server server; private static void startServer() throws IOException =7B server =3D new NettyServer(new SpecificResponder(Mail.class, new = MailImpl()), new InetSocketAddress(65111)); // the server implements the Mail protocol (MailImpl) =7D public static void main(String=5B=5D args) throws IOException =7B if (args.length =21=3D 3) =7B System.out.println(=22Usage: =22); System.exit(1); =7D System.out.println(=22Starting server=22); // usually this would be another app, but for simplicity startServer(); System.out.println(=22Server started=22); NettyTransceiver client =3D new NettyTransceiver(new InetSocketAd= dress(65111)); // client code - attach to the server and send a message Mail.Callback proxy =3D SpecificRequestor.getClient(Mail.Callback= .class, client); System.out.println(=22Client built, got proxy=22); // fill in the Message record and send it Message message =3D new Message(); message.setTo(new Utf8(args=5B0=5D)); message.set=46rom(new Utf8(args=5B1=5D)); message.setBody(new Utf8(args=5B2=5D)); System.out.println(=22Calling proxy.send with message: =22 + mes= sage.toString()); proxy.send(message, new Callback() =7B =40Override public void handleError(Throwable arg0) =7B System.out.println(=22Error: =22 + arg0.getMessage()); =7D =40Override public void handleResult(CharSequence arg0) =7B System.out.println(=22Got async result =22 + arg0); =7D =7D); =20 System.out.println(=22Should see this log before Closure 'Got asy= nc result' message - but do not.=22); try =7B Thread.sleep(5000); =7D catch (InterruptedException e) =7B // TODO Auto-generated catch block e.printStackTrace(); =7D =20 =20 // cleanup client.close(); server.close(); =7D =7D Schema: =7B=22namespace=22: =22example.proto=22, =22protocol=22: =22Mail=22, =22types=22: =5B =7B=22name=22: =22Message=22, =22type=22: =22record=22, =22fields=22: =5B =7B=22name=22: =22to=22, =22type=22: =22string=22=7D, =7B=22name=22: =22from=22, =22type=22: =22string=22=7D, =7B=22name=22: =22body=22, =22type=22: =22string=22=7D =5D =7D =5D, =22messages=22: =7B =22send=22: =7B =22request=22: =5B=7B=22name=22: =22message=22, =22type=22: =22M= essage=22=7D=5D, =22response=22: =22string=22 =7D =7D =7D Output: =20 Starting server Server started Client built, got proxy Calling proxy.send with message: =7B=22to=22: =22some=5Fuser=22, =22from= =22: =22joe=22, =22body=22: =22Hello=5FWorld=22=7D Sending message Got async result Sending message to some=5Fuser from joe with body Hello=5F= World Should see this log before Closure 'Got async result' message - but do no= t. So clearly, proxy.send() is not acting asynchronous otherwise we would se= e the =22Should see=E2=80=A6=22 log before the =22Got async=E2=80=A6=22 l= og. --50d50531_5895f5fa_3f7 Content-Type: text/html; charset="utf-8" Content-Transfer-Encoding: quoted-printable Content-Disposition: inline

Can you please provide complete = code for a test that fails=3F Thanks=21

=
<= /span>
Here is a single class that builds upon one of the common avr= o examples out there on the web, showing that async is not working:



package com.example.avrotest1;<= /div>

import java.io.IOException;
import java.net.InetSocketAddress;

import org.apache.avro.ipc.specific.SpecificReques= tor;
import org.apache.a= vro.ipc.specific.SpecificResponder;
import org.apache.avro.util.Utf8;

import example.proto.Mail;
import example.proto.Message;

import or= g.apache.avro.ipc.Callback;
import org.apache.avro.ipc.NettyServer;
import org.apache.avro.ipc.NettyTransceiver;
import org.apache.avro.ipc.Serve= r;

/**
 * Start a server, attach a client, and send a message.
 */
public class ExampleProto =7B
    public static class Ma= ilImpl implements Mail =7B
        // in this simple example just return detail= s of the message
  =       public Utf8 send(Message message) =7B
          &nb= sp; System.out.println(=22Sending message=22);
            try =7B<= /div>
Thread.sleep(5000);
=7D catch (InterruptedE= xception e) =7B
// TO= DO Auto-generated catch block
= e.printStackTrace();
= =7D
   = ;         return new Utf8(=22Sending message to =22 += message.getTo().toString()
                   = + =22 from =22 + message.get=46rom().toString()
             =       + =22 with body =22 + message.getBody().toString())= ;
      &= nbsp; =7D
    = =7D

    private static Server ser= ver;

    private static void star= tServer() throws IOException =7B
        server =3D new NettyServer(new Speci= ficResponder(Mail.class, new MailImpl()), new InetSocketAddress(65111));<= /div>
      &nb= sp; // the server implements the Mail protocol (MailImpl)
    =7D

    public static void main(String=5B=5D args) throws = IOException =7B
  &= nbsp;     if (args.length =21=3D 3) =7B
            Syste= m.out.println(=22Usage: <to> <from> <body>=22);
        &nb= sp;   System.exit(1);
        =7D

  &nb= sp;     System.out.println(=22Starting server=22);
        // usual= ly this would be another app, but for simplicity
        startServer();
=
        S= ystem.out.println(=22Server started=22);

&n= bsp;       NettyTransceiver client =3D new NettyTransceive= r(new InetSocketAddress(65111));
        // client code - attach to the serve= r and send a message
&nb= sp;       Mail.Callback proxy =3D SpecificRequestor.getCli= ent(Mail.Callback.class, client);
        System.out.println(=22Client built,= got proxy=22);

       = // fill in the Message record and send it
        Message message =3D new Me= ssage();
    &= nbsp;   message.setTo(new Utf8(args=5B0=5D));
        message.set=46rom(= new Utf8(args=5B1=5D));
=         message.setBody(new Utf8(args=5B2=5D));
=
        S= ystem.out.println(=22Calling proxy.send with message:  =22 + message= .toString());
  &nb= sp;     proxy.send(message, new Callback<CharSequence>() = =7B

=40Override
public void handleError(Throwable arg0) =7B
System.out.println(=22Er= ror: =22 + arg0.getMessage());
= =7D

<= div style=3D=22font-family: monospace; =22> =40Override
public void handleResult(CharSequence arg= 0) =7B
System.out.pri= ntln(=22Got async result =22 + arg0);
=7D
&nbs= p;       =7D);
        
        System.out.println(=22Should = see this log before Closure 'Got async result' message - but do not.=22);=

        try =7B
<= div style=3D=22font-family: monospace; =22> Thread.sleep(5000);
=7D catch (InterruptedException e= ) =7B
// TODO Auto-gen= erated catch block
e.p= rintStackTrace();
=7D
      &nbs= p; 
    &= nbsp;   
 = ;       // cleanup
        client.close();
        server.close();
    =7D
=7D


Schema:


=7B=22namespace=22: =22example.pr= oto=22,

 =22protocol=22: =22Mail=22,

 =22types=22: =5B

 &n= bsp;   =7B=22name=22: =22Message=22, =22type=22: =22record=22,

 = ;     =22fields=22: =5B

          =7B=22= name=22: =22to=22,   =22type=22: =22string=22=7D,

    &nbs= p;     =7B=22name=22: =22from=22, =22type=22: =22string=22=7D,<= /p>

=           =7B=22name=22: =22body=22, =22type=22:= =22string=22=7D

      =5D

     =7D

 =5D= ,

&nb= sp;=22messages=22: =7B

     =22send=22: =7B

   &= nbsp;     =22request=22: =5B=7B=22name=22: =22message=22, =22ty= pe=22: =22Message=22=7D=5D,

         =22response= =22: =22string=22

     =7D

 =7D

=7D



=


Output:

St= arting server

Server started

Client built, got proxy

Calling proxy.send w= ith message:  =7B=22to=22: =22some=5Fuser=22, =22from=22: =22joe=22,= =22body=22: =22Hello=5FWorld=22=7D

Sending message

Got async result Send= ing message to some=5Fuser from joe with body Hello=5FWorld

Should see thi= s log before Closure 'Got async result' message - but do not.





So clearly, proxy.send() is not acting asynchronous otherwise we = would see the =22Should see=E2=80=A6=22 log before the =22Got async=E2=80= =A6=22 log.




--50d50531_5895f5fa_3f7--