|
|
TransportsOverviewJRemoting has a number of 'transports' to connect clients to servers. Some of the work over the internet, some are for more local situations. Socket TransportThis will work over the internet or an
intranet, between two different machines. It will also work
between two different processes on the same machine. Server side usage
server = new SocketServer(new ConsoleServerMonitor(),
new InetSocketAddress(portNum));
Client side usage
serviceResolver = new ServiceResolver(new SocketTransport(new ConsoleClientMonitor(),
new SocketDetails("somehost.com", portNum)));
Secure Socket TransportAs above, but using SSL.
You need to set the keyStore and/or trustStore for the VM
in question.
Pass these to java as env vars:
-Djavax.net.ssl.keyStore=/path/to/keyStore
-Djavax.net.ssl.keyStore=/path/to/trustStore
-Djavax.net.ssl.keyStorePassword=yourPassword
server = new SSLSocketServer(new ConsoleServerMonitor(), new InetSocketAddress(portNum));
Client side usage
serviceResolver = new ServiceResolver(new SSLSocketTransport(new ConsoleClientMonitor(),
new SocketDetails("somehost.com", portNum)));
Piped TransportUsing Java's built-in pipes, this
transport will join two parts of the same application with RPC.
Interestingly you could have a large hierarchy of
clasloaders with the objects to be serialized duplicated in the
tree (once for client side, once for server side) and it would
work. Perhaps even if they were different versions of the same
jar. Pipes offers some natural threading to the two sides
of the application. PipedServer server = new PipedServer(new ConsoleServerMonitor(), new InetSocketAddress(portNum)); PipedInputStream in = new PipedInputStream(); PipedOutputStream out = new PipedOutputStream(); server.makeNewConnection(in, out); serviceResolver = new ServiceResolver(new PipedTransport(new ConsoleClientMonitor(), in, out)); Direct TransportDirectly wiring a JRemoting server to a
client mostly serves as a quality/development consideration for
us. The transport is very fast as no serialization is
taking place. If you can find a use for it, you will note
that you can't have a complex classloader design for this. server = new DirectServer((ServerMonitor) mockServerMonitor.proxy()); Direct Transport - marshaledAs above, but with a
deliberate serialize/deserialize step. Again of marginal
use for the end user compared to sockets/pipes. This one could
leverage a hierarchy of classloaders. Specifically, the things
that would be serialized and/or the facade in question could be
duplicated within the app, as long as they are are not in the
same branch of a classloader tree. server = new DirectMarshalledServer((ServerMonitor) mockServerMonitor.proxy()); serviceResolver = new ServiceResolver(new DirectMarshalledTransport(new ConsoleClientMonitor(), server)); Over RMIThis is just like the Socket based transports, except that it leverages classic RMI for the transport.
server = new RmiServer(new ConsoleServerMonitor(),
new InetSocketAddress(portNum));
Client side usage
serviceResolver = new ServiceResolver(new RmiTransport(new ConsoleClientMonitor(),
new SocketDetails("somehost.com", portNum)));
Using Apache Mina for NIO on the server sideThis is just like the Socket based transports, except that it on the server
side Apache Mina is used to leverage NIO.
This does not have as fast throughput as plain sockets, it is just able to scale to more concurrent connections
server = new MinaServer(new ConsoleServerMonitor(),
new InetSocketAddress(portNum));
Client side usage
serviceResolver = new ServiceResolver(new SocketTransport(new ConsoleClientMonitor(),
new SocketDetails("somehost.com", portNum)));
ServletsTodo Comparative speedsOn a single MacBook Pro (2.16Ghz
Core2Duo) with server and client on the same machine. ByteStream or ObjectStream Piped types - 4,500 reqs/sec Dynamic
proxy - 7 million reqs/sec |