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

Create queues with limit length #30

Closed
droidsyer opened this issue Feb 3, 2016 · 4 comments
Closed

Create queues with limit length #30

droidsyer opened this issue Feb 3, 2016 · 4 comments

Comments

@droidsyer
Copy link
Contributor

Hi,
Can I configure a queue with limit of length ?
I need to create a queue with last value caching and max number of message equal to 1.
I set this policy with a command on rabbitmq server, without effects....
My problem is a queue grow up more than 1 message.
Example
1 sender publish a message per second
1 receiver receive a message one per second, but if I break it on a breakpoint then i resume from break, It will receive all message buffered on queue, what I want is receive only last value sent.

I think RabbitMQ server holds ready_messages =0
So doesn't purge oldest messages from queue, saving only last message sent.

Thanks,.

@droidsyer
Copy link
Contributor Author

I resolved it combining:

  • message with ACK
  • queue with QoS (Quality of Service)
  • queue with limit on "x-max-length"
    In order to configure x-max-lenght using arguments, I've just modify "declare" method of queue class.
QAmqpTable optionTable;
optionTable.insert("x-max-length",1);
queue_->declare(option, optionTable);
void declare(int options = Durable|AutoDelete, const QAmqpTable optionTable = QAmqpTable());
void QAmqpQueue::declare(int options, const QAmqpTable optionTable)
{
    Q_D(QAmqpQueue);
    d->options = options;
    d->optionsTable = optionTable;

    if (!d->opened) {
        d->delayedDeclare = true;
        return;
    }

    d->declare();
}

Added private attribute to QAmqpQueuePrivate class:

private:
    QAmqpTable optionsTable;

@mbroadst
Copy link
Owner

mbroadst commented Feb 3, 2016

@droidsyer ah yes, it looks like optional arguments were omitted from both exchange and queue declare methods. Would you be willing to put a PR together for this? Also, just as a nitpick I would prefer that the parameter was called arguments like the spec. Extra bonus points if you put a test together 😄

@droidsyer
Copy link
Contributor Author

@mbroadst I've just create a PR about this, it's my first time :-D.
Is it right?

@droidsyer
Copy link
Contributor Author

@mbroadst Can you please be aware about "arguments and qamqpInterface.pri" pull request.
It has been tested by me, it works !

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

2 participants