mirror of
https://github.com/eclipse-sailing-analytics/sailing-analytics.git
synced 2026-11-08 20:12:23 +00:00
bug6211: use explicit ACKs in RabbitInputStreamProvider and set basicQos(1);
this to avoid any flooding of TCP sockets by the RabbitMQ server when the client isn't able to consume traffic fast enough
This commit is contained in:
1 parent
7ed24638ec
commit
48b5c2c8b0
1 file changed
+4
-2
+4
-2
@@ -39,14 +39,16 @@ public class RabbitInputStreamProvider extends NamedImpl {
|
||||
messagesAreWrittenToThis = new PipedOutputStream();
|
||||
clientReadsFromThis = new PipedInputStream(messagesAreWrittenToThis);
|
||||
final QueueingConsumer messageConsumer = new QueueingConsumer(channel);
|
||||
channel.basicConsume(queueName, /* auto-ack */ true, messageConsumer);
|
||||
channel.basicQos(1); // with "manual" acknowledgement, process one message at a time, avoiding overloading inbound socket
|
||||
channel.basicConsume(queueName, /* auto-ack */ false, messageConsumer);
|
||||
new Thread(getClass().getSimpleName()) {
|
||||
@Override
|
||||
public void run() {
|
||||
while (true) {
|
||||
try {
|
||||
Delivery delivery = messageConsumer.nextDelivery();
|
||||
final Delivery delivery = messageConsumer.nextDelivery();
|
||||
byte[] bytesFromMessage = delivery.getBody();
|
||||
channel.basicAck(delivery.getEnvelope().getDeliveryTag(), /* multiple */ false);
|
||||
if (RabbitOutputStream.startsWithTerminationCommand(bytesFromMessage, bytesFromMessage.length)) {
|
||||
if (bytesFromMessage.length == RabbitOutputStream.TERMINATION_COMMAND.length) {
|
||||
// received exactly TERMINATION_COMMAND
|
||||
|
||||
Reference in new issue
Block a user