Using Netty from within an Oracle Database

Adrian Nakon a_p_nakon at hotmail.com
Tue Oct 18 08:31:20 EDT 2011


Hi Norman,
Thanks for your reply.
Here is my code - It's pretty simple (I'm a newbie to Netty) :
Any help would be greatly appreciated.  :)

Thanks,
Adrian.

---------------------------------

package nclient;
/** * * @author ANakon */
import java.net.InetSocketAddress;import java.util.Map;import java.util.concurrent.Executors;import org.jboss.netty.bootstrap.ClientBootstrap;import org.jboss.netty.channel.Channel;import org.jboss.netty.channel.ChannelFactory;import org.jboss.netty.channel.ChannelFuture;import org.jboss.netty.channel.ChannelFutureListener;import org.jboss.netty.channel.ChannelPipeline;import org.jboss.netty.channel.ChannelPipelineFactory;import org.jboss.netty.channel.Channels;import org.jboss.netty.channel.socket.nio.NioClientSocketChannelFactory;

public class NettyClient {      static int  counter = 0;        public static void main(String[] args) throws Exception {        String host = args[0];        int port = Integer.parseInt(args[1]);
                ChannelFactory factory =            new NioClientSocketChannelFactory(                    Executors.newCachedThreadPool(),                    Executors.newCachedThreadPool());
        ClientBootstrap bootstrap = new ClientBootstrap(factory);
        bootstrap.setPipelineFactory(new ChannelPipelineFactory() {//            @Override            public ChannelPipeline getPipeline() {                return Channels.pipeline(                        new TimeDecoder(),                        new TimeEncoder(),                        new TimeClientHandler());            }        });                bootstrap.setOption("tcpNoDelay", true);        bootstrap.setOption("keepAlive", true);
        //        // Lets loop forever .....        //                ChannelFuture future;                while (true)        {            //          // Send a message to the time server.          //                    //          // We're going to use a ChannelFuture here since it allows us to manage          //  the channel and clean up afterwards.          //                    future = bootstrap.connect(new InetSocketAddress(host, port));            
                    //          // We have a connection.  Send a message to the server.          //                    future.addListener(new ChannelFutureListenerImpl());                              //          // Wait for the returned ChannelFuture to determine if the connection attempt was successful or not.          //                    future.awaitUninterruptibly();                    //          // If failed, we print the cause of the failure to know why it failed. the getCause() method of          //  ChannelFuture will return the cause of the failure if the connection attempt was neither successful          //  nor cancelled.          //                    if (!future.isSuccess())           {            future.getCause().printStackTrace();          }                   //          // Sleep for a second before trying again.          //                    Thread.sleep(1000);                            }      
    }
  private static class ChannelFutureListenerImpl implements ChannelFutureListener  {
    public ChannelFutureListenerImpl()    {    }
//    @Override    public void operationComplete(ChannelFuture future) {        Channel ch = future.getChannel();                  String user = System.getenv("USERNAME");                    String origion = "Hi from the client @ " + user + " - " + counter;          counter++;                    System.out.println("Operation complete connected = : " + ch.isConnected());                    ChannelFuture f = future.getChannel().write(origion);               }  }    }

===================== 

> Date: Tue, 18 Oct 2011 14:18:00 +0200
> Subject: Re: Using Netty from within an Oracle Database
> From: norman.maurer at googlemail.com
> To: netty-users at lists.jboss.org
> 
> Show us your code...
> 
> Bye,
> Norman
> 
> 
> 2011/10/18 Adrian Nakon <a_p_nakon at hotmail.com>:
> > Hi Guys,
> > I am trying to get a Netty based client to run from within an Oracle
> > Database (Oracle DB uses JVM 1.5).
> > So far things are going well, in that I can get classes / jars loaded into
> > the DB etc. without error.
> > The next thing I'm trying to do is get a connected out from within the DB
> > (using Netty) to talk to a
> > small Netty service I've written.  This service is running on the same
> > machine as the DB, so can be
> > considered local.
> > I am seeing this error, and would appreciate any input.  Does this error
> > indicate a config error (quite possible!),
> > or does it indicate that what I'm trying to do isn't actually possible?
> > ---------------
> > ORA-29532: Java call terminated by uncaught Java exception:
> > org.jboss.netty.channel.ChannelException: java.net.SocketException: Socket
> > option not supported by PlainDatagramSocketImp
> > Socket operation on non-socket
> > ORA-06512: at "COHERENCE.NETTYCLIENT", line 3
> > ORA-06512: at line 12
> > ----------------
> > Many Thanks,
> > Adrian.
> >
> >
> >
> > =====================
> > _______________________________________________
> > netty-users mailing list
> > netty-users at lists.jboss.org
> > https://lists.jboss.org/mailman/listinfo/netty-users
> >
> 
> _______________________________________________
> netty-users mailing list
> netty-users at lists.jboss.org
> https://lists.jboss.org/mailman/listinfo/netty-users
 		 	   		  
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.jboss.org/pipermail/netty-users/attachments/20111018/a6141232/attachment-0001.html 


More information about the netty-users mailing list