users@grizzly.java.net

Re: grizzly-cometd-bayeux not sending messages to all subscribed clients.

From: Oleksiy Stashok <Oleksiy.Stashok_at_Sun.COM>
Date: Tue, 18 Aug 2009 17:54:25 +0200

Hi,

can I ask you to add some output to CometHandler code, to see if all
CometHandlers got notified and the problem is only in sending data
over socket.

Thanks.

WBR,
Alexey.

On Aug 17, 2009, at 20:15 , victorng wrote:

>
> I can reproduce this behaviour with the following code:
>
> I'm using GF v2.1 with the stock grizzly.
>
> I *thought* I saw this working but I guess I was delusional on
> Friday. :)
>
> I'm sending messages via JMS to a queue - I can see the messages get
> through, the cometcontext is properly acquired and I can see the
> CometHandlers all there - but nothing comes through on the website.
>
>
> The demo app I'm using is grizzly-cometd-chat-1.9.9.war
> (http://download.java.net/maven/2/com/sun/grizzly/samples/grizzly-cometd-chat/1.9.9/
> )
> and the MDB I'm using is at the bottom of this message.
>
> If it's of use, here's my Jython JMS code:
>
> def send():
> context = get_context()
> qfactory = context.lookup("jms/MyConnectionFactory")
> qconnection = qfactory.createQueueConnection('senduser',
> 'sendpass')
> qsession = qconnection.createQueueSession(False,
> Session.AUTO_ACKNOWLEDGE)
> qsender = qsession.createSender(context.lookup("jms/MyQueue"))
> msg = qsession.createTextMessage()
> msg.setText('this is a test message')
> qsender.send(msg)
>
> Is there something I should be doing to flush the messages down to the
> CometHandlers?
>
> thanks,
> vic
>
>
> Server logs:
>
> [#|2009-08-17T14:03:07.688-0400|INFO|sun-appserver2.1|
> javax.enterprise.system.stream.out|_ThreadID=40;_ThreadName=p:
> thread-pool-1; w: 47;|
> Got message: this is a test message|#]
>
> [#|2009-08-17T14:03:07.688-0400|INFO|sun-appserver2.1|
> javax.enterprise.system.stream.out|_ThreadID=40;_ThreadName=p:
> thread-pool-1; w: 47;|
> Engine:
> com.sun.enterprise.web.connector.grizzly.comet.CometEngine_at_1ef2fd3|#]
>
> [#|2009-08-17T14:03:07.688-0400|INFO|sun-appserver2.1|
> javax.enterprise.system.stream.out|_ThreadID=40;_ThreadName=p:
> thread-pool-1; w: 47;|
> ContextPath: /cometd/cometd|#]
>
> [#|2009-08-17T14:03:07.688-0400|INFO|sun-appserver2.1|
> javax.enterprise.system.stream.out|_ThreadID=40;_ThreadName=p:
> thread-pool-1; w: 47;|
> Context: /cometd/cometd|#]
>
> [#|2009-08-17T14:03:07.688-0400|INFO|sun-appserver2.1|
> javax.enterprise.system.stream.out|_ThreadID=40;_ThreadName=p:
> thread-pool-1; w: 47;|
> Sent {chat=Wake up call from the chatroom :-) to /chat/demo,
> user=ChatPinger} back down to the comet context|#]
>
> [#|2009-08-17T14:03:07.688-0400|INFO|sun-appserver2.1|
> javax.enterprise.system.stream.out|_ThreadID=40;_ThreadName=p:
> thread-pool-1; w: 47;|
> Found handler: com.sun.grizzly.cometd.DataHandler_at_11ab4ec|#]
>
> [#|2009-08-17T14:03:07.688-0400|INFO|sun-appserver2.1|
> javax.enterprise.system.stream.out|_ThreadID=40;_ThreadName=p:
> thread-pool-1; w: 47;|
> Found handler: com.sun.grizzly.cometd.BayeuxCometHandler_at_eaa683|#]
>
> [#|2009-08-17T14:03:07.688-0400|INFO|sun-appserver2.1|
> javax.enterprise.system.stream.out|_ThreadID=40;_ThreadName=p:
> thread-pool-1; w: 47;|
> Completed try block|#]
>
> --- code snip ---
>
> package com.crankycoder;
> import javax.ejb.MessageDriven;
> import javax.jms.MessageListener;
> import javax.jms.Message;
> import javax.jms.TextMessage;
> import java.util.Map;
> import java.util.HashMap;
> import java.util.Iterator;
> import com.sun.enterprise.web.connector.grizzly.comet.CometContext;
> import com.sun.enterprise.web.connector.grizzly.comet.CometEngine;
> import com.sun.grizzly.cometd.CometdNotificationHandler;
> import com.sun.grizzly.cometd.CometdRequest;
> import com.sun.enterprise.web.connector.grizzly.comet.CometHandler;
> import com.sun.grizzly.cometd.CometdResponse;
> import com.sun.grizzly.cometd.bayeux.Data;
> import com.sun.grizzly.cometd.bayeux.DeliverResponse;
>
> @MessageDriven(mappedName="jms/MyQueue")
> public class HelloMDB implements MessageListener {
>
> public void onMessage(Message msg) {
> try {
> if (msg instanceof TextMessage) {
> TextMessage txtmsg = (TextMessage) msg;
> String cpath = "/cometd/cometd";
> String topic ="/chat/demo";
> CometHandler handler = null;
> System.out.println("Got message: "+txtmsg.getText());
> CometEngine engine = CometEngine.getEngine();
> System.out.println("Engine: " + engine);
> CometContext context = engine.getCometContext(cpath);
> System.out.println("ContextPath: " + cpath);
> System.out.println("Context: " + context);
>
> Map<String, Object> map = new HashMap<String, Object>();
> map.put("chat", "Wake up call from the chatroom :-) to
> "+topic);
> map.put("user", "ChatPinger");
> Data data = new Data();
> data.setMapData(map);
> data.setChannel(topic);
> DeliverResponse deliverResponse = new DeliverResponse();
> deliverResponse.setChannel(topic);
> deliverResponse.setData(data);
> deliverResponse.setLast(true);
> deliverResponse.setFollow(true);
> context.notify(deliverResponse);
> System.out.println("Sent "+map+" back down to the comet
> context");
> for (Iterator iter = context.getCometHandlers().iterator() ;
> iter.hasNext() ;) {
> handler = (CometHandler) iter.next();
> System.out.println("Found handler: " + handler);
> }
> System.out.println("Completed try block");
> }
> } catch (Exception e) { System.out.println(e.toString()); }
> }
> }
>
> --
> View this message in context: http://www.nabble.com/grizzly-cometd-bayeux-not-sending-messages-to-all-subscribed-clients.-tp24460710p25011615.html
> Sent from the Grizzly - Users mailing list archive at Nabble.com.
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe_at_grizzly.dev.java.net
> For additional commands, e-mail: users-help_at_grizzly.dev.java.net
>