Skip to content

Commit e70ad6b

Browse files
committed
Simplify super stream routing settings
1 parent ec1dc72 commit e70ad6b

File tree

2 files changed

+14
-7
lines changed

2 files changed

+14
-7
lines changed

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

+13-6
Original file line numberDiff line numberDiff line change
@@ -136,17 +136,24 @@ public ProducerBuilder routing(
136136
Function<Message, String> routingKeyExtractor,
137137
RoutingType routingType,
138138
ToIntFunction<String> hash) {
139-
if ((routingKeyExtractor == null && routingType == null)
140-
|| (routingKeyExtractor != null && routingType != null)) {
141-
this.routingKeyExtractor = routingKeyExtractor;
142-
this.routingType = routingType;
143-
} else {
139+
if (routingKeyExtractor == null || routingType == null) {
144140
throw new IllegalArgumentException(
145-
"both routing key extractor and routing type must be " + "non-null");
141+
"both routing key extractor and routing type must be non-null");
142+
}
143+
this.routingKeyExtractor = routingKeyExtractor;
144+
this.routingType = routingType;
145+
if (hash != null) {
146+
this.hash = hash;
146147
}
147148
return this;
148149
}
149150

151+
void resetRouting() {
152+
this.routingKeyExtractor = null;
153+
this.routingType = null;
154+
this.hash = null;
155+
}
156+
150157
public Producer build() {
151158
if (subEntrySize == 1 && compression != null) {
152159
throw new IllegalArgumentException(

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

+1-1
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ class SuperStreamProducer implements Producer {
4444
this.superStream = superStream;
4545
this.producerBuilder = producerBuilder.duplicate();
4646
this.producerBuilder.stream(null);
47-
this.producerBuilder.routing(null, null);
47+
this.producerBuilder.resetRouting();
4848
}
4949

5050
@Override

0 commit comments

Comments
 (0)