BayeuxClient in java, need hooks for lost connection

37 views
Skip to first unread message

Drahcir

unread,
Jun 8, 2009, 5:48:42 AM6/8/09
to cometd-dev
Hi all,

I am using the BayeuxClient code in an open source project my company
is working on. The BayeuxClient is used by a 'TestBot' slave for
communication with our Server. The testbots need to stay alive and as
soon as the connection to the server is lost (e.g. because the server
gets a new release), the slave should automatically reconnect.

I have been busy searching for hooks to get notified when the
connection is lost. With my current (limited) knowledge of the system
I would add a RemoveListener and implement a reconnect on a remove.
However, I don't see a reference to the list to inform the registered
remove listeners. Maybe I miss something, but currently I assume this
is just not implemented. I will try to implement the code myself and
see if this provides me the functionality I need.

Maybe I am having the wrong assumptions, or I want something that can
be handled in a completely different way. So please correct me if I am
wrong.

cheers,

Richard den Adel.



Drahcir

unread,
Jun 9, 2009, 8:20:30 AM6/9/09
to cometd-dev
I have changed the code for BayeuxClient by changing the code for
setInitialized(boolean b).
I understand this is possibly not the right place for the call of
RemoveListener, but this works for me. I can now react on a lost
connection and rebuild the connection in a proper way.
Is there a way to get (similar) behaviour in the next release of
cometd-java-client? Is there something I can do to help?

cheers,

Richard.

p.s. My change to BayeuxClient.java (I changed version 1.0.beta8 )


/* ------------------------------------------------------------ */
/**
* False when we have received a success=false message in response
to a
* Connect, or we have had an exception when sending or receiving
a Connect.
* True when handshake and then connect has happened.
*
* @param b
*/
protected void setInitialized(boolean b) {

synchronized (_outQ) {
_initialized = b;
if (!_initialized) {
for (RemoveListener r : _rListeners) {
r.removed(_clientId, false);

Athena

unread,
Jun 9, 2009, 8:45:32 AM6/9/09
to comet...@googlegroups.com
Hi Richard,

See ClientImpl.remove -- it notifies any available listeners when a
client has been removed.

cheers,
Athena

Drahcir

unread,
Jun 9, 2009, 9:35:12 AM6/9/09
to cometd-dev
Hi Athena,

ClientImpl is the server side. I am looking for the BayeuxClient from
the client side as part of a java application. Or do I miss something?

Richard.

Greg Wilkins

unread,
Jun 21, 2009, 10:07:45 PM6/21/09
to comet...@googlegroups.com

Drahcir,

with the latest javascript client (to be released in beta9 or in svn now),
you can addListener client side to /meta/* channels to receive such events.

I think there is a /meta/unsuccessful channel.

Simone (bcc'd) have we documented these channels anywhere ?

cheers

Richard den Adel

unread,
Jun 22, 2009, 8:51:30 AM6/22/09
to comet...@googlegroups.com
Hi Greg,

I am not using the javascript client, I am using the java client. Does
this make any difference?

Richard.

Jan Bartel

unread,
Jun 22, 2009, 7:26:14 PM6/22/09
to comet...@googlegroups.com
Richard,

Have a look at the SimpleEchoBayeuxClient.java test class.
It's in the jetty-6 repository at:

https://svn.codehaus.org/jetty-contrib/branches/jetty-6.1.x/contrib/cometd/client/src/test/java/org/mortbay/cometd/client/SimpleEchoBayeuxClient.java

cheers
Jan

Drahcir

unread,
Jul 21, 2009, 4:59:33 AM7/21/09
to cometd-dev
Hi Jan,

It looks similar to what BayeuxClient.java already does. I just added
the hook in BayeuxClient.java to make sure the RemoveListeners are
called as soon as there is failure. It would be very helpfull for me
if this code can be included in upcoming releases of cometd.

cheers,

Richard.

On Jun 23, 1:26 am, Jan Bartel <j...@mortbay.com> wrote:
> Richard,
>
> Have a look at the SimpleEchoBayeuxClient.java test class.
> It's in the jetty-6 repository at:
>
> https://svn.codehaus.org/jetty-contrib/branches/jetty-6.1.x/contrib/c...
Reply all
Reply to author
Forward
0 new messages