Skip to content

Commit 68fd5bd

Browse files
committed
Increment connection name suffix
References #50
1 parent 06a5913 commit 68fd5bd

File tree

2 files changed

+17
-1
lines changed

2 files changed

+17
-1
lines changed

src/main/java/com/rabbitmq/stream/impl/Utils.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -234,6 +234,6 @@ static Function<ClientConnectionType, String> defaultConnectionNamingStrategy()
234234
prefixes.put(type, "rabbitmq-stream-" + type.name().toLowerCase(Locale.ENGLISH) + "-");
235235
}
236236
return clientConnectionType ->
237-
prefixes.get(clientConnectionType) + sequences.get(clientConnectionType);
237+
prefixes.get(clientConnectionType) + sequences.get(clientConnectionType).getAndIncrement();
238238
}
239239
}

src/test/java/com/rabbitmq/stream/impl/UtilsTest.java

+16
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
import static com.rabbitmq.stream.Constants.CODE_MESSAGE_ENQUEUEING_FAILED;
1717
import static com.rabbitmq.stream.Constants.RESPONSE_CODE_OK;
1818
import static com.rabbitmq.stream.Constants.RESPONSE_CODE_STREAM_DOES_NOT_EXIST;
19+
import static com.rabbitmq.stream.impl.Utils.defaultConnectionNamingStrategy;
1920
import static com.rabbitmq.stream.impl.Utils.formatConstant;
2021
import static org.assertj.core.api.Assertions.assertThat;
2122
import static org.mockito.ArgumentMatchers.any;
@@ -26,11 +27,14 @@
2627
import static org.mockito.Mockito.when;
2728

2829
import com.rabbitmq.stream.impl.Client.ClientParameters;
30+
import com.rabbitmq.stream.impl.Utils.ClientConnectionType;
2931
import com.rabbitmq.stream.impl.Utils.ClientFactory;
3032
import com.rabbitmq.stream.impl.Utils.ClientFactoryContext;
3133
import com.rabbitmq.stream.impl.Utils.ExactNodeRetryClientFactory;
3234
import java.time.Duration;
35+
import java.util.function.Function;
3336
import java.util.function.Predicate;
37+
import java.util.stream.IntStream;
3438
import org.junit.jupiter.api.Test;
3539

3640
public class UtilsTest {
@@ -73,4 +77,16 @@ void exactNodeRetryClientFactoryShouldRetryUntilConditionOk() {
7377
verify(cf, times(3)).client(any());
7478
verify(client, times(2)).close();
7579
}
80+
81+
@Test
82+
void defaultConnectionNamingStrategyShouldIncrement() {
83+
Function<ClientConnectionType, String> strategy = defaultConnectionNamingStrategy();
84+
for (ClientConnectionType type : ClientConnectionType.values()) {
85+
IntStream.range(0, 10)
86+
.forEach(
87+
i -> {
88+
assertThat(strategy.apply(type)).endsWith("-" + i);
89+
});
90+
}
91+
}
7692
}

0 commit comments

Comments
 (0)