0

Given a Java web application using CometD, how can I publish a message to all of a channel's subscribers each time a message is processed by bayeux?

For testing, I used serverSession.deliver(serverSession, "/test-channel", map, null);.

The result is that my Javascript client will subscribe successfully, but only receive messages 1 out of 10 tries. So, 90% of the time, no messages are ever received by the browser, yet the Bayeux logging (level 3) shows that they are being sent to the correct channel every time.

Should I be using some form of a client session? The CometD documentation appears to be a bit unclear.

Matt
  • 3,254
  • 3
  • 23
  • 32

1 Answers1

2

Using the localSession seems to be the answer. I implemented this to fix:

ClientSessionChannel channel = localSession.getChannel(getClientChannel());
channel.publish(map);

The clients are now receiving all messages.

Matt
  • 3,254
  • 3
  • 23
  • 32
  • Have you tried for example publishing a message to a channel from a java client and you had expected the message to arrive to all subscribers (even the javascript/dojo ones?)If so could you, please provide the complete code of the java publishing client? I have this use case and I don't know what is wrong because the javascript client doesn't receive the message. Thanks – mihaela Oct 04 '11 at 14:56
  • I was referring to this: http://stackoverflow.com/questions/7658643/publish-messages-using-cometd-java-client-that-can-be-consumed-by-javascript-subs – mihaela Oct 05 '11 at 13:16