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

GH-2552: Fix Builder Argument Types maxLength etc #2553

Merged
merged 1 commit into from
Oct 31, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2016-2022 the original author or authors.
* Copyright 2016-2023 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -150,12 +150,26 @@ public QueueBuilder expires(int expires) {
* @param count the number of (ready) messages allowed.
* @return the builder.
* @since 2.2
* @deprecated in favor of {@link #maxLength(long)}.
* @see #overflow(Overflow)
*/
@Deprecated
public QueueBuilder maxLength(int count) {
return withArgument("x-max-length", count);
}

/**
* Set the number of (ready) messages allowed in the queue before it starts to drop
* them.
* @param count the number of (ready) messages allowed.
* @return the builder.
* @since 3.1
* @see #overflow(Overflow)
*/
public QueueBuilder maxLength(long count) {
return withArgument("x-max-length", count);
}

/**
* Set the total aggregate body size allowed in the queue before it starts to drop
* them.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
* Based on <a href="https://www.rabbitmq.com/streams.html">Streams documentation</a>
*
* @author Sergei Kurenchuk
* @author Gary Russell
* @since 3.1
*/
public class SuperStreamBuilder {
Expand Down Expand Up @@ -73,7 +74,7 @@ public SuperStreamBuilder maxAge(String maxAge) {
* @param bytes the max total size in bytes
* @return the builder
*/
public SuperStreamBuilder maxLength(int bytes) {
public SuperStreamBuilder maxLength(long bytes) {
return withArgument("max-length-bytes", bytes);
}

Expand All @@ -82,7 +83,7 @@ public SuperStreamBuilder maxLength(int bytes) {
* @param bytes the max segments size in bytes
* @return the builder
*/
public SuperStreamBuilder maxSegmentSize(int bytes) {
public SuperStreamBuilder maxSegmentSize(long bytes) {
return withArgument("x-stream-max-segment-size-bytes", bytes);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,8 +85,8 @@ void builderMustSetupArguments() {
var finalPartitionsNumber = 4;
var finalName = "test-name";
var maxAge = "1D";
var maxLength = 10_000_000;
var maxSegmentsSize = 100_000;
var maxLength = 10_000_000L;
var maxSegmentsSize = 100_000L;
var initialClusterSize = 5;

var testArgName = "test-key";
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2014-2022 the original author or authors.
* Copyright 2014-2023 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -265,7 +265,7 @@ public Queue allArgs1() {
return QueueBuilder.nonDurable("all.args.1")
.ttl(1000)
.expires(200_000)
.maxLength(42)
.maxLength(42L)
.maxLengthBytes(10_000)
.overflow(Overflow.rejectPublish)
.deadLetterExchange("reply.dlx")
Expand All @@ -282,7 +282,7 @@ public Queue allArgs2() {
return QueueBuilder.nonDurable("all.args.2")
.ttl(1000)
.expires(200_000)
.maxLength(42)
.maxLength(42L)
.maxLengthBytes(10_000)
.overflow(Overflow.dropHead)
.deadLetterExchange("reply.dlx")
Expand All @@ -298,7 +298,7 @@ public Queue allArgs3() {
return QueueBuilder.nonDurable("all.args.3")
.ttl(1000)
.expires(200_000)
.maxLength(42)
.maxLength(42L)
.maxLengthBytes(10_000)
.overflow(Overflow.rejectPublish)
.deadLetterExchange("reply.dlx")
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2002-2022 the original author or authors.
* Copyright 2002-2023 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -833,7 +833,7 @@ public void testWithFuture() throws Exception {
RabbitAdmin admin = new RabbitAdmin(this.connectionFactory);
Queue queue = QueueBuilder.nonDurable()
.autoDelete()
.maxLength(1)
.maxLength(1L)
.overflow(Overflow.rejectPublish)
.build();
admin.declareQueue(queue);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2018-2019 the original author or authors.
* Copyright 2018-2023 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -103,7 +103,7 @@ void testCorrelatedWithNack() {
RabbitTemplate template = new RabbitTemplate(ccf);
RabbitAdmin admin = new RabbitAdmin(ccf);
Queue queue = QueueBuilder.durable(QUEUE + ".nack")
.maxLength(1)
.maxLength(1L)
.overflow(Overflow.rejectPublish)
.build();
admin.declareQueue(queue);
Expand Down