From e7ca8453c727b6fbdc70e31a63c447b71afe979d Mon Sep 17 00:00:00 2001 From: April M <36110273+aimurphy@users.noreply.github.com> Date: Fri, 23 Jan 2026 13:34:43 -0800 Subject: [PATCH 1/2] delete duplicate subscription topics --- modules/ROOT/nav.adoc | 7 +- .../astream-subscriptions-exclusive.adoc | 87 ----------- .../pages/astream-subscriptions-failover.adoc | 89 ----------- .../astream-subscriptions-keyshared.adoc | 143 ------------------ .../pages/astream-subscriptions-shared.adoc | 88 ----------- modules/subscriptions/pages/index.adoc | 30 ---- .../partials/subscription-prereq.adoc | 22 --- 7 files changed, 1 insertion(+), 465 deletions(-) delete mode 100644 modules/subscriptions/pages/astream-subscriptions-exclusive.adoc delete mode 100644 modules/subscriptions/pages/astream-subscriptions-failover.adoc delete mode 100644 modules/subscriptions/pages/astream-subscriptions-keyshared.adoc delete mode 100644 modules/subscriptions/pages/astream-subscriptions-shared.adoc delete mode 100644 modules/subscriptions/pages/index.adoc delete mode 100644 modules/subscriptions/partials/subscription-prereq.adoc diff --git a/modules/ROOT/nav.adoc b/modules/ROOT/nav.adoc index a77c655..c442c06 100644 --- a/modules/ROOT/nav.adoc +++ b/modules/ROOT/nav.adoc @@ -42,9 +42,4 @@ ** xref:functions:unwrap-key-value.adoc[] ** xref:functions:deploy-in-sink.adoc[] ** xref:functions:drop-fields.adoc[] -* Topic Subscriptions -** xref:subscriptions:index.adoc[] -** xref:subscriptions:astream-subscriptions-exclusive.adoc[] -** xref:subscriptions:astream-subscriptions-failover.adoc[] -** xref:subscriptions:astream-subscriptions-shared.adoc[] -** xref:subscriptions:astream-subscriptions-keyshared.adoc[] +* xref:astra-streaming:astream-subscriptions.adoc[Topic subscriptions] \ No newline at end of file diff --git a/modules/subscriptions/pages/astream-subscriptions-exclusive.adoc b/modules/subscriptions/pages/astream-subscriptions-exclusive.adoc deleted file mode 100644 index 7677cb1..0000000 --- a/modules/subscriptions/pages/astream-subscriptions-exclusive.adoc +++ /dev/null @@ -1,87 +0,0 @@ -= Exclusive subscriptions in {pulsar-reg} -:navtitle: Exclusive - -*Subscriptions* in {pulsar-reg} describe which consumers are consuming data from a topic and how they want to consume that data. + - -An *exclusive* subscription describes a basic publish-subscribe pattern where a *single consumer* subscribes to a *single topic* and consumes from it. + - -This document explains how to use {pulsar-short}'s exclusive subscription model to manage your topic consumption. - -include::partial$subscription-prereq.adoc[] - -[#example] -== Exclusive subscription example - -This example uses the `pulsarConsumer` object in `SimplePulsarConsumer.java` below. + - -[source,java] ----- -pulsarConsumer = pulsarClient.newConsumer(Schema.JSON(DemoBean.class)) - .topic("persistent://" - + conf.getTenantName() + "/" - + conf.getNamespace() + "/" - + conf.getTopicName()) - .startMessageIdInclusive() - .subscriptionInitialPosition(SubscriptionInitialPosition.Earliest) - .subscriptionName("SimplePulsarConsumer") - .subscribe(); ----- - -[NOTE] -==== -{pulsar-short} creates an exclusive subscription by default when no `subscriptionType` is declared. -==== - -. Open the `pulsar-subscription-example` repo in the IDE of your choice and run `SimplePulsarConsumer.java` to begin consuming messages. + -The confirmation message and a cursor appear to indicate the consumer is ready. -+ -[source,bash] ----- -[main] INFO com.datastax.pulsar.Configuration - Configuration has been loaded successfully -... -[pulsar-client-io-1-1] INFO org.apache.pulsar.client.impl.ConsumerImpl - [persistent:////in][SimplePulsarConsumer] Subscribed to topic on -- consumer: 0 ----- - -. In a new terminal window, run `SimplePulsarProducer.java` to begin producing messages. -+ -[source,bash] ----- -[main] INFO com.datastax.pulsar.SimplePulsarProducer - Message 93573631 sent -[main] INFO com.datastax.pulsar.SimplePulsarProducer - Message 16931522 sent -[main] INFO com.datastax.pulsar.SimplePulsarProducer - Message 68306175 sent ----- - -. The consumer begins consuming the produced messages. -+ -[source,bash] ----- -[main] INFO com.datastax.pulsar.SimplePulsarConsumer - Message received: {"show_id":93573631,"cast":"LeBron James, Anthony Davis, Kyrie Irving, Damian Lillard, Klay Thompson...","country":"United States","date_added":"July 16, 2021","description":"NBA superstar LeBron James teams up with Bugs Bunny and the rest of the Looney Tunes for this long-awaited sequel.","director":"Malcolm D. Lee","duration":"120 min","listed_in":"Animation, Adventure, Comedy","rating":"PG","release_year":2021,"title":"Space Jam: A New Legacy","type":"Movie"} -[main] INFO com.datastax.pulsar.SimplePulsarConsumer - Message received: {"show_id":16931522,"cast":"LeBron James, Anthony Davis, Kyrie Irving, Damian Lillard, Klay Thompson...","country":"United States","date_added":"July 16, 2021","description":"NBA superstar LeBron James teams up with Bugs Bunny and the rest of the Looney Tunes for this long-awaited sequel.","director":"Malcolm D. Lee","duration":"120 min","listed_in":"Animation, Adventure, Comedy","rating":"PG","release_year":2021,"title":"Space Jam: A New Legacy","type":"Movie"} -[main] INFO com.datastax.pulsar.SimplePulsarConsumer - Message received: {"show_id":68306175,"cast":"LeBron James, Anthony Davis, Kyrie Irving, Damian Lillard, Klay Thompson...","country":"United States","date_added":"July 16, 2021","description":"NBA superstar LeBron James teams up with Bugs Bunny and the rest of the Looney Tunes for this long-awaited sequel.","director":"Malcolm D. Lee","duration":"120 min","listed_in":"Animation, Adventure, Comedy","rating":"PG","release_year":2021,"title":"Space Jam: A New Legacy","type":"Movie"} ----- - -. Open a new terminal window and try to run `SimplePulsarConsumer.java`. -+ -[source,bash] ----- -[main] INFO com.datastax.pulsar.Configuration - Configuration has been loaded successfully -... -[main] INFO com.datastax.pulsar.SimplePulsarConsumer - SimplePulsarProducer has been stopped. -Exception in thread "main" java.lang.IllegalStateException: Cannot connect to pulsar - at com.datastax.pulsar.SimplePulsarConsumer.main(SimplePulsarConsumer.java:53) -Caused by: org.apache.pulsar.client.api.PulsarClientException$ConsumerBusyException: {"errorMsg":"Exclusive consumer is already connected","reqId":2964994443801550457, "remote":"", "local":"/192.168.0.95:55777"} ----- - -The second consumer cannot subscribe to the topic because the subscription is *exclusive*. + - -In the example above, the consumer didn't declare a subscription type, so {pulsar-short} created an exclusive subscription by default. + -To explicitly define an exclusive subscription, add `.subscriptionType(SubscriptionType.Exclusive)` to the consumer. - -== What's next - -For more on subscriptions, see: - -* xref:index.adoc[Subscriptions in {pulsar-short}] -* xref:astream-subscriptions-shared.adoc[Shared subscriptions] -* xref:astream-subscriptions-failover.adoc[Failover subscriptions] -* xref:astream-subscriptions-keyshared.adoc[Key_shared subscriptions] diff --git a/modules/subscriptions/pages/astream-subscriptions-failover.adoc b/modules/subscriptions/pages/astream-subscriptions-failover.adoc deleted file mode 100644 index bcd6e6c..0000000 --- a/modules/subscriptions/pages/astream-subscriptions-failover.adoc +++ /dev/null @@ -1,89 +0,0 @@ -= Failover subscriptions in {pulsar-reg} -:navtitle: Failover - -*Subscriptions* in {pulsar-reg} describe which consumers are consuming data from a topic and how they want to consume that data. + - -If an xref:astream-subscriptions-exclusive.adoc[exclusive] consumer fails, the topic backlog balloons with stale, unacknowledged messages. {pulsar-short} solves this problem with *failover* subscriptions. + -In *failover* subscriptions, {pulsar-short} designates one *primary* consumer and multiple *standby* consumers. If the primary consumer disconnects, the standby consumers begin consuming the subsequent unacknowledged messages. + - -This document explains how to use {pulsar-short}'s failover subscription model to manage your topic consumption. - -include::partial$subscription-prereq.adoc[] - -[#example] -== Failover subscription example - -To try out a {pulsar-short} failover subscription, add `.subscriptionType(SubscriptionType.Failover)` to the `pulsarConsumer` in `SimplePulsarConsumer.java`. - -[source,java] ----- -pulsarConsumer = pulsarClient.newConsumer(Schema.JSON(DemoBean.class)) - .topic("persistent://" - + conf.getTenantName() + "/" - + conf.getNamespace() + "/" - + conf.getTopicName()) - .startMessageIdInclusive() - .subscriptionInitialPosition(SubscriptionInitialPosition.Earliest) - .subscriptionName("SimplePulsarConsumer") - .subscriptionType(SubscriptionType.Failover) - .subscribe(); ----- - -. Open `pulsar-subscription-example` in the IDE of your choice and run `SimplePulsarConsumer.java` to begin consuming messages. + -This is the *primary* consumer. + -The confirmation message and a cursor appear to indicate the consumer is ready. -+ -[source,bash] ----- -[main] INFO com.datastax.pulsar.Configuration - Configuration has been loaded successfully -... -[pulsar-client-io-1-1] INFO org.apache.pulsar.client.impl.ConsumerImpl - [persistent:////in][SimplePulsarConsumer] Subscribed to topic on -- consumer: 0 ----- - -. In a new terminal window, run `SimplePulsarProducer.java` to begin producing messages. -+ -[source,bash] ----- -[main] INFO com.datastax.pulsar.SimplePulsarProducer - Message 50585599 sent -[main] INFO com.datastax.pulsar.SimplePulsarProducer - Message 98055337 sent -[main] INFO com.datastax.pulsar.SimplePulsarProducer - Message 36327100 sent -... -[main] INFO com.datastax.pulsar.SimplePulsarProducer - Message 73260535 sent -[main] INFO com.datastax.pulsar.SimplePulsarProducer - Message 42372149 sent ----- - -. The primary consumer begins consuming messages. -+ -[source,bash] ----- -[main] INFO com.datastax.pulsar.SimplePulsarConsumer - Message received: {"show_id":50585599,"cast":"LeBron James, Anthony Davis, Kyrie Irving, Damian Lillard, Klay Thompson...","country":"United States","date_added":"July 16, 2021","description":"NBA superstar LeBron James teams up with Bugs Bunny and the rest of the Looney Tunes for this long-awaited sequel.","director":"Malcolm D. Lee","duration":"120 min","listed_in":"Animation, Adventure, Comedy","rating":"PG","release_year":2021,"title":"Space Jam: A New Legacy","type":"Movie"} -[main] INFO com.datastax.pulsar.SimplePulsarConsumer - Message received: {"show_id":98055337,"cast":"LeBron James, Anthony Davis, Kyrie Irving, Damian Lillard, Klay Thompson...","country":"United States","date_added":"July 16, 2021","description":"NBA superstar LeBron James teams up with Bugs Bunny and the rest of the Looney Tunes for this long-awaited sequel.","director":"Malcolm D. Lee","duration":"120 min","listed_in":"Animation, Adventure, Comedy","rating":"PG","release_year":2021,"title":"Space Jam: A New Legacy","type":"Movie"} -[main] INFO com.datastax.pulsar.SimplePulsarConsumer - Message received: {"show_id":36327100,"cast":"LeBron James, Anthony Davis, Kyrie Irving, Damian Lillard, Klay Thompson...","country":"United States","date_added":"July 16, 2021","description":"NBA superstar LeBron James teams up with Bugs Bunny and the rest of the Looney Tunes for this long-awaited sequel.","director":"Malcolm D. Lee","duration":"120 min","listed_in":"Animation, Adventure, Comedy","rating":"PG","release_year":2021,"title":"Space Jam: A New Legacy","type":"Movie"} ----- - -. Open a new terminal window and run `SimplePulsarConsumer.java`. This is the *backup* consumer. The backup consumer subscribes to the topic, but does not immediately begin consuming messages. - -. Return to the *primary* consumer and `Ctrl+C` to stop it. The *backup* consumer begins consuming right where the first consumer left off. -+ -[source,bash] ----- -[main] INFO com.datastax.pulsar.SimplePulsarConsumer - Message received: {"show_id":73260535,"cast":"LeBron James, Anthony Davis, Kyrie Irving, Damian Lillard, Klay Thompson...","country":"United States","date_added":"July 16, 2021","description":"NBA superstar LeBron James teams up with Bugs Bunny and the rest of the Looney Tunes for this long-awaited sequel.","director":"Malcolm D. Lee","duration":"120 min","listed_in":"Animation, Adventure, Comedy","rating":"PG","release_year":2021,"title":"Space Jam: A New Legacy","type":"Movie"} -[main] INFO com.datastax.pulsar.SimplePulsarConsumer - Message received: {"show_id":42372149,"cast":"LeBron James, Anthony Davis, Kyrie Irving, Damian Lillard, Klay Thompson...","country":"United States","date_added":"July 16, 2021","description":"NBA superstar LeBron James teams up with Bugs Bunny and the rest of the Looney Tunes for this long-awaited sequel.","director":"Malcolm D. Lee","duration":"120 min","listed_in":"Animation, Adventure, Comedy","rating":"PG","release_year":2021,"title":"Space Jam: A New Legacy","type":"Movie"} ----- - -. You can repeat this process with as many primary and backup consumers as you want- the next message is delivered to the subscribed failover consumers. - -=== Failover subscription video - -Follow along with this video from our *Five Minutes About {pulsar-short}* series to see failover subscriptions in action. - -video::ckB87OLs5eM[youtube, list=PL2g2h-wyI4SqeKH16czlcQ5x4Q_z-X7_m, height=445px,width=100%] - -== What's next? - -For more on subscriptions, see: - -* xref:index.adoc[Subscriptions in {pulsar-short}] -* xref:astream-subscriptions-exclusive.adoc[Exclusive subscriptions] -* xref:astream-subscriptions-shared.adoc[Shared subscriptions] -* xref:astream-subscriptions-keyshared.adoc[Key_shared subscriptions] \ No newline at end of file diff --git a/modules/subscriptions/pages/astream-subscriptions-keyshared.adoc b/modules/subscriptions/pages/astream-subscriptions-keyshared.adoc deleted file mode 100644 index a3edc9f..0000000 --- a/modules/subscriptions/pages/astream-subscriptions-keyshared.adoc +++ /dev/null @@ -1,143 +0,0 @@ -= Key_Shared subscriptions in {pulsar-reg} -:navtitle: Key Shared - -*Subscriptions* in {pulsar-reg} describe which consumers are consuming data from a topic and how they want to consume that data. + - -{pulsar-short}'s xref:astream-subscriptions-shared.adoc[shared subscription] model trades an increased message processing rate for ordering guarantees. In a round-robin delivery, there's no way for the broker to know which messages are going to which consumer. + -*Key_Shared* subscriptions allow multiple consumers to subscribe to a topic, but with additional metadata in the form of *keys* which link messages to specific consumers. + -*Keys* are generated with *hashing*, which converts arbitrary values like "topic-name" or JSON blobs into fixed integer values. These hashed values are then assigned to subscribed consumers in one of two ways: - -* *Auto hash* - uses *consistent hashing* to balance range values across available consumers, without requiring manual setup of hash ranges. -* *Sticky hash* - the client manually assigns consumer range values. All hashes within a configured range go to one consumer. - -This document explains how to use {pulsar-short}'s Key_Shared subscription model to manage your topic consumption. - -include::partial$subscription-prereq.adoc[] - -[#example] -== Key_Shared subscription example - -To try out a {pulsar-short} Key_Shared subscription, add `.subscriptionType(SubscriptionType.Key_Shared)` to the `pulsarConsumer` in `SimplePulsarConsumer.java`. + -You must also tell {pulsar-short} what `keySharedPolicy` this subscription will use. The example below uses the auto-hashing `keySharedPolicy`. - -[source,java] ----- -pulsarConsumer = pulsarClient.newConsumer(Schema.JSON(DemoBean.class)) - .topic("persistent://" - + conf.getTenantName() + "/" - + conf.getNamespace() + "/" - + conf.getTopicName()) - .startMessageIdInclusive() - .subscriptionInitialPosition(SubscriptionInitialPosition.Earliest) - .subscriptionName("SimplePulsarConsumer") - .subscriptionType(SubscriptionType.Key_Shared) - .keySharedPolicy(KeySharedPolicy.autoSplitHashRange()) - .subscribe(); ----- - -Running multiple consumers with auto-hashing balances the messaging load across all available consumers. - -=== Manually set stickyHashRange - -You can manually set a hash range with `KeySharedPolicy.stickyHashRange()`. - -To test out sticky hashed Key_Shared subscriptions, you need to first import some additional classes. - -. Add the following classes to `SimplePulsarConsumer.java`: -+ -[source,java] ----- -import org.apache.pulsar.client.api.Range; -import org.apache.pulsar.client.api.KeySharedPolicy; -import org.apache.pulsar.client.api.SubscriptionType; ----- - -. Add the following classes to `SimplePulsarProducer.java`: -+ -[source,java] ----- -import org.apache.pulsar.client.api.BatcherBuilder; -import org.apache.pulsar.client.api.HashingScheme; ----- - -. Modify the `pulsarProducer` in `SimplePulsarProducer.java` to use the `JavaStringHash` hashing scheme. -+ -[source,java] ----- -pulsarProducer = pulsarClient - .newProducer(Schema.JSON(DemoBean.class)) - .topic("persistent://" - + conf.getTenantName() + "/" - + conf.getNamespace() + "/" - + conf.getTopicName()) - .batcherBuilder(BatcherBuilder.KEY_BASED) - .hashingScheme(HashingScheme.JavaStringHash) - .create(); ----- - -. Modify the `pulsarConsumer` in `SimplePulsarConsumer.java` to use sticky hashing. This example sets all possible hashes (0-65535) on this subscription to this consumer. -+ -[source,java] ----- -.subscriptionType(SubscriptionType.Key_Shared) -.keySharedPolicy(KeySharedPolicy.stickyHashRange().ranges(Range.of(0,65535))) ----- - -. Open `pulsar-examples` in the IDE of your choice and run `SimplePulsarConsumer.java` to begin consuming messages. + -The confirmation message and a cursor appear to indicate the consumer is ready. -+ -[source,bash] ----- -[main] INFO com.datastax.pulsar.Configuration - Configuration has been loaded successfully -... -[pulsar-client-io-1-1] INFO org.apache.pulsar.client.impl.ConsumerImpl - [persistent:////in][SimplePulsarConsumer] Subscribed to topic on -- consumer: 0 ----- - -. In a new terminal window, run `SimplePulsarProducer.java` to begin producing messages. -+ -[source,bash] ----- -[main] INFO com.datastax.pulsar.SimplePulsarProducer - Message 55794190 sent -[main] INFO com.datastax.pulsar.SimplePulsarProducer - Message 41791865 sent -[main] INFO com.datastax.pulsar.SimplePulsarProducer - Message 74840732 sent -[main] INFO com.datastax.pulsar.SimplePulsarProducer - Message 57467766 sent ----- - -. The consumer begins receiving messages. -+ -[source,bash] ----- -[main] INFO com.datastax.pulsar.SimplePulsarConsumer - Message received: {"show_id":55794190,"cast":"LeBron James, Anthony Davis, Kyrie Irving, Damian Lillard, Klay Thompson...","country":"United States","date_added":"July 16, 2021","description":"NBA superstar LeBron James teams up with Bugs Bunny and the rest of the Looney Tunes for this long-awaited sequel.","director":"Malcolm D. Lee","duration":"120 min","listed_in":"Animation, Adventure, Comedy","rating":"PG","release_year":2021,"title":"Space Jam: A New Legacy","type":"Movie"} -[main] INFO com.datastax.pulsar.SimplePulsarConsumer - Message received: {"show_id":41791865,"cast":"LeBron James, Anthony Davis, Kyrie Irving, Damian Lillard, Klay Thompson...","country":"United States","date_added":"July 16, 2021","description":"NBA superstar LeBron James teams up with Bugs Bunny and the rest of the Looney Tunes for this long-awaited sequel.","director":"Malcolm D. Lee","duration":"120 min","listed_in":"Animation, Adventure, Comedy","rating":"PG","release_year":2021,"title":"Space Jam: A New Legacy","type":"Movie"} ----- - -. Open a new terminal window and try to run `SimplePulsarConsumer.java`. -+ -[source,bash] ----- -[main] INFO com.datastax.pulsar.Configuration - Configuration has been loaded successfully -[main] INFO com.datastax.pulsar.SimplePulsarConsumer - SimplePulsarProducer has been stopped. -Exception in thread "main" java.lang.IllegalStateException: Cannot connect to pulsar - at com.datastax.pulsar.SimplePulsarConsumer.main(SimplePulsarConsumer.java:59) -Caused by: org.apache.pulsar.client.api.PulsarClientException$ConsumerAssignException: {"errorMsg":"Range conflict with consumer Consumer{subscription=PersistentSubscription{topic=persistent:////in, name=SimplePulsarConsumer}, consumerId=0, consumerName=5825b, address=/...}","reqId":1243883448178735299, "remote":"", "local":"/192.168.0.95:56512"} - at org.apache.pulsar.client.api.PulsarClientException.unwrap(PulsarClientException.java:1060) - at org.apache.pulsar.client.impl.ConsumerBuilderImpl.subscribe(ConsumerBuilderImpl.java:101) - at com.datastax.pulsar.SimplePulsarConsumer.main(SimplePulsarConsumer.java:47) ----- - -The new consumer cannot subscribe to the topic because you reserved the entire hash range for the first consumer. - -== Key_Shared subscription video - -Follow along with this video from our *Five Minutes About {pulsar-short}* series to see Key_Shared subscriptions in action. - -video::_49wlA53L_8[youtube, list=PL2g2h-wyI4SqeKH16czlcQ5x4Q_z-X7_m, height=445px,width=100%] - -== What's next? - -For more on subscriptions, see: - -* xref:index.adoc[Subscriptions in {pulsar-short}] -* xref:astream-subscriptions-exclusive.adoc[Exclusive subscriptions] -* xref:astream-subscriptions-shared.adoc[Shared subscriptions] -* xref:astream-subscriptions-failover.adoc[Failover subscriptions] \ No newline at end of file diff --git a/modules/subscriptions/pages/astream-subscriptions-shared.adoc b/modules/subscriptions/pages/astream-subscriptions-shared.adoc deleted file mode 100644 index 2d85077..0000000 --- a/modules/subscriptions/pages/astream-subscriptions-shared.adoc +++ /dev/null @@ -1,88 +0,0 @@ -= Shared subscriptions in {pulsar-reg} -:navtitle: Shared - -*Subscriptions* in {pulsar-reg} describe which consumers are consuming data from a topic and how they want to consume that data. + - -A *shared* subscription allows *multiple consumers* to consume messages from a *single topic* in round-robin fashion. + -More consumers in a shared subscription can increase your {pulsar-short} deployment's rate of message consumption, but at the cost of losing message ordering guarantees and acknowledgement schemes. - -This document explains how to use {pulsar-short}'s shared subscription model to manage your topic consumption. - -include::partial$subscription-prereq.adoc[] - -[#example] -== Shared subscription example - -To try out a {pulsar-short} shared subscription, add `.subscriptionType(SubscriptionType.Shared)` to the `pulsarConsumer` in `SimplePulsarConsumer.java`. - -[source,java] ----- -pulsarConsumer = pulsarClient.newConsumer(Schema.JSON(DemoBean.class)) - .topic("persistent://" - + conf.getTenantName() + "/" - + conf.getNamespace() + "/" - + conf.getTopicName()) - .startMessageIdInclusive() - .subscriptionInitialPosition(SubscriptionInitialPosition.Earliest) - .subscriptionName("SimplePulsarConsumer") - .subscriptionType(SubscriptionType.Shared) - .subscribe(); ----- - -. Open `pulsar-subscription-example` in the IDE of your choice and run `SimplePulsarConsumer.java` to begin consuming messages. + -The confirmation message and a cursor appear to indicate the consumer is ready. -+ -[source,bash] ----- -[main] INFO com.datastax.pulsar.Configuration - Configuration has been loaded successfully -... -[pulsar-client-io-1-1] INFO org.apache.pulsar.client.impl.ConsumerImpl - [persistent:////in][SimplePulsarConsumer] Subscribed to topic on -- consumer: 0 ----- - -. In a new terminal window, run `SimplePulsarProducer.java` to begin producing messages. -+ -[source,bash] ----- -[main] INFO com.datastax.pulsar.SimplePulsarProducer - Message 59819331 sent -[main] INFO com.datastax.pulsar.SimplePulsarProducer - Message 70129519 sent -[main] INFO com.datastax.pulsar.SimplePulsarProducer - Message 31365142 sent -[main] INFO com.datastax.pulsar.SimplePulsarProducer - Message 48206643 sent -[main] INFO com.datastax.pulsar.SimplePulsarProducer - Message 51277375 sent ----- - -. The consumer begins receiving messages. -+ -[source,bash] ----- -[main] INFO com.datastax.pulsar.SimplePulsarConsumer - Message received: {"show_id":59819331,"cast":"LeBron James, Anthony Davis, Kyrie Irving, Damian Lillard, Klay Thompson...","country":"United States","date_added":"July 16, 2021","description":"NBA superstar LeBron James teams up with Bugs Bunny and the rest of the Looney Tunes for this long-awaited sequel.","director":"Malcolm D. Lee","duration":"120 min","listed_in":"Animation, Adventure, Comedy","rating":"PG","release_year":2021,"title":"Space Jam: A New Legacy","type":"Movie"} -[main] INFO com.datastax.pulsar.SimplePulsarConsumer - Message received: {"show_id":31365142,"cast":"LeBron James, Anthony Davis, Kyrie Irving, Damian Lillard, Klay Thompson...","country":"United States","date_added":"July 16, 2021","description":"NBA superstar LeBron James teams up with Bugs Bunny and the rest of the Looney Tunes for this long-awaited sequel.","director":"Malcolm D. Lee","duration":"120 min","listed_in":"Animation, Adventure, Comedy","rating":"PG","release_year":2021,"title":"Space Jam: A New Legacy","type":"Movie"} -[main] INFO com.datastax.pulsar.SimplePulsarConsumer - Message received: {"show_id":51277375,"cast":"LeBron James, Anthony Davis, Kyrie Irving, Damian Lillard, Klay Thompson...","country":"United States","date_added":"July 16, 2021","description":"NBA superstar LeBron James teams up with Bugs Bunny and the rest of the Looney Tunes for this long-awaited sequel.","director":"Malcolm D. Lee","duration":"120 min","listed_in":"Animation, Adventure, Comedy","rating":"PG","release_year":2021,"title":"Space Jam: A New Legacy","type":"Movie"} ----- - -. Open a new terminal window and run `SimplePulsarConsumer.java`. The new consumer subscribes to the topic and consumes a message. -+ -[source,bash] ----- -[main] INFO com.datastax.pulsar.SimplePulsarConsumer - Message received: {"show_id":70129519,"cast":"LeBron James, Anthony Davis, Kyrie Irving, Damian Lillard, Klay Thompson...","country":"United States","date_added":"July 16, 2021","description":"NBA superstar LeBron James teams up with Bugs Bunny and the rest of the Looney Tunes for this long-awaited sequel.","director":"Malcolm D. Lee","duration":"120 min","listed_in":"Animation, Adventure, Comedy","rating":"PG","release_year":2021,"title":"Space Jam: A New Legacy","type":"Movie"} -[main] INFO com.datastax.pulsar.SimplePulsarConsumer - Message received: {"show_id":48206643,"cast":"LeBron James, Anthony Davis, Kyrie Irving, Damian Lillard, Klay Thompson...","country":"United States","date_added":"July 16, 2021","description":"NBA superstar LeBron James teams up with Bugs Bunny and the rest of the Looney Tunes for this long-awaited sequel.","director":"Malcolm D. Lee","duration":"120 min","listed_in":"Animation, Adventure, Comedy","rating":"PG","release_year":2021,"title":"Space Jam: A New Legacy","type":"Movie"} ----- - -. Open as many terminals as you'd like and run `SimplePulsarConsumer.java`. All the consumers subscribe to the topic and consume messages in a round-robin fashion. - -If you run this test with xref:astream-subscriptions-exclusive.adoc[exclusive subscriptions], you cannot attach more than once subscriber to the exclusive topic. -Since this test uses shared subscriptions, you can attach multiple consumers to the topic. - -== Shared subscription video - -Follow along with this video from our *Five Minutes About {pulsar-short}* series to see shared subscriptions in action. - -video::mmukXqGsauA[youtube, list=PL2g2h-wyI4SqeKH16czlcQ5x4Q_z-X7_m, height=445px,width=100%] - -== What's next? - -For more on subscriptions, see: - -* xref:index.adoc[Subscriptions in {pulsar-short}] -* xref:astream-subscriptions-exclusive.adoc[Exclusive subscriptions] -* xref:astream-subscriptions-failover.adoc[Failover subscriptions] -* xref:astream-subscriptions-keyshared.adoc[Key_shared subscriptions] diff --git a/modules/subscriptions/pages/index.adoc b/modules/subscriptions/pages/index.adoc deleted file mode 100644 index 1d6e4c6..0000000 --- a/modules/subscriptions/pages/index.adoc +++ /dev/null @@ -1,30 +0,0 @@ -= Subscriptions in {pulsar-reg} -:navtitle: Overview - -*Subscriptions* in {pulsar-reg} describe which consumers are consuming data from a topic and how they want to consume that data. + - -Subscriptions are managed in the broker as a collection of metadata about a topic and its subscribed consumers. This metadata includes: - -* Topic name - which topic the consumer wants data from -* Subscription name - a string representing a qualified name for the subscription -* Subscription type - which type of subscription is being used -* Subscription cursor - a representation of the consumer's current place in the subscribed topic log - -For example, the {pulsar-short} consumer below has a *shared* subscription starting at the *earliest* cursor position in `my-subscription` to `my-topic`: - -[source,java] ----- -pulsarConsumer = pulsarClient.newConsumer(Schema.BYTES) - .topic("my-topic") - .subscriptionName("my-subscription") - .subscriptionType(SubscriptionType.Shared) - .subscriptionInitialPosition(SubscriptionInitialPosition.Earliest) - .subscribe(); ----- - -Read on to use {pulsar-short}'s four types of subscriptions to manage your topic consumption. - -* xref:astream-subscriptions-exclusive.adoc[Exclusive subscriptions] -* xref:astream-subscriptions-shared.adoc[Shared subscriptions] -* xref:astream-subscriptions-failover.adoc[Failover subscriptions] -* xref:astream-subscriptions-keyshared.adoc[Key_shared subscriptions] diff --git a/modules/subscriptions/partials/subscription-prereq.adoc b/modules/subscriptions/partials/subscription-prereq.adoc deleted file mode 100644 index f5070da..0000000 --- a/modules/subscriptions/partials/subscription-prereq.adoc +++ /dev/null @@ -1,22 +0,0 @@ -== Prerequisites - -To run this example, you'll need: - -* https://maven.apache.org/install.html[Apache Maven] - -* https://openjdk.java.net/install/[Java OpenJDK 11] - -* A configured Astra Streaming instance with at least one streaming tenant and one topic. See the xref:astra-streaming:getting-started:index.adoc[Astra Streaming quick start] for instructions. - -* A local clone of the https://github.com/datastax/pulsar-subscription-example[{company} {pulsar-short} Subscription Example repository] - -* Modify the `src/main/resources/application.properties` in the `pulsar-subscription-example` repo to connect to your Astra Streaming cluster, as below: -+ -[source,bash] ----- -service_url={broker-service-url} -namespace=default -tenant_name=my-tenant -authentication_token={astra-auth-token} -topic_name=my-topic ----- \ No newline at end of file From 16e1b7f4c4c57c0cee17f21d5a8ff2dea931b5a2 Mon Sep 17 00:00:00 2001 From: April M <36110273+aimurphy@users.noreply.github.com> Date: Fri, 23 Jan 2026 13:40:51 -0800 Subject: [PATCH 2/2] fix xref --- modules/ROOT/nav.adoc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/ROOT/nav.adoc b/modules/ROOT/nav.adoc index c442c06..df6fd49 100644 --- a/modules/ROOT/nav.adoc +++ b/modules/ROOT/nav.adoc @@ -42,4 +42,4 @@ ** xref:functions:unwrap-key-value.adoc[] ** xref:functions:deploy-in-sink.adoc[] ** xref:functions:drop-fields.adoc[] -* xref:astra-streaming:astream-subscriptions.adoc[Topic subscriptions] \ No newline at end of file +* xref:astra-streaming:ROOT:astream-subscriptions.adoc[Topic subscriptions] \ No newline at end of file