You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Dec 31, 2025. It is now read-only.
I'm trying to play around with nats-streaming and I took an example from the readme but it throws a NullPointerException when I try to call sub.close()
Exception in thread "main" java.lang.NullPointerException
at shaded.nats.com.google.protobuf.AbstractParser.parseFrom(AbstractParser.java:185)
at shaded.nats.com.google.protobuf.AbstractParser.parseFrom(AbstractParser.java:190)
at shaded.nats.com.google.protobuf.AbstractParser.parseFrom(AbstractParser.java:49)
at io.nats.streaming.protobuf.SubscriptionResponse.parseFrom(SubscriptionResponse.java:253)
at io.nats.streaming.SubscriptionImpl.close(SubscriptionImpl.java:178)
at NatsStreamingService.main(NatsStreamingService.java:41)
import io.nats.streaming.*;
import java.time.Duration;
import java.util.concurrent.CountDownLatch;
public class NatsStreamingService {
public static void main(String[] args) throws Exception {
// Create a connection factory
StreamingConnectionFactory cf = new StreamingConnectionFactory("test-cluster", "bar");
cf.setNatsUrl("nats://localhost:4223");
try (StreamingConnection sc = cf.createConnection()) {
sc.publish("TestSubject", "Hello World".getBytes());
final CountDownLatch doneSignal = new CountDownLatch(1);
final SubscriptionOptions options = new SubscriptionOptions.Builder()
.deliverAllAvailable()
.manualAcks()
.ackWait(Duration.ofSeconds(60L))
.build();
Subscription sub = sc.subscribe("TestSubject", m -> {
System.out.printf("Received a message: %s\n", new String(m.getData()));
try {
System.out.println("Going to ack");
m.ack();
doneSignal.countDown();
}catch (Exception e) {
e.printStackTrace();
}
}, options);
doneSignal.await();
sub.close(true);
}
}
}
I'm trying to play around with nats-streaming and I took an example from the readme but it throws a NullPointerException when I try to call
sub.close()Client version: 0.5.0
Server version: 0.9.2