Subscription to stream sa-stream failed with code 17 (PRECONDITION_FAILED) #6445
-
I learn from the blog rabbitmq-3-11-feature-preview-single-active-consumer-for-streams but it startup fail: An exception occured while executing the Java class. Subscription to stream single-active-consumer failed with code 17 (PRECONDITION_FAILED) RabbitMQ 3.11.3 |
Beta Was this translation helpful? Give feedback.
Replies: 3 comments 1 reply
-
I re-ran the steps from the blog post and it worked as expected. Please be more specific on the steps you ran to get to this error and provide server logs as well. Thanks. |
Beta Was this translation helpful? Give feedback.
-
the log show 2022-11-24 11:39:45.620144+08:00 [info] <0.1237.0> accepting AMQP connection <0.1237.0> (127.0.0.1:53080 -> 127.0.0.1:5672)
2022-11-24 11:39:45.624502+08:00 [info] <0.1237.0> connection <0.1237.0> (127.0.0.1:53080 -> 127.0.0.1:5672) has a client-provided name: rabbitConnectionFactory#37f21974:0
2022-11-24 11:39:45.626377+08:00 [info] <0.1237.0> connection <0.1237.0> (127.0.0.1:53080 -> 127.0.0.1:5672 - rabbitConnectionFactory#37f21974:0): user 'guest' authenticated and granted access to vhost '/demo'
2022-11-24 11:39:45.804475+08:00 [warning] <0.1262.0> Cannot create subcription 0, stream single active consumer feature flag is not enabled
2022-11-24 11:39:47.948112+08:00 [info] <0.1237.0> closing AMQP connection <0.1237.0> (127.0.0.1:53080 -> 127.0.0.1:5672 - rabbitConnectionFactory#37f21974:0, vhost: '/demo', user: 'guest') I just run the code: private void sac(String stream) {
try (Environment environment =
Environment.builder()
.uri("rabbitmq-stream://localhost:5552")
.virtualHost("/demo")
.maxConsumersByConnection(1)
.maxTrackingConsumersByConnection(1)
.build()) {
environment.streamCreator().stream(stream).create();
IntStream.range(0, 3)
.forEach(
i -> {
System.out.println("Starting consumer instance " + i);
environment.consumerBuilder().stream(stream)
.name(stream + "-consumer")
.singleActiveConsumer()
.autoTrackingStrategy()
.messageCountBeforeStorage(10)
.builder()
.messageHandler(
(context, message) -> {
System.out.printf(
"Consumer instance %d received a message (%d).%n",
i, sequence.incrementAndGet());
})
.build();
});
Scanner keyboard = new Scanner(System.in);
keyboard.nextLine();
}
} |
Beta Was this translation helpful? Give feedback.
-
The server logs say the stream SAC feature flag is not activated:
You have to activate it: rabbitmqctl enable_feature_flag stream_single_active_consumer All feature flags are activated on a new installation, so maybe you installed 3.11.3 on top of an older installation. If it's meant for testing, you can wipe completely the old installation or use an one-time Docker container: docker run -it --rm --name rabbitmq -p 5552:5552 -p 5672:5672 -p 15672:15672 \
-e RABBITMQ_SERVER_ADDITIONAL_ERL_ARGS='-rabbitmq_stream advertised_host localhost' \
rabbitmq:3.11-management And enable the stream plugin: docker exec rabbitmq rabbitmq-plugins enable rabbitmq_stream |
Beta Was this translation helpful? Give feedback.
The server logs say the stream SAC feature flag is not activated:
You have to activate it:
All feature flags are activated on a new installation, so maybe you installed 3.11.3 on top of an older installation. If it's meant for testing, you can wipe completely the old installation or use an one-time Docker container:
docker run -it --rm --name rabbitmq -p 5552:5552 -p 5672:5672 -p 15672:15672 \ -e RABBITMQ_SERVER_ADDITIONAL_ERL_ARGS='-rabbitmq_stream advertised_host localhost' \ rabb…