Automatic batching of outgoing messages?

4 views
Skip to first unread message

Cosimo

unread,
Nov 22, 2022, 8:48:00 AM11/22/22
to cometd-users
Hi,

At the moment I'm using ServerSession.deliver() for each message to remote clients, even in case of high volume of messages.

I'm wondering whether batching, as in:
- session.startBatch(),
- ... multiple deliver() calls
- endBatch()
would perhaps work better.

The source messages (that I receive from multiple threads and that I'm routing through) could be arriving at random times, so I'd like to implement a sort of "time-out" mechanism: if I don't receive any message within x number of milliseconds, I'd like to send what's in the queue in one batch and start a new batch. This is intended for messages to a specific remote session only.

The goal here is to save processing overhead at the remote end, which we have seen to be a problem with a sufficiently large number of messages.

Is there perhaps a built-in mechanism in Comet to do this?

Thanks,

--
Cosimo

Simone Bordet

unread,
Nov 22, 2022, 12:58:03 PM11/22/22
to cometd...@googlegroups.com
Hi,
Have you looked at lazy messages and channels?
https://docs.cometd.org/current7/reference/#_java_server_lazy_messages

--
Simone Bordet
----
http://cometd.org
http://webtide.com
Developer advice, training, services and support
from the Jetty & CometD experts.

Cosimo

unread,
Nov 23, 2022, 6:20:15 AM11/23/22
to cometd...@googlegroups.com
On Tue, Nov 22, 2022, at 18:57, Simone Bordet wrote:
> On Tue, Nov 22, 2022 at 2:48 PM Cosimo <cosi...@streppone.it> wrote:
>>
>> At the moment I'm using ServerSession.deliver() for each message to remote clients, even in case of high volume of messages.
>>
> Have you looked at lazy messages and channels?
> https://docs.cometd.org/current7/reference/#_java_server_lazy_messages

Thanks, this seems useful.

Will this work even if I use deliver() to send messages - which I've setLazy(true) -
rather than publish to a channel?

--
Cosimo

Simone Bordet

unread,
Nov 23, 2022, 6:57:37 AM11/23/22
to cometd...@googlegroups.com
Hi,
Yes it will work for deliver() too.

--
Simone Bordet
---
Finally, no matter how good the architecture and design are,
to deliver bug-free software with optimal performance and reliability,
the implementation technique must be flawless. Victoria Livschitz
Reply all
Reply to author
Forward
0 new messages