⚠ This page is served via a proxy. Original site: https://github.com
This service does not collect credentials or authentication data.
Skip to content

Conversation

@artur-ciocanu
Copy link
Contributor

Description

Adding raw event subscription alongside CloudEvent subscription

Issue reference

We strive to have all PR being opened based on an issue, where the problem or feature have been discussed prior to implementation.

Please reference the issue this PR will close: #1616

Checklist

Please make sure you've completed the relevant tasks for this PR, out of the following list:

  • Code compiles correctly
  • Created/updated tests
  • Extended the documentation

@artur-ciocanu artur-ciocanu requested review from a team as code owners January 10, 2026 07:51
@artur-ciocanu
Copy link
Contributor Author

@dapr/approvers-java-sdk and @dapr/maintainers-java-sdk could you please take a look and approve. This has been requested by @alicejgibbons.

One thing I want to mention, I am not really fond of the new name subscribeToEventsData(...) I couldn't think of a better name.

An alternative would be to rename the old method to subscribeToCloudEvents(...) that uses CloudEvent and then have subscribeToEvents(...) return generic type.

@javier-aliaga
Copy link
Contributor

@dapr/approvers-java-sdk and @dapr/maintainers-java-sdk could you please take a look and approve. This has been requested by @alicejgibbons.

One thing I want to mention, I am not really fond of the new name subscribeToEventsData(...) I couldn't think of a better name.

An alternative would be to rename the old method to subscribeToCloudEvents(...) that uses CloudEvent and then have subscribeToEvents(...) return generic type.

Another possibility is naming the new one SubscribeToRawEvent or similar

javier-aliaga
javier-aliaga previously approved these changes Jan 11, 2026
siri-varma
siri-varma previously approved these changes Jan 11, 2026
@alicejgibbons
Copy link

Regardinging renaming, can we have multiple overloads to subscribeToEvents?

@artur-ciocanu
Copy link
Contributor Author

Regardinging renaming, can we have multiple overloads to subscribeToEvents?

@alicejgibbons unfortunately we can not have the same overloads that depends just on generic type.

@alicejgibbons as I was thinking more and more. Instead of coming up with different APIs, customers can leverage Flux via a simple map operator. It is trivial:

Flux<SomeEvent> stream = daprClient.subscribeToEvents(pubsubName, topic, type)
        .map(CloudEvent::getData);

It is an additional step, but it is not too bad.

Please let me know your thoughts.

CC: @javier-aliaga @cicoyle

@artur-ciocanu artur-ciocanu force-pushed the generic-type-subscriptions branch from b4601a8 to e5dc0ec Compare January 15, 2026 02:41
@artur-ciocanu
Copy link
Contributor Author

@alicejgibbons @cicoyle @javier-aliaga I went a different route, since this is not released yet, I think a breaking change is OK.

The final API is the following:

<T> Flux<T> subscribeToEvents(String pubsubName, String topic, TypeRef<T> type);

<T> Flux<T> subscribeToEvents(String pubsubName, String topic, TypeRef<T> type, Map<String, String> metadata);

There are different examples in the integrations tests for raw payload and CloudEvent.

Let me know your thoughts.

@javier-aliaga
Copy link
Contributor

@alicejgibbons @cicoyle @javier-aliaga I went a different route, since this is not released yet, I think a breaking change is OK.

The final API is the following:

<T> Flux<T> subscribeToEvents(String pubsubName, String topic, TypeRef<T> type);

<T> Flux<T> subscribeToEvents(String pubsubName, String topic, TypeRef<T> type, Map<String, String> metadata);

There are different examples in the integrations tests for raw payload and CloudEvent.

Let me know your thoughts.

Looks good to me, it feels more simple.

Copy link
Contributor

@cicoyle cicoyle left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you review the tests bc CI is failing with:

Error:  Errors: 
Error:    PubSubStreamIT.testPubSub:115 » Runtime org.opentest4j.AssertionFailedError: expected: <100> but was: <95>
Error:    PubSubStreamIT.testPubSubCloudEvent:207 » Runtime org.opentest4j.AssertionFailedError: expected: <100> but was: <0>

Signed-off-by: Artur Ciocanu <[email protected]>
Signed-off-by: Artur Ciocanu <[email protected]>
@codecov
Copy link

codecov bot commented Jan 16, 2026

Codecov Report

❌ Patch coverage is 90.00000% with 3 lines in your changes missing coverage. Please review.
✅ Project coverage is 78.93%. Comparing base (d759c53) to head (c73c3a4).
⚠️ Report is 249 commits behind head on master.

Files with missing lines Patch % Lines
...al/subscription/EventSubscriberStreamObserver.java 92.00% 0 Missing and 2 partials ⚠️
...k/src/main/java/io/dapr/client/DaprClientImpl.java 80.00% 0 Missing and 1 partial ⚠️
Additional details and impacted files
@@             Coverage Diff              @@
##             master    #1617      +/-   ##
============================================
+ Coverage     76.91%   78.93%   +2.02%     
- Complexity     1592     2083     +491     
============================================
  Files           145      227      +82     
  Lines          4843     6277    +1434     
  Branches        562      692     +130     
============================================
+ Hits           3725     4955    +1230     
- Misses          821      970     +149     
- Partials        297      352      +55     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@artur-ciocanu
Copy link
Contributor Author

@cicoyle @alicejgibbons and @javier-aliaga the PR is looking good and the build is 🟢.

Could you please take another look. Thank you.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Flux Streaming subscriptions with generic type

5 participants