diff --git a/src/main/java/io/nats/client/JetStream.java b/src/main/java/io/nats/client/JetStream.java index 2f2da8a3e..3d6e6535b 100644 --- a/src/main/java/io/nats/client/JetStream.java +++ b/src/main/java/io/nats/client/JetStream.java @@ -375,7 +375,8 @@ public interface JetStream { *

See {@link io.nats.client.Connection#createDispatcher(MessageHandler) createDispatcher} for * information about creating an asynchronous subscription with callbacks. * - * @param subscribeSubject the subject to subscribe to + * @param subscribeSubject the subject to subscribe to. + * Can be null or empty when the options have a ConsumerConfiguration that supplies a filter subject. * @param options optional subscription options * @return The subscription * @throws IOException covers various communication issues with the NATS @@ -394,6 +395,7 @@ public interface JetStream { * information about creating an asynchronous subscription with callbacks. * * @param subscribeSubject the subject to subscribe to + * Can be null or empty when the options have a ConsumerConfiguration that supplies a filter subject. * @param queue the optional queue group to join * @param options optional subscription options * @return The subscription @@ -424,6 +426,7 @@ public interface JetStream { * specified dispatcher. Since a MessageHandler is also required, the Dispatcher will * not prevent duplicate subscriptions from being made. * @param subscribeSubject The subject to subscribe to. + * Can be null or empty when the options have a ConsumerConfiguration that supplies a filter subject. * @param dispatcher The dispatcher to handle this subscription * @param handler The target for the messages * @param autoAck Whether to auto ack @@ -441,6 +444,7 @@ public interface JetStream { * not prevent duplicate subscriptions from being made. * * @param subscribeSubject The subject to subscribe to. + * Can be null or empty when the options have a ConsumerConfiguration that supplies a filter subject. * @param queue the optional queue group to join * @param dispatcher The dispatcher to handle this subscription * @param handler The target for the messages @@ -456,6 +460,7 @@ public interface JetStream { /** * Create a subscription to the specified subject in the mode of pull, with additional options * @param subscribeSubject The subject to subscribe to + * Can be null or empty when the options have a ConsumerConfiguration that supplies a filter subject. * @param options pull subscription options * @return The subscription * @throws IOException covers various communication issues with the NATS @@ -467,6 +472,7 @@ public interface JetStream { /** * Create an asynchronous subscription to the specified subject in the mode of pull, with additional options * @param subscribeSubject The subject to subscribe to + * Can be null or empty when the options have a ConsumerConfiguration that supplies a filter subject. * @param dispatcher The dispatcher to handle this subscription * @param handler The target for the messages * @param options pull subscription options diff --git a/src/main/java/io/nats/client/impl/NatsJetStream.java b/src/main/java/io/nats/client/impl/NatsJetStream.java index ccc3c35cb..72d56b9cc 100644 --- a/src/main/java/io/nats/client/impl/NatsJetStream.java +++ b/src/main/java/io/nats/client/impl/NatsJetStream.java @@ -302,7 +302,7 @@ JetStreamSubscription createSubscription(String userSubscribeSubject, // 2. figure out user provided subjects and prepare the userCcFilterSubjects userSubscribeSubject = emptyAsNull(userSubscribeSubject); List userCcFilterSubjects = new ArrayList<>(); - if (userCC.getFilterSubject() == null) { // empty filterSubjects gives gives null + if (userCC.getFilterSubject() == null) { // empty filterSubjects gives null // userCC.filterSubjects empty, populate userCcFilterSubjects w/userSubscribeSubject if possible if (userSubscribeSubject != null) { userCcFilterSubjects.add(userSubscribeSubject); diff --git a/src/main/java/io/nats/client/impl/NatsJetStreamImpl.java b/src/main/java/io/nats/client/impl/NatsJetStreamImpl.java index 22cfa2c44..64e011d82 100644 --- a/src/main/java/io/nats/client/impl/NatsJetStreamImpl.java +++ b/src/main/java/io/nats/client/impl/NatsJetStreamImpl.java @@ -87,6 +87,7 @@ ConsumerInfo _createConsumer(String streamName, ConsumerConfiguration config) th String durable = config.getDurable(); String subj; + // new consumer create not available before 290 and can't be used with multiple filter subjects if (consumerCreate290Available && !multipleFilterSubject) { if (consumerName == null) { // if both consumerName and durable are null, generate a name