Skip to content

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

@dmitry027

Description

@dmitry027

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions