Twisted in Java - java

What is the closest Java alternative to Twisted?

Nio is really low level and supports Socket only and SSL if you dig hard enough on Google for samples.
Apache Mina wraps the complexity and adds a few protocols but not as much as Twister.

Like Stephane, I would suggest you take a look at Mina. Its a framework for asynchronous network IO. It is built on top of NIO, which was mentioned earlier, and IMO hides away some of the complexity involved with Selectors,Channels,etc.. I've used Mina for a couple of projects and its pretty good, but be warned, I've found the documentation to be a little weak. And again, like Stephane mentioned, it doesn't have out of the box support for too many protocols.

I've implemented most of a Twisted reactor in my collection of AMP hacks on launchpad - but it needs a maintainer.

I don't think there is anything quite like Twisted, as far as Deferreds and complex callback chains go. For non-blocking IO, I think NIO is the most commonly-used solution. In particular, look at this section on Selectors.

If there is still an interest in this, I've just put up the first beta release of the 'Reaction' framework, which supports the Twisted-style deferred callback model in Java. As well as working as a standard Java package, it can also be used as an OSGi service. License is Apache version 2.
More details on my website, >here<.

See this framework from Spring.io: http://spring.io/blog/2013/05/13/reactor-a-foundation-for-asynchronous-applications-on-the-jvm

Related

Status of Apache-Commons Commons-Functor

When I look at the commons-functor website website, it appears to be out of sandbox state, but it also says there is no official binary release? But I thought I saw it in some Maven repository somewhere and can't find it now. Does anyone know what the status is and whether there is an official binary release? I suspect I am just poor at navigating the Commons website.
Looks like the last development was three weeks ago (see this) and their "release notes" for 1.0 are just a skeleton (see here).
A couple quick searches show that Apache Commons Lang used to have a package org.apache.commons.lang.functor - but this was removed some time ago, it seems (like 2003 or so)
As a side note, it appears that Apache Commons Collections has a package org.apache.commons.collections.functors - but this might not be what you're looking for.
I have absolutely no idea what the release or maintenance state of this library is. My apologies.
But what i do know is that the world needs another functional programming library for Java like it needs a hole in the, er, head. Ozone layer? There are already quite a number in circulation - Functional Java, the functional parts of Guava, LambdaJ, and others - all doing much the same thing (or at least having overlapping bits doing much the same thing). What we need to do now is to start coalescing our attention around two or three of these libraries, developing common styles and idioms for using them.</rant>
At the company where i work, where there are a lot of big fans of functional programming, we seem to have settled on Functional Java, having had LambdaJ, Guava, and a couple of homebrewed functional frameworks in our codebase (and having rewritten bits of it in Scala!). That decision was made by people with deeper understanding of functional style than me, and before i joined the company, so i can't explain the reasoning, merely report that it was made. Functional Java is actively developed, and it's in Maven. I would urge you to have a look at it, and see if it meets your needs.
Commons Functor is heading toward it's first official release. You can give it a try by using the nightly snapshot from the Apache repository:
https://repository.apache.org/content/groups/snapshots/org/apache/commons/commons-functor/1.0-SNAPSHOT/

HTTP Client with NIO2

Have someone familiar with HTTP Client that based on JDK7 and NIO2,
Implementation that use: AsynchronousSocketChannel
I am looking for implementation that based on NIO2 and can scale out unlimited, thousands of HTTP requests concurrently.
NOTES:
please do not suggest me an implementation that based on NIO1 like Apache::AsyncHTTPClient and JBOSS::Netty framework
Please do not suggest me a solution that based on distribute solution, I am looking for one client that can handle all the HTTP requests efficiently.
THANKS!
I would recommend checking out AsyncHttpClient. It was written by the guy that wrote Grizzy for Sun and now works for Sonatype.
I believe you are mistaken in your assumption that you must use NIO2 to scale up. Please listen!
NIO2 is the non-blocking version of Java's IO. This means it's easier to write high performance io in NIO2 because you need not start and manage threads, because most of your threads are just going to be waiting on IO. Multi-threaded programming is tricky, so anything to make it easier is a feature, hence NIO2.
However, as a library user how hard the library was to write isn't your concern. Modern JVMs can handle a lot of threads and the old io API should be powerful when used by skilled programmers. Since you are a user of the library, I suggest that you just find the fastest library.
HTTPClient from Apache is a very popular library. I suggest you get in contact with the experts on that and ask them your performance questions. I'm not an expert in this area, so I'm not telling you HTTPClient is the best, I'm just saying not to count it out yet and that talking to the HTTPClient people would be a good place to start.
Good Luck

Kryonet reliability

Is there anyone who has used the Java Kryonet library in a project willing to share their experience? I've seen it recommended a few times, but haven't actually seen anybody talk about their experiences using it.
Specifically, I want to make sure that it is reliable and relatively stable. Or should I consider using something like Google protocol buffers with custom networking code?
Thanks!
I have discussed the kryonet and kryo in my master's thesis and compared it some of the contemporaries; that should give some information and analysis about Kryo: http://de.scribd.com/doc/67084961/MasterArbeit
Answering the other half of your question that isn't addressed by the older one, Protocol Buffers have the advantage of being much more widely deployed, so you're less likely to run into major bugs. There are serious downsides, though, not least the facts that (1) you have to define your format using an IDL and then use PB's generated classes (meaning you may have to copy data in and out of your own back-end objects, which might result in lower performance) and (2) PB doesn't support polymorphism except through a variety of difficult-to-manage hacks.
So, if you're just looking for a straightforward way of transferring structured (but not object-oriented) data from one endpoint to another, Protocol Buffers is probably your best bet. More complex scenarios probably favour Kryonet.
HTH
I developed a game with kryonet and it works like a charm. It is also very easy to use.
I am currently working with Kryonet and making a game. I have myself found it as a very helpful and easy to use library. It has a very simple API which makes life very easy. I won't say it is as powerful as something like Netty or Apache Mina but it does all the required tasks. I personally love it and I will use it everywhere I can unless I require something more powerful or sending huge data as other libraries provide much more than KryoNet when it comes to sending data.

twisted matrix framework for java

is there a twisted matrix framework for java??
I think Netty could be one.
While the very original version of twisted was written in Java, and there are a few implementations of Deferreds and a simple reactor written in Java, they aren't in a published library state.
Searching for an alternative you might do well to google with various keywords such as "asynchronous networking library" and such.

java.nio.channels.*

What is up with nio channels ? There were some nice talks when it was added to java but I still don't see people using it in their applications.
Is there something wrong with it, or am I just not encountering people who use it?
Any nice examples as to why I should bother using it at all ?
Thanks
You're asking about channels, but channels only make sense within the general framework of using the (relatively) new nio capabilities as a whole.
My guess is that of the many, many Java applications out in the world, not many need the capabilities of nio. The usual "business" process read streams and/or files... nothing special.
That said, the Apache folks have recently rewritten their core Java libraries ( http://hc.apache.org/ ) to use nio, and claim some impressive performance benefits in some cases.
nio also lets you do stuff like memory-mapping files, and this can allow an application to do very fast random access to the file. Again, only some special applications need this, and that's probably why you don't see a lot of it used.
Apache Mina is a great networking library and uses NIO.
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.
Net4J, a signaling platform/framework, makes heavy use of NIO channels. (One part of Net4J basically provides a convenience API to NIO channels.)

Categories

Resources