Hi Marco,
sorry for the NPE (thanks for the clear description of the problem).
I've fixed it but now I need to understand why the channel isn't set
correctly. Can you send me your client so I can see what's happening
(jeanfrancois.arcand at sun.com)?
Thanks!!!
-- Jeanfrancois
Marco Balzter wrote:
> Hello Jeanfrancois,
>
> i have a problem with the new channel implementation. Here is a short subscription of what i'm doing:
>
> - A "Comet Read Client" subscribes to channel "chat/demo". The channel does not get set on the "onSubscribe" or "onReconnect" methods in the BayeuxCometHandler. Please see my comment in the code snippet below.
> - A "Comet Writer Client" writes to channel "chat/demo". The method notify0 of the CometdNotificationHandler leaves me with NullpointerException. Please see my comment in the code snippet below.
>
> Perhaps i've done something wrong in setting the channel in my "Comet Read Client".
> If you need more information i'll be happy to give.
>
> Class BayeuxCometHandler
> public void onSubscribe(CometEvent event) throws IOException {
> ...
> DataHandler dataHandler = activeHandler.get(subscribe.getClientId());
> -->
> --> dataHandler is null, so channel does not get set. Client id is a numeric value
> -->
> if (dataHandler != null){
> dataHandler.setChannel(subscribe.getSubscription());
> }
> res.setContentType(DEFAULT_CONTENT_TYPE);
> res.write(subscribe.toJSON());
> res.flush();
> }
>
>
> public void onReconnect(CometEvent event) throws IOException {
> ...
> DataHandler prevHandler = activeHandler
> .putIfAbsent(reconnect.getClientId(),requestHandler);
> // Set the previous channel value.
> -->
> --> DataHandler prevHandler is null, so channel does not get set.
> -->
> if (prevHandler != null){
> requestHandler.setChannel(prevHandler.getChannel());
> }
> cometContext.addCometHandler(requestHandler);
>
> res.setContentType(DEFAULT_CONTENT_TYPE);
> res.write(reconnect.toJSON());
> res.flush();
> }
>
>
> Class CometdNotificationHandler
> /**
> * Notify only client subscribed to the active channel.
> */
> protected void notify0(CometEvent cometEvent,Iterator<CometHandler> iteratorHandlers)
> throws IOException{
> ...
>
> handler = (CometHandler)iteratorHandlers.next();
>
> if (handler instanceof CometdHandler){
> channel = ((CometdHandler)handler).getChannel();
> } else if (handler instanceof DataHandler){
> channel = ((DataHandler)handler).getChannel();
> -->
> --> channel is "chat/demo".
> -->
> }
> while(iteratorHandlers.hasNext()){
> try{
> handler = (CometHandler)iteratorHandlers.next();
>
> if (handler instanceof CometdHandler){
> channel = ((CometdHandler)handler).getChannel();
> } else if (handler instanceof DataHandler){
> channel = ((DataHandler)handler).getChannel();
> -->
> --> channel is null
> -->
> }
>
> if (channel.equals(BayeuxCometHandler.BAYEUX_COMET_HANDLER)
> -->
> --> i get a NullPointerException here because channel is null
> -->
> || channel.equalsIgnoreCase(activeChannel)){
> notify0(cometEvent,handler);
> }
> } catch (Throwable ex){
> if (exceptions == null){
> exceptions = new ArrayList<Throwable>();
> }
> exceptions.add(ex);
> }
> }
> if (exceptions != null){
> StringBuffer errorMsg = new StringBuffer();
> for(Throwable t: exceptions){
> errorMsg.append(t.getMessage());
> }
> throw new IOException(errorMsg.toString());
> }
> }
>
>
> Regards
> Marco
>
> -----Ursprüngliche Nachricht-----
> Von: Jeanfrancois.Arcand_at_Sun.COM [mailto:Jeanfrancois.Arcand_at_Sun.COM]
> Gesendet: Dienstag, 24. April 2007 22:30
> An: users_at_grizzly.dev.java.net
> Betreff: Re: AW: Re: AW: Re: Grizzly Cometd questions
>
>
> Hi Marco,
>
> finally I've updated the cometd workspace with the fix for the multiple
> channels update. Can you try it and let me know if you still see the
> problem?
>
> Thanks for you patience!
>
> -- Jeanfrancois
>
> Marco Balzter wrote:
>> Hi Jeanfrancois,
>>
>> it's only half an hour before weekend starts (at least in the timezone i'm in).
>> So i'll give you feedback sometime next week.
>>
>> Thanks for your quick response
>>
>> Marco
>>
>> -----Ursprüngliche Nachricht-----
>> Von: Jeanfrancois.Arcand_at_Sun.COM [mailto:Jeanfrancois.Arcand_at_Sun.COM]
>> Gesendet: Freitag, 13. April 2007 16:42
>> An: users_at_grizzly.dev.java.net
>> Betreff: Re: AW: Re: Grizzly Cometd questions
>>
>>
>> Hi Marco,
>>
>> Marco Balzter wrote:
>>> Hi Jeanfrancois,
>>>
>>> i'm using the latest sources from grizzly.dev.java.net. So i assume it's version 1.5.
>>> I think i will wait until you fixed the issue on Grizzly 1.5 and will have
>>> a look to the grizzly repository sometimes next week to see if something changed.
>> Already done yesterday :-) Can you try it and let me know. There is one
>> bug to fix which is the update of all channel instead of a single one.
>> I'm working on it right now and should have something by the end of the day.
>>
>> Thanks!
>>
>> -- Jeanfrancois
>>
>>> Thanks for your help
>>>
>>> Marco
>>>
>>> -----Ursprüngliche Nachricht-----
>>> Von: Jeanfrancois.Arcand_at_Sun.COM [mailto:Jeanfrancois.Arcand_at_Sun.COM]
>>> Gesendet: Donnerstag, 12. April 2007 15:20
>>> An: users_at_grizzly.dev.java.net
>>> Betreff: Re: Grizzly Cometd questions
>>>
>>>
>>> Hi Marco,
>>>
>>> Marco Balzter wrote:
>>>> Hi,
>>>>
>>>> I'm using the CometdAdapter as the Adapter class for grizzly standalone
>>>> ARP.
>>>> In the CometContext class the blockingNotification can be set to
>>>> true/false.
>>>> With blockingNotification set to true i can get my Test application up
>>>> and running.
>>>> Grizzly sends back the correct HTTP header and the answer to my bayeux
>>>> message in the POST section.
>>> Which version are you using (Grizzly 1.0 or 1.5)? I've fixed a similar
>>> issue on Monday in GlassFish (Grizzly 1.0) and I need to port the fix to
>>> 1.5.I will try to port the fix to 1.5 as soon as possible.
>>>
>>>> But with blockingNotification set to false it seems that Grizzly only
>>>> sends back the HHTP header
>>>> and does not send a POST section at all.
>>>> Could someone give me a hint if this is a bug or if i'm doing something
>>>> wrong here.
>>> This is a bug. I need to look at it.
>>>
>>>> Another question: With blockingNotification set to true, the server
>>>> blocks for a few seconds after the
>>>> notification (at least he seems to block). Using long-polling in my
>>>> application i'm doing a reconnect after receiving some data.
>>> Why? The connection is long polled so you don't necessarily needs to
>>> reconnect. You can leave the connection open and waits for new server push
>>>
>>>> If the server is in blocking mode, the reconnect request does not reach
>>>> the server and my application hangs.
>>>> Any ideas how to avoid this situation without resending the reconnect
>>>> request?
>>> Hum...this is strange. It may or may not be related to the bug have
>>> fixed in 1.0. Can you try your application in GlassFish latest nightly?
>>> Or wait a couple of hours and I will port the 1.0 fix to 1.5.
>>>
>>> Thanks for your feedback!
>>>
>>> -- Jeanfrancois
>>>
>>>
>>>> Thanks for your help
>>>>
>>>> Marco
>>>>
>>>>
>>>> ------------------------------------------------------------------------
>>>> PROEMION GmbH
>>>>
>>>> *Marco Balzter *
>>>>
>>>> IT Development (IT/DEV)
>>>>
>>>> Donaustrasse 14
>>>> D-36043 Fulda, Germany
>>>>
>>>> Phone +49 (0) 661 9490-151
>>>> Fax +49 (0) 661 9490-333
>>>>
>>>> http://www.proemion.com <http://www.proemion.com/>
>>>> marco.balzter_at_proemion.com <mailto:marco.balzter_at_proemion.com>
>>>>
>>>> Geschäftsleitung: Dipl. Ing. Robert Michaelides
>>>> Handelsregister: AG Fulda 5 HRB 1867
>>>>
>>>>
>>>> ------------------------------------------------------------------------
>>>> E-mail and any attachments may be confidential. If you have received
>>>> this E-mail and you are not a named addressee, please inform the sender
>>>> immediately by E-mail and then delete this E-mail from your system. If
>>>> you are not a named addressee, you may not use, disclose, distribute,
>>>> copy or print this E-mail. Addressees should scan this E-mail and any
>>>> attachments for viruses. No representation or warranty is made as to the
>>>> absence of viruses in this E-mail or any of its attachments.
>>>>
>>>>
>>>> AKTUELLES
>>>> * PROEMION auf der Messe HMI in Hannover. *
>>>> Kommen Sie uns vom 16. - 20. April in Halle 9, Stand D05 besuchen. Wir
>>>> freuen uns auf Sie!
>>>> <http://www.rmcan.de>
>>>>
>>>> NEWS
>>>> * PROEMION is exhibiting at HMI in Hannover. *
>>>> Come and visit us from April 16 - 20 in Hall 9 at Booth D05. We look
>>>> forward to seeing you there!
>>>> <http://www.rmcan.com>
>>>>
>>> ---------------------------------------------------------------------
>>> 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
>>>
>> ---------------------------------------------------------------------
>> 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
>>
>
> ---------------------------------------------------------------------
> 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
>