This is an automated email from the ASF dual-hosted git repository.

davsclaus pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/camel.git


The following commit(s) were added to refs/heads/main by this push:
     new 3a76888e1ba Camel-16483 remove unwanted code (#18286)
3a76888e1ba is described below

commit 3a76888e1ba87838905047b8913d63f7bcc6b646
Author: Vineet Saurabh <vineetsaur...@gmail.com>
AuthorDate: Thu Jun 5 15:36:24 2025 +0200

    Camel-16483 remove unwanted code (#18286)
    
    JetstreamManagement::addStream menthod call addOrUpdateStream. So, it is 
safe to call addStream method even if there is an existing stream with the same 
name.
    
    Co-authored-by: Vineet Saurabh <vineet.saur...@bbraun.com>
---
 .../apache/camel/component/nats/NatsConsumer.java    | 20 +++++---------------
 1 file changed, 5 insertions(+), 15 deletions(-)

diff --git 
a/components/camel-nats/src/main/java/org/apache/camel/component/nats/NatsConsumer.java
 
b/components/camel-nats/src/main/java/org/apache/camel/component/nats/NatsConsumer.java
index 5bfaa962960..42b5c988c5c 100644
--- 
a/components/camel-nats/src/main/java/org/apache/camel/component/nats/NatsConsumer.java
+++ 
b/components/camel-nats/src/main/java/org/apache/camel/component/nats/NatsConsumer.java
@@ -159,24 +159,14 @@ public class NatsConsumer extends DefaultConsumer {
                     consumerName, this.configuration.getTopic());
 
             JetStreamManagement jsm = connection.jetStreamManagement();
-            try {
-                // Try to get the stream, create it if it doesn't exist
-                jsm.getStreamInfo(streamName);
-            } catch (JetStreamApiException e) {
-                if (e.getErrorCode() == 404) {
-                    StreamConfiguration streamConfig = 
StreamConfiguration.builder()
-                            .name(streamName)
-                            .subjects(topic)
-                            .build();
-                    jsm.addStream(streamConfig);
-                } else {
-                    throw e;
-                }
-            }
+            StreamConfiguration streamConfig = StreamConfiguration.builder()
+                    .name(streamName)
+                    .subjects(topic)
+                    .build();
+            jsm.addStream(streamConfig);
 
             ConsumerConfiguration.Builder ccBuilder = 
ConsumerConfiguration.builder()
                     .durable(consumerName);
-
             ccBuilder.deliverSubject(null);
             ConsumerConfiguration cc = ccBuilder.build();
 

Reply via email to