diff --git a/examples/src/main/java/io/dapr/examples/pubsub/stream/README.md b/examples/src/main/java/io/dapr/examples/pubsub/stream/README.md index 7916f6278..c31607f75 100644 --- a/examples/src/main/java/io/dapr/examples/pubsub/stream/README.md +++ b/examples/src/main/java/io/dapr/examples/pubsub/stream/README.md @@ -56,8 +56,8 @@ public class Subscriber { public static void main(String[] args) throws Exception { try (var client = new DaprClientBuilder().buildPreviewClient()) { - // Subscribe to events - receives raw String data directly - client.subscribeToEvents(PUBSUB_NAME, topicName, TypeRef.STRING) + // Subscribe to topic - receives raw String data directly + client.subscribeToTopic(PUBSUB_NAME, topicName, TypeRef.STRING) .doOnNext(message -> { System.out.println("Subscriber got: " + message); }) @@ -79,8 +79,8 @@ public class SubscriberCloudEvent { public static void main(String[] args) throws Exception { try (var client = new DaprClientBuilder().buildPreviewClient()) { - // Subscribe to events - receives CloudEvent with full metadata - client.subscribeToEvents(PUBSUB_NAME, topicName, new TypeRef>() {}) + // Subscribe to topic - receives CloudEvent with full metadata + client.subscribeToTopic(PUBSUB_NAME, topicName, new TypeRef>() {}) .doOnNext(cloudEvent -> { System.out.println("Received CloudEvent:"); System.out.println(" ID: " + cloudEvent.getId()); @@ -101,7 +101,7 @@ public class SubscriberCloudEvent { You can also pass metadata to the subscription, for example to enable raw payload mode: ```java -client.subscribeToEvents(PUBSUB_NAME, topicName, TypeRef.STRING, Map.of("rawPayload", "true")) +client.subscribeToTopic(PUBSUB_NAME, topicName, TypeRef.STRING, Map.of("rawPayload", "true")) .doOnNext(message -> { System.out.println("Subscriber got: " + message); }) diff --git a/examples/src/main/java/io/dapr/examples/pubsub/stream/Subscriber.java b/examples/src/main/java/io/dapr/examples/pubsub/stream/Subscriber.java index 59be7beb2..e9456dc24 100644 --- a/examples/src/main/java/io/dapr/examples/pubsub/stream/Subscriber.java +++ b/examples/src/main/java/io/dapr/examples/pubsub/stream/Subscriber.java @@ -47,8 +47,8 @@ public static void main(String[] args) throws Exception { try (var client = new DaprClientBuilder().buildPreviewClient()) { System.out.println("Subscribing to topic: " + topicName); - // Subscribe to events - receives raw String data directly - client.subscribeToEvents(PUBSUB_NAME, topicName, TypeRef.STRING) + // Subscribe to topic - receives raw String data directly + client.subscribeToTopic(PUBSUB_NAME, topicName, TypeRef.STRING) .doOnNext(message -> { System.out.println("Subscriber got: " + message); }) diff --git a/examples/src/main/java/io/dapr/examples/pubsub/stream/SubscriberCloudEvent.java b/examples/src/main/java/io/dapr/examples/pubsub/stream/SubscriberCloudEvent.java index a76603fdb..5f52d51d0 100644 --- a/examples/src/main/java/io/dapr/examples/pubsub/stream/SubscriberCloudEvent.java +++ b/examples/src/main/java/io/dapr/examples/pubsub/stream/SubscriberCloudEvent.java @@ -50,9 +50,9 @@ public static void main(String[] args) throws Exception { try (var client = new DaprClientBuilder().buildPreviewClient()) { System.out.println("Subscribing to topic: " + topicName + " (CloudEvent mode)"); - // Subscribe to events - receives CloudEvent with full metadata + // Subscribe to topic - receives CloudEvent with full metadata // Use TypeRef> to get CloudEvent wrapper with metadata - client.subscribeToEvents(PUBSUB_NAME, topicName, new TypeRef>() {}) + client.subscribeToTopic(PUBSUB_NAME, topicName, new TypeRef>() {}) .doOnNext(cloudEvent -> { System.out.println("Received CloudEvent:"); System.out.println(" ID: " + cloudEvent.getId()); diff --git a/sdk-tests/src/test/java/io/dapr/it/pubsub/stream/PubSubStreamIT.java b/sdk-tests/src/test/java/io/dapr/it/pubsub/stream/PubSubStreamIT.java index a1d1b4fe3..334bc5232 100644 --- a/sdk-tests/src/test/java/io/dapr/it/pubsub/stream/PubSubStreamIT.java +++ b/sdk-tests/src/test/java/io/dapr/it/pubsub/stream/PubSubStreamIT.java @@ -151,8 +151,8 @@ public void testPubSubFlux() throws Exception { Set messages = Collections.synchronizedSet(new HashSet<>()); - // subscribeToEvents now returns Flux directly (raw data) - var disposable = previewClient.subscribeToEvents(PUBSUB_NAME, TOPIC_NAME_FLUX, TypeRef.STRING) + // subscribeToTopic returns Flux directly (raw data) + var disposable = previewClient.subscribeToTopic(PUBSUB_NAME, TOPIC_NAME_FLUX, TypeRef.STRING) .doOnNext(rawMessage -> { // rawMessage is String directly if (rawMessage.contains(runId)) { @@ -196,7 +196,7 @@ public void testPubSubCloudEvent() throws Exception { Set messageIds = Collections.synchronizedSet(new HashSet<>()); // Use TypeRef> to receive full CloudEvent with metadata - var disposable = previewClient.subscribeToEvents(PUBSUB_NAME, TOPIC_NAME_CLOUDEVENT, new TypeRef>(){}) + var disposable = previewClient.subscribeToTopic(PUBSUB_NAME, TOPIC_NAME_CLOUDEVENT, new TypeRef>(){}) .doOnNext(cloudEvent -> { if (cloudEvent.getData() != null && cloudEvent.getData().contains(runId)) { messageIds.add(cloudEvent.getId()); @@ -241,8 +241,8 @@ public void testPubSubRawPayload() throws Exception { Set messages = Collections.synchronizedSet(new HashSet<>()); Map metadata = Map.of("rawPayload", "true"); - // Use subscribeToEvents with rawPayload metadata - var disposable = previewClient.subscribeToEvents(PUBSUB_NAME, TOPIC_NAME_RAWPAYLOAD, TypeRef.STRING, metadata) + // Use subscribeToTopic with rawPayload metadata + var disposable = previewClient.subscribeToTopic(PUBSUB_NAME, TOPIC_NAME_RAWPAYLOAD, TypeRef.STRING, metadata) .doOnNext(rawMessage -> { if (rawMessage.contains(runId)) { messages.add(rawMessage); diff --git a/sdk/src/main/java/io/dapr/client/DaprClientImpl.java b/sdk/src/main/java/io/dapr/client/DaprClientImpl.java index f36b59c68..6ef975c52 100644 --- a/sdk/src/main/java/io/dapr/client/DaprClientImpl.java +++ b/sdk/src/main/java/io/dapr/client/DaprClientImpl.java @@ -482,15 +482,15 @@ public Subscription subscribeToEvents( * {@inheritDoc} */ @Override - public Flux subscribeToEvents(String pubsubName, String topic, TypeRef type) { - return subscribeToEvents(pubsubName, topic, type, null); + public Flux subscribeToTopic(String pubsubName, String topic, TypeRef type) { + return subscribeToTopic(pubsubName, topic, type, null); } /** * {@inheritDoc} */ @Override - public Flux subscribeToEvents(String pubsubName, String topic, TypeRef type, Map metadata) { + public Flux subscribeToTopic(String pubsubName, String topic, TypeRef type, Map metadata) { DaprProtos.SubscribeTopicEventsRequestInitialAlpha1.Builder initialRequestBuilder = DaprProtos.SubscribeTopicEventsRequestInitialAlpha1.newBuilder() .setTopic(topic) diff --git a/sdk/src/main/java/io/dapr/client/DaprPreviewClient.java b/sdk/src/main/java/io/dapr/client/DaprPreviewClient.java index fa4a1eb9b..e8124e4f7 100644 --- a/sdk/src/main/java/io/dapr/client/DaprPreviewClient.java +++ b/sdk/src/main/java/io/dapr/client/DaprPreviewClient.java @@ -277,7 +277,7 @@ Mono> publishEvents(String pubsubName, String topicNa * @param type Type for object deserialization. * @param Type of object deserialization. * @return An active subscription. - * @deprecated Use {@link #subscribeToEvents(String, String, TypeRef)} instead for a more reactive approach. + * @deprecated Use {@link #subscribeToTopic(String, String, TypeRef)} instead for a more reactive approach. */ @Deprecated Subscription subscribeToEvents( @@ -298,12 +298,12 @@ Subscription subscribeToEvents( * @return A Flux of deserialized event payloads. * @param Type of the event payload. */ - Flux subscribeToEvents(String pubsubName, String topic, TypeRef type); + Flux subscribeToTopic(String pubsubName, String topic, TypeRef type); /** * Subscribe to pubsub events via streaming using Project Reactor Flux with metadata support. * - *

If metadata is null or empty, this method delegates to {@link #subscribeToEvents(String, String, TypeRef)}. + *

If metadata is null or empty, this method delegates to {@link #subscribeToTopic(String, String, TypeRef)}. * Use metadata {@code {"rawPayload": "true"}} for raw payload subscriptions where Dapr * delivers messages without CloudEvent wrapping. * @@ -314,7 +314,7 @@ Subscription subscribeToEvents( * @return A Flux of deserialized event payloads. * @param Type of the event payload. */ - Flux subscribeToEvents(String pubsubName, String topic, TypeRef type, Map metadata); + Flux subscribeToTopic(String pubsubName, String topic, TypeRef type, Map metadata); /* * Converse with an LLM. diff --git a/sdk/src/test/java/io/dapr/client/DaprPreviewClientGrpcTest.java b/sdk/src/test/java/io/dapr/client/DaprPreviewClientGrpcTest.java index dff71794e..dfc82cbf7 100644 --- a/sdk/src/test/java/io/dapr/client/DaprPreviewClientGrpcTest.java +++ b/sdk/src/test/java/io/dapr/client/DaprPreviewClientGrpcTest.java @@ -640,8 +640,8 @@ public void onCompleted() { final AtomicInteger eventCount = new AtomicInteger(0); final Semaphore gotAll = new Semaphore(0); - // subscribeToEvents now returns Flux directly (raw data) - var disposable = previewClient.subscribeToEvents(pubsubName, topicName, TypeRef.STRING) + // subscribeToTopic returns Flux directly (raw data) + var disposable = previewClient.subscribeToTopic(pubsubName, topicName, TypeRef.STRING) .doOnNext(rawData -> { // rawData is String directly, not CloudEvent assertEquals(data, rawData); @@ -728,8 +728,8 @@ public void onCompleted() { final Semaphore gotAll = new Semaphore(0); Map metadata = Map.of("rawPayload", "true"); - // Use subscribeToEvents with rawPayload metadata - var disposable = previewClient.subscribeToEvents(pubsubName, topicName, TypeRef.STRING, metadata) + // Use subscribeToTopic with rawPayload metadata + var disposable = previewClient.subscribeToTopic(pubsubName, topicName, TypeRef.STRING, metadata) .doOnNext(rawData -> { assertEquals(data, rawData); assertTrue(rawData instanceof String);