Jeanfrancois and Shing Wai,
As per Alexey's morning call, I am attaching my source code related to
this issue. Note that my CometdServlet.java does not extends
com.sun.grizzly.cometd.servlet.CometdServlet right now, as I brought code
in from that class to try patching. Please help as soon as you can.
Thanks,
Anthony
Jeanfrancois,
We have been testing with this new drop and example code all day. This
seems to work better, but there is still a problem. I'm not sure what is
causing this behavior, but it is consistent each time we test.
Here's what happens:
1. client 1 logs on
2. servlet sends message to client 1 sucessfully
3. client 2 logs on
4. servlet attempts to send message to client 1, but fails
5. servlet sends message to client 1 sucessfully
In other words, each time a new client subscribes, each
previously-subscribed client must be sent one message from the servlet
(which does not get sent) before that client can sucessfully receive any
new messages.
Here's another way to describe it: when a new client logs on, in order for
any of the other clients to receive a new message, it must be sent from
the server to the client twice.
I hope this makes sense. If you know of a work around, please let us
know.
Thanks,
Anthony
-------
Salut,
first, I apologize for the recent regressions observed with cometd, in
both GlassFish v2 (grizzly 1.0.22) and v3 (1.9.x). We wioll improve our
testing and avoid such major regressions.
we recently updated the way cometd/bayeux has been implemented on top of
Grizzly Comet. During that re-factoring we have made some major
performance improvement and modified a little how the JavaAPI can be
used. A simple demo can be downloaded here:
http://download.java.net/maven/2/com/sun/grizzly/samples/grizzly-cometd-bayeux/1.9.5-SNAPSHOT/
Mainly, you can test it using the grizzly-cometd-webserver.jar
downloaded from here (hudson seems broken, so make sure you download the
20090126 war file).
http://download.java.net/maven/2/com/sun/grizzly/grizzly-cometd-webserver/1.9.5-SNAPSHOT/
You can run the demo by doing:
java -jar grizzly-cometd-webserver.jar -p 8080 -a
grizzly-cometd-bayeux.war com.sun.grizzly.bayeux.BayeuxExternalServlet.
In that demo, request which takes the form of:
http://host:port/BayeuxExternalServlet/?message=hello,user=moi
will update the cometd-chat demo bu using the JavaAPI. The demo is
simple and can be read from here:
https://grizzly.dev.java.net/nonav/xref/com/sun/grizzly/bayeux/BayeuxExternalServlet.html
The code looks like:
> 133 @Override
> 134 public void doPost(HttpServletRequest request,
> HttpServletResponse response) throws ServletException, IOException {
> 135 String message = request.getParameter("message");
> 136 String user = request.getParameter("user");
> 137 ServletOutputStream out = response.getOutputStream();
> 138
> 139 CometEngine engine = CometEngine.getEngine();
> 140 CometContext context = engine.getCometContext(channel);
> 141
> 142 if (context != null && message != null) {
> 143 Map<String, Object> map = new HashMap<String, Object>();
> 144 map.put("chat", message);
> 145 map.put("user", user);
> 146 Data data = new Data();
> 147 data.setMapData(map);
> 148 data.setChannel("/chat/demo");
> 149
> 150 DeliverResponse deliverResponse = new DeliverResponse();
> 151 deliverResponse.setChannel("/chat/demo");
> 152 deliverResponse.setClientId("");
> 153 deliverResponse.setData(data);
> 154 deliverResponse.setLast(true);
> 155 deliverResponse.setFollow(true);
> 156 deliverResponse.setFinished(true);
> 157
> 158 context.notify(deliverResponse);
> 159
> 160 out.println("Data is sent.");
> 161 System.out.println("Data is sent.");
> 162 } else {
> 163 out.println("No data is sent.");
> 164 System.out.println("No data is sent.");
> 165 }
The main changes from previous version are:
+ No needs for invoking DeliveryResponse.setFinished(...); This was
added after Shing Wai blog and it seemed to break backward
compatibility. Hence we have listened and removed this new API.
+ Now you can lookup CometContext using the channel instead of the
context-path of the Servlet. This was required to allow more than one
channel update from a single Servlet.
All of those changes has been backported to Grizzly 1.0.23. Please gives
us feedback so we can fix regression as soon as possible.
Thanks
-- Jeanfancois
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe_at_grizzly.dev.java.net
For additional commands, e-mail: users-help_at_grizzly.dev.java.net
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe_at_grizzly.dev.java.net
For additional commands, e-mail: users-help_at_grizzly.dev.java.net
- application/x-zip-compressed attachment: Screen.zip