« Return to Thread: Queue does not drain completely.

Re: Queue does not drain completely.

by RakeshRay :: Rate this Message:

Reply to Author | View in Thread


Hi,
We have written a wrapper around and internally it is using using timeout feature.
What version of Active MQ are you using?

sub read {
        my ($self) = @_;
        # after reading, we also need to acknoledge the read, but keep them both as part of the same transaction
       
        # still need to define a way of signalling errors vs nothing to read
       
        return unless $self->{stomp}->can_read({ timeout => '5' });
       
        my $frame = $self->{stomp}->receive_frame;

        return unless $frame;
       
        my $msg = $frame->body;
        my $msgid = $frame->headers->{'message-id'};

        # sending an ACK with the message id and a transaction makes the read part of the transaction
        $frame = Net::Stomp::Frame->new( {
                command => 'ACK',
                headers => { transaction => $self->_tran(), 'message-id' => $msgid },
        } );
    $self->{stomp}->send_frame($frame);

        return $msg;
}




I don't know the PHP Stomp client very well (but a Delphi implementation).

$stomp->read() seems to return immediately without waiting for the next message.
There might be a different method $stomp->read(receivetimeout), which waits for the given time (in milliseconds) before it gives up.

Michael

RakeshRay wrote:
Just installed Active MQ 5.2.
Using Stomp, inserted 5000 msgs and try to read the same with
while ( my $msg = $stomp->read() ) {
        $stomp->commit();
        print $msg.$/;
}
It leaves 2 messages in the queue, just reads 4998 and comes out.

Any suggestions?

 « Return to Thread: Queue does not drain completely.