Win a copy of Think Java: How to Think Like a Computer Scientist this week in the Java in General forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Asynchronous communication among clients?

 
L Chan
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
I'm relatively new to J2EE...so bear with me if I'm using incorrect terminology...
Anyway, I'd like to know if there's a way (in effect) to communicate among client applications within the J2EE framework. For example, let's say we have three Swing client applications. Each Swing client is associated with a stateful session bean. In turn, all three of these stateful session beans is associated with only one entity bean. A client could call business methods on the stateful session bean which in turn calls a setter method that updates/changes the state of an entity in a persistence store. Or to make the example even easier, forget about the stateful session bean and just envision an example of three Swing clients and one entity bean...
However, I want changes to this entity to be communicated back to the other two Swing clients (e.g. the Swing client updates some information in its window). How can I do this using only J2EE concepts and techniques without resorting to creating sockets, threads, listeners, etc.? Is this even possible in J2EE (I've been told this isn't possible)?
 
L Chan
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
BTW, I forgot to mention that I'd like a solution that doesn't involve some sort of constant refresh (let's say every second) of the Swing client (i.e. the client uses a getter method to get method information from the session/entity bean). This is probably not very scalable.
 
C. Nimo
Ranch Hand
Posts: 82
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi.
I suppose your best option is to use JMS for messaging your updates to the clients.
Nimo.
 
L Chan
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by C. Nimo:
Hi.
I suppose your best option is to use JMS for messaging your updates to the clients.
Nimo.

But I thought that only client beans can subscribe to these updates (as a topic)? However, a Swing client itself cannot subscribe to them. I thought about using this previously - let's assume the session beans can subscribe to the messages - how will it be able to relay this change back to the Swing client without using constant refreshes and stay within the J2EE framework (no writing of threads, sockets, etc.)?
 
Roland Barcia
author
Ranch Hand
Posts: 181
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
In stand alone clients, you can use a regualr JMS Listener to recieve asynchronous request. An EJB can write to w JMS queue and send it to a stand alone Java App as long as they share the same queueing system.
 
L Chan
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Roland Barcia:
In stand alone clients, you can use a regualr JMS Listener to recieve asynchronous request. An EJB can write to w JMS queue and send it to a stand alone Java App as long as they share the same queueing system.

Thanks for all the help, guys! Yes, a regular JMS listener will work - didn't think about that - but then again, that's why I'm a novice. Thanks!
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic