Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p><strong>Option 1</strong> is the easiest one, you can use there asynchronous EJB methods:</p> <p>SERVER</p> <pre><code>@Asynchronous public Future&lt;String&gt; getUpdatedModel() { //here create blocking process until something interesting happen return new AsyncResult&lt;String&gt;("model has changed!"); } </code></pre> <p>CLIENT</p> <pre><code> Future&lt;String&gt; updatedModel = bean.getUpdatedModel(); while(true){ String response = updatedModel.get(); //process response here } </code></pre> <p><strong>Option 2</strong> looks like option 1, but you have to take care of marshaling objects, so don't bother in using plain servlet.</p> <p><strong>Option 3</strong> looks interesting, as websockets are going to be included in Java EE7 (now you can use opensource comet implementations for servlets). In my opinion it is not designed for communication in enterprise applications, but might be fine for your usecase. There is a plenty of JSON serializers available (e.g. gson), I use that kind of communication between JS and java, and works fine.</p> <p><strong>Option 4</strong> breaks major Java EE principles (opening your own sockets is forbidden), and I would discourage you to use it.</p> <p><strong>Option 5</strong> Listen to Xie and use JMS! If you will use JMS topic, you could just send the message when particular event occur, and all connected client will receive the message asynchronously. It is natural Java EE way of solving this kind of problems, with out of box transactions, message redelivery and persistence if nessesary.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload