Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unable to receive messages from ActiveMQ in 'auto' ack mode #181

Open
dmitry027 opened this issue Apr 26, 2024 · 1 comment
Open

Unable to receive messages from ActiveMQ in 'auto' ack mode #181

dmitry027 opened this issue Apr 26, 2024 · 1 comment

Comments

@dmitry027
Copy link

Environment:

PHP v8.1
Activemq Artemis v2.33.0 with default settings
stomp-php/stomp-php v5.1

I am running ActiveMQ via docker:

docker run --rm -p 61613:61613 -e ANONYMOUS_LOGIN=true apache/activemq-artemis:2.33.0

Listener script:

$client = new \Stomp\Client('tcp://127.0.0.1:61613');
$stomp = new \Stomp\StatefulStomp($client);
$stomp->subscribe('test-topic', null, 'auto');
while (true) {
    if ($frame = $stomp->read()) {
        echo $frame->getBody(), ' ', $frame->getMessageId(), "\n";
    }
}

Emitter script:

$client = new \Stomp\Client('tcp://127.0.0.1:61613');
$stomp = new \Stomp\StatefulStomp($client);
$stomp->send('test-topic', new \Stomp\Transport\Message('test'));

The problem is that the listener only receives the first message, all subsequent messages remain in the queue. But when subscription mode is 'client' and I send ack for each message, it works fine.

This behavior seems to be caused by 'activemq.prefetchSize:1' header which is always set by the lib.

The client code doesn't seem to be able to change this behavior, because Frame::addHeaders() method can't override headers that were set by ActiveMq::getSubscribeFrame(), as it uses += operator.

@dmitry027
Copy link
Author

Fixed by setting 'consumer-window-size' header, which seems to take precedence over 'activemq.prefetchSize'.

$stomp->subscribe('test-topic', null, 'auto', [
    'consumer-window-size' => -1,
]);

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant