Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 9 years ago.
Improve this question
I want to create simple server having low load. The goal is to give a few javascript clients access to some functionality implemented in Java through WebSockets. I seek for best library to use for that - it should be simple, robust etc. Now I consider 3 alternatives
- jWebSocket
- jetty
- netty
What is the best? Or may be something else?
Thanks in advance
I'd go with proven Java servlet servers: Jetty or Resin. The have both been extended to handle WebSockets:
Jetty WebSockets
Resin WebSockets
My personal choice would be Jetty, as it's very simple to use and I've been using it as embedded server in several projects.
There are also some new kids on the block like Atmosphere and jWebSocket, but for servers I prefer to go with a proven solution. Jetty and Resin are also generic Servlet servers, so you can go with one product for all your serving needs.
jWebSocket now includes the Jetty 8.0 engine including SSL and includes many nice-to-haves on top of it. It provides cross-browser and cross-platform compatible clients even more mobile apps e.g. under Android, Symbian and BlackBerry. The server can easily be extended with plug-in and already includes lots of them (e.g. for Authentication/Autorization, JDBC, SMTP, XMPP/Jabber, RPC, Twitter, Filesharing, Chat etc.). Just check it out... http://jwebsocket.org. Looking forward to your feedback.
Regards
Alex
The PlayFramework! is the other very good option.
FYI, Atmosphere run on top of Resin, GlassFish and Jetty. Atmosphere free you from being stuck with one server by giving you Websocket portability amongst Websocket server. It also offer a client library that can be select the best transport in case websocket isn't supported by the browser. So you can't compare Atmosphere with Jetty or Rsin
Take a look at Atmosphere. Here is an article about websocket and atmosphere.
While I value the implementations of JWebsockets and Autobahn a lot, I prefer Atmosphere.
Ramp-Up::
Ramp-Up time is low. Francois Arcand puts a lot of effort into testing and examples, helping everyone to achived quick wins. (And I have no clue why he's able to respond so quickly to any architectural questions I rise. Impressive.)
Maintenance Perspective::
To me, maintainability is fundamental, if a software goes beyond major release version 1.0.0. The project is maintained at a top Maven-POM level with a properly constructed hierarchy. It prevents library incompatability. Libraries are reference at the correct level. That is well done.
Technical/Functional Perspective::
It offers a Java SE client library (wasync) that can either do native websocket communication (onMessage) or build on Jersey REST annotations (#Path). Subsequently this makes it as simple as it gets with the benefit of maintaining an open connection for subscriptions and the popular remote procedure calls (RPC) paradigm. It is a common attempt to merge those two paradigms. See also http://wamp.ws/, which heads for the same approach. Also, the library offers to establish QoS properties like robustness (e.g. in case a client disconnects) and reliability (caching undelivered messages). That is great for professional software to harness.
Maybe you should try Bristleback Server? Using Bristleback, you may choose from several WebSockets engines, like Jetty, Netty and Tomcat. You can have standalone server as well as web application that uses WebSockets (Jetty and Tomcat 7). Bristleback uses Spring Framework. If you have worked with web frameworks like Struts, Stripes or Play!, it will be very easy for you to start. Of course, Bristleback has its own JavaScript client library for even easier development.
Full disclosure: I am one of the co-creators of Bristleback Server.
I would also add vert.x to the list. It can server Websockets and SockJS (websocket emulation when the browser doesn't support them).
Update:
Undertow http://undertow.io also supports websockets.
Follow my blog. I'll be ready for release sometime in the not too far off future. Light-weight has been emphasized through the whole thing - but it's also fast. I don't know yet how well it will ramp up to higher loads. But I've been running the demo for a while now with relatively low load and what I have has been working well. (I'll test heavier loads later and make sure that it can be ramped up.)
http://highlevellogic.blogspot.com/2011/09/websocket-server-demonstration_26.html
If you are looking for infrastructure around message management, user grouping ("rooms"), and data synchronization ("shared variables"), you might want to consider Union Platform:
http://www.unionplatform.com
[Full disclosure: I am one of the co-creators of Union]
Why don't you just write your application on an open standard like JMS, and let the clients sit on the JMS bus as message clients?
The whole point of websockets is to bring any native TCP protocol directly to the client instead of converting it from your back end to http request/response.
Your back end services would talk to a JMS broker like ActiveMQ, and your clients speak AMQP in the browser via a Javascript API that looks just like the JMS API in Java. All you need for that is a websocket gateway, for example Kaazing has such a gateway, all it does is route your JMS TCP traffic out to the web clients over websockets. They also provide fan-out so that you don't overload your JMS bus, i.e. you just use a handful of connections to the broker to offload a million browser client connections.
The bottom line is that you don't need to tie yourself to any specific platform. Stick with standards, that way you have 100% freedom to swap out components as your environment changes.
Related
I need to implement a chat server API in Java in a way that it can scale horizontally. I'm currently using tomcat + jersey + postgresql server side to implement a REST-like layer, and it would be good for the proposed solution to work with these technologies, but if I you believe the best solution lies with other java techs it can be discussed.
I've been looking at websockets, and some of the chat samples out there, starting with the tomcat websockets chat, but they are stateful and not well suited as they are to scale.
The way I see it, with a websockets approach I could take state out of each node, by storing it in the database, but then I'd need some sort of pub/sub mechanism for all nodes to push new messages to the clients they are bound to that participate in a chat room.
Since I don't want to reinvent the wheel, I was hoping to be able to put in place a solution by composing existing and tried technologies. Thanks in advance.
Take a look at Cettia - Java server's quick start guide and clustering section, which is designed to meet such usages.
A cettia application is designed to run on Grizzly, Netty, Play, Servlet, Vert.x, and so on and to share nothing between servers for easy scaling (pub-sub system is enough).
Here's some examples for you:
Servlet 3 and Java WebSocket API 1 for Tomcat
JAX-RS 2 Atmosphere2 for Jersey
Hazelcast 3 for scaling
jGroups 3 for scaling
I'm the author that project. If you mind it's in alpha stage, you may want to try Atmosphere out, which is similar to Cettia but provides GA.
If you don't want to reinvent the wheel, I'd suggest a Jabber/XMPP server like ejabberd or Openfire (if you really want a Java solution). Its not RESTful but its an industry standard chat server and is horizontally scalable.
please check out solutions at:
http://www.programmingforliving.com/2013/08/websocket-tomcat-8-ServerEndpointConfig-Configurator.html
or here:
http://svn.apache.org/viewvc/tomcat/tc7.0.x/trunk/webapps/examples/WEB-INF/classes/websocket/chat/ChatAnnotation.java?view=markup
I have made a Java Swing application. Now I would like to make it a Client-Server application. All clients should be notified when data on the server is changed, so I'm not looking for a Web Service. The Client-Server application will be run on a single LAN, it's a business application. The Server will contain a database, JavaDB.
What technology and library is easiest to start with? Should I implement it from scratch using Sockets, or should I use Java RMI, or maybe JMS? Or are there other alternatives that are easier to start with?
And is there any server library that I should use? Is Jetty an alternative?
Given that you have the application already, perhaps the simplest thing to do is to identify the interface that you require between the client and server, and first of all to refactor your application to use that interface to talk between the back-end/front-end within the same process.
Then you can start to split this apart. A simple solution would be to split this apart using RMI (since you're talking Java objects and have Java method calls). Spring contains useful tools to simplify/automate the RMI exposure of interfaces.
For the notification requirement, a simple UDP multicast (or broadcast) would suffice.
Note that as soon as you split your application up, you have issues re. maintaining consistent views of data, managing timely updates, handling cases when the server is down, possible loading issues when you get lots of clients etc. In a sense, splitting the application up into a client and server is just the start of a new architecture process.
Mina is a good choice as a network application framework for building a simple server for this purpose - it's a much better option than using raw sockets.
http://mina.apache.org/
If you really need an application server then you could take look at JBoss. It also provides a remoting component (as an alternative to something like Mina):
http://www.jboss.org/jbossremoting
You probably won't have much need for Enterprise Java Beans though. In most cases a simple POJO based framework is more than sufficient - you could tie this altogether with a dependency injection framework such as Guice:
http://code.google.com/p/google-guice/
or Spring. Keep it simple, don't use a J2EE server unless you really need to. Hope that helps.
This is much of what J2EE does, but it's a whole new learning curve because they have pre-solved many of the problems you will run into and many you may not and therefore add on a lot of new technologies.
But at it's most basic, J2EE answers just that question.
I worked in a project like this. We implemented Client-Side Swing and Server side with J2EE. We used EJB,Stateless beans and Message Driven Beans.Also I have been in a device tracking, management project. Our clients were trucks+Swing users and We have used Servets+TCP/UDP,Apache Mina framework to handle and keep connections.
I have been working in Java Swing Client/Server applications for almost 3 years. I would suggest you to go for RMI/EJBs. The initial application that we developed was doing this using RMI/EJB for client-server communication with WebLogic being the server.
But we later found out that there are lot of "browser-like" features to be included to the application such as session-timeout etc., So, we used the BrightSide Framework which wraps the RMI calls through HTTP. One more enhancment we made is that we replaced Weblogic with the open source JBoss server.
The wrapping of calls with HTTP will become very handy and you can make your swing applications really rich. Later, when the situation demands for you to use a website strictly, you can deploy your swing using jnlp.
Hope this helped.
Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 8 years ago.
Improve this question
I am doing some research related to Java NIO. I need to find some representative
applications that are based on this framework. Please feel free to suggest! The more, the merrier!
Thanks
The Apache MINA Networking framework is built on NIO (and is used by many applications to provide high-performance networking).
Apache MINA is a network application
framework which helps users develop
high performance and high scalability
network applications easily. It
provides an abstract · event-driven ·
asynchronous API over various
transports such as TCP/IP and UDP/IP
via Java NIO.
Apache MINA is often called:
NIO framework · library,
client · server framework · library, or
a networking · socket library.
However, it's much more than that.
Please take a look around the list of
the features that enable rapid network
application development, and what
people says about MINA. Please grab
yourself a download, try our Quick
Start Guide, surf our FAQ or start
join us on our community
I believe JETTY uses continuations to support 5000+ HTTP Comet connections using Servlet 3.0 continuations.
Also you can look at a BlazeDS NIO implementation (basically an opensource LCDS).
http://blogs.webtide.com/athena/entry/asynchronous_blazeds_polling_with_jetty
Netty:
Netty is a NIO client server framework
which enables quick and easy
development of network applications
such as protocol servers and clients.
It greatly simplifies and streamlines
network programming such as TCP and
UDP socket server.
Grizzly, a HTTP connector, makes use of NIO. It's been used in Sun Glassfish Java EE application server and is available in Apache Tomcat Java servletcontainer as well. It not only enables Comet (sort of HTTP push idea), but it also scales damn good, it can go up to ~20.000 concurrent HTTP connections on a single thread instead of ~5.000 concurrent HTTP connections on that much threads.
Rabbit web proxy is using NIO.
But before jumping on the NIO bandwagon, I'd recommend you to read this.
I believe Adobe LCDS runs off Java NIO.
I started an open source project on SourceForge called JInSim that uses nio. I'm no longer an active developer on it, but I'm sure that part is still the same. It's a smaller scale library that allows people to write clients for the auto racing simulator Live For Speed.
JInSim link
Jetty, the popular web application server, can use NIO. Check out the different socket connectors. Jetty can also use continuations for handling asynchronous web requests.
Project Voldemort, a distributed key/value store, can also be configured to use NIO for socket connections and uses parts of the library for reading from it's read-only data store.
Is there a demand out there for a small, lightweight, Java 7 based open source project that is geared toward making Cloud services more elegant? I have written several servers in my lifetime, and was curious if there was a need for this.
My thoughts were to keep it simple, lightweight, and use the Java 7 NIO 2 functionality for network communications. I was also thinking of using either a broadcast address for local cloud based communications between servers in a rack solution (MBONE) or a serialization-based communications protocol.
I don't want to use Spring or Tomcat, as they are overweight, and they are written on older Java technology. Furthermore, I don't want to use another Apache project because it's too dependent on Apache technologies. Keywords here are "small", "lightweight", "portable", and "efficient".
Maybe this will even have the potential of being installed and used in mobile devices as background servers, or even mobile cloud networks.
From my own point of view, no.
If I want a lightweight servlet server, I use Jetty.
If I want a more powerful, versatile Web app server, I use Tomcat.
If I want a full J2EE server, I use Glassfish.
All of these are of course highly proven. Memory is cheap enough these days that I'm not very worried about a little bloat. That comes standard with Java apps :)
Also, I'd consider it crazy to deploy server technology on mobile devices. Maybe other people have bright new ideas, I think mobile devices should communicate with central servers.
I would probably not want to use a Java 7 server not based on J2EE, at least the servlet part, unless someone comes up with a really compelling alternative. On the other hand, I wonder how small you could make a compliant server.
Finally, as far as I know, Tomcat already (optionally) supports nio: http://tomcat.apache.org/tomcat-6.0-doc/aio.html .
Strictly a personal opinion from an old curmudgeon.
I'm writing/porting a C++ HTTP event server to Java. I'm wondering what are the best paradigms for implementing comet with Jetty, Tomcat, any other server, or natively.
Threaded
Continuations
NIO
Servlet 3.0
Scalability is an absolute must as I'm developing a new protocol that uses up to 3 concurrent connections per client.
Any help is appreciated.
PS: If possible, I would love to also see some sample code or tutorials..
We've had a lot of success with Caucho Resin's LongPoll features (the majority of the data to our UI comes in over Comet). Caucho has also added support for WebSockets, so if you have an HTML 5 client you can benefit there too.
On Linux they have some custom JNI code that talks directly to epoll, which allows the server to scale well.
Glassfish has native comet support and I thought there was WAR for comet support in tomcat from the Glassfish team. Jetty also seems to be leading the crowd. Am I misunderstanding, but why are you trying to re-implement comet in a Java app Server?
Or you can drop Comet and go WebSockets: http://www.jWebSocket.org
I've been looking into Comet myself the past couple days. My company uses Tomcat in development and WebLogic in production. We'd like to incorporate Comet without shaking up our existing application. I've been impressed with Atmosphere's APIs. It focuses on the server side, allowing for portability while taking advantage of native server features like NIO. They seem to be putting out updates every month.
https://atmosphere.dev.java.net/