Jetty And Netty integration - java

I want to build a nio based java web server. Jetty is light weighted java server and Netty is an asynchronous event-driven network application nio framework. can any one help me to integrate this two?

You could build up your own webserver by using only netty.
See the examples for this:
http://docs.jboss.org/netty/3.2/xref/org/jboss/netty/example/http/

Finagle, you can easily, and within minutes, spin up a Netty based web server using Finagle. Finagle is an open source project by Twitter.

Related

Connecting external Java program with Apache via module

Last time I think how can I connect my Java external program to Apache webserver.
I wanna send HTTP requests to process and then send output back as HTML file.
I thought about JNI but with multi-thread structure, it doesn't look good for me.
I think with help of Sockets it could be nice but I want to hear Your ideas.
Last but very important: should I use "normal" Apache or Tomcat for that?
For the level of integration you are looking for, JNI is way too low-level and involved.
Instead, take a look at:
FastCGI: on the Apache side use mod_fastcgi and jfastCGI on the Java side.
small HTTP servers: mod_proxy on the Apache side, which reverse proxies to a small HTTP server on the Java side such as Netty or Undertow.

Using WebSockets with Codename One

I am new at using Codename One. I am trying to deploy a server that will interact with my app on Amazon Web Services using OpsWorks. The server is going to run on Apache Tomcat and be a dynamic web project written in Java, and I am wondering the best way to communicate with the Codename One client. I am planning to use the Socket classes provided by Codename One, but and not sure what to use for the server-side code. Will it work to use WebSockets from Apache? I am having difficulty debugging the server code and have hit a wall here. Thanks in advance!
WebSockets aren't compatible with sockets so you will need to code a websocket implementation which is a bit of work. I suggest you use HTTP communication which is more portable and very performant on the devices.
You can also use solutions such as PubNub which allow for fast message based communications.

One to One chat application in java

Hi Im planning to create a one to one chat application in Spring2/hibernate without using XMPP/Jabber and need to run in websphere server.
Can someone point me some technology to use to create comunication channel between two users
Is CometD a good option?will it run on websphere?
CometD is a good option and it should run on websphere however it works best on Jetty as there are optimizations in place for it. CometD 3 will have support for jsr-356 javax.websocket so I would recommend using a websphere version that supports that since you are starting out with it...or just use Jetty. :)

communication between jruby app and java app that are on different servers

Anyone has expirience on having Jruby project running on Jboss (using torquebox or whatever) with an ability to communicate with another "japps" not on the same jboss where jruby app is, i.e. some java project on another jboss?
I know there is an torque-messanging but dunno if it's possible to communicate with external(out of jruby-app's jboss) app?
Best practices are welcomed.
Thanks in advance.
P.S. placing that other app on the jboss where jruby app is not acceptible solution.
I can recommend you to use Thrift and build communication via them.
Thrift have generator for both your needed languages (Java and JRuby) and provide good and fast communication.
UPDATED:
Thrift is RPC (remote procedure call) framework developed at Facebook. In detail you can read about it in Wiki.
In few word to save you time, what it is and how to use it:
You describe you data structures and service interface in .thrift file(files). And generate from this file all needed source files(with all need serialization) for one or few languages(what you need). Than you can simple create server and client in few lines
Using it inside client will be looks like you just use simple class.
With Thrift you can use what protocol and transport used.
In most cases uses Binary or Compact protocol via Blocked or Not-blocked transport. So network communication will be light and fast + with fast serialization.
SOAP(based on XML on HTTP) packages, its in few times bigger, and inappropriate for sending binary data, but not only this. Also XML-serialization is very slow. So with SOAP you receive big overhead. Also with soap you need to write (or use third-party) lib for calling server(tiny network layer), thrift already made it for you.
SMTP and basically JMS is inappropriate for realtime and question-answer communication.
I mean if you need just to put some message in queue and someone sometime give this message and process it — you can (and should) use JMS or any other MQ services(Thrift can do this to, but MQ architecture is better for this issue).
But if you need realtime query-answer calls, you should use RPC, as protocol it can be HTTP(REST, SOAP), binary(Thrift, ProtoBuf, JDBC, etc) or any other.
Thrift (and ProtoBuf) provide framework for generate client and server, so it incapsulate you from low level issues.
P.S:
I made some example in past https://github.com/imysak/using-thrift (communication via Thrift Java server + Java Client or node.js client), maybe it will be useful for someone . But you can found more simple and better examples.
Torquebox supports JMS. The gem you specified torquebox-messaging allows for publishing and processing of HornetQ messages on the local JBoss AS server/cluster that the JRuby app is running in. I don't think it currently supports connecting to remote servers.
Using this functionality in your JRuby app you could then configure your Java app on another server to communicate with HornetQ running in the JBoss AS that the JRuby app is running on.
Alternatively you could always implement your own communication protocol or use another Java library - you have access to anything Java you want to run from JRuby.
You can use Web Services or JMS for that

Non-blocking Web Server for java

I was reading about "Tornado Web Server".
It says that it is non-blocking web server.
Is there any non-blocking server for java web app ?
You're thus looking for a Java servletcontainer/applicationserver which supports NIO (Non Blocking IO).
Pretty much all of them supports NIO: Apache Tomcat, JBoss AS, Oracle Glassfish, etcetera. On some of them (e.g. Apache Tomcat), you've to make some configuration changes first (see also its HTTP connector documentation with regard to NIO). Glassfish uses under the covers Grizzly as NIO implementation of the HTTP connector.
As to which one to choose, that depends on what parts provided by the huge Java EE 6 API you'd like to utilize. If it's just JSP/Servlet, then Tomcat suffices. If you need a bit more than just JSP/Servlet, the Glassfish Web Profile may suffice. If you'd like to utilize the entire Java EE 6 API, then go ahead with JBoss AS or Glassfish Full Platform.
Also there is a non-blocking library in java called Netty and you can use Netty to write asyn network servers like web servers.
Non-blocking sockets have been available in Java in the java.nio pacakges since Java 1.4.
The Grizzly server is a servlet container based exclusively on NIO. Most established Java webservers are older than the NIO feature and have added support for it at some point.
Besides servers that BalusC listed, there is also Grizzly.
Here is a nice description of it's non-blocking operation.

Categories

Resources