Tiếp theo là độ dài của queue
Trong rabbitMQ thì độ dài của queue có thể đc setup theo policy theo 2 khía cạnh
1. là queue có thể chứa bao nhiêu phần tử
2. là độ dài bytes của tổng số các phần tử trong queue, ví dụ khai báo là tổng số phần tử trong queue là 2MB=> nếu 1 phần tử mới vào làm cho khối lượng tăng lên hơn 2MB thì phần tử sẽ drop hoặc forward tiếp
Ví dụ sét số phần tử max-length của 1 queue
Map<String, Object> args = new HashMap<String, Object>();
args.put("x-max-length", 10);
channel.queueDeclare("myqueue", false, false, false, args);
Define Max Queue Length Using x-arguments During Declaration
Maximum number of messages can be set by supplying the x-max-length queue declaration argument with a non-negative integer value.
Maximum length in bytes can be set by supplying the x-max-length-bytes queue declaration argument with a non-negative integer value.
If both arguments are set then both will apply; whichever limit is hit first will be enforced.
Overflow behaviour can be set by supplying the x-overflow queue declaration argument with a string value. Possible values are drop-head (default) or reject-publish
Comments
Post a Comment