Martin Andersson
Martin Andersson

Reputation: 19563

How to make an application client get events and notifications from an EJB, pushed by the server?

It is so simple with Java EE and CDI to inject a EJB in an application client and let the application client talk to the EJB. Really simple. And also, this stream of communication is what the whole sum of books and Internet talks about. No one seem to be concerned or ever have the need to make the conversation flow the other way around. Well I want my EJB to be able to push events and notifications to my application clients that originated from the server (application clients are launched with Java Web Start).

Surely I can have the application clients poll data from the server like constantly, however, I don't see that as a good design. My web clients are using ajax long pulling (comet), should they really be of a smaller burden to the server than what my application clients are?

The way I see it, JMS is my only option. And that just seems to be overkill for the simple kind of communication I will have going between two, what I know is, JAVA end points =) I tried RMI and to push a remote stub from application client to EJB but then I got exceptions telling me my object in question are already some kind of remote stub. Hmm.

You got an idea?

EDIT

A similar discussion occurs here. They too figure there is no other way than to use JMS. I find it slightly "confusing" that none of all my Java EE books or the official Oracle tutorials address this issue. Not even in a small side note. Am I that alone in this universe trying to do what I'm trying to do?

Upvotes: 1

Views: 945

Answers (2)

ar4ers
ar4ers

Reputation: 740

Same problem here.

I myself came up with the same solution - to send JMS from server and listen to it from client's MDB, and then pull it from client's cache, to reduce server loading.

And i can't use WebSocket.


Also, you can try to use GifSocket. It's pretty simple and compatible with IE6! c: https://github.com/videlalvaro/gifsockets

Upvotes: 0

Martin Andersson
Martin Andersson

Reputation: 19563

If you don't want to open your own socket, nor do you want the client to launch web services the server can consume, then there's another alternative to JMS. Namely Java EE 7 WebSocket. They are full-duplex.

Upvotes: 0

Related Questions