Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Is there a way to subscribe to topic and get data #8

Closed
blublinsky opened this issue Oct 22, 2019 · 19 comments
Closed

Is there a way to subscribe to topic and get data #8

blublinsky opened this issue Oct 22, 2019 · 19 comments
Labels
question Further information is requested

Comments

@blublinsky
Copy link

Ask your question here

An example here shows how to publish event, but provides no information on how to subscribe and receive events?
I can see Node and Python examples at https://github.com/dapr/samples/tree/master/4.pub-sub,
But they are not easily transferable to java

@amanbha
Copy link
Contributor

amanbha commented Oct 22, 2019

@blublinsky The subscription in dapr is similar across all languages:
Dapr will call into the app over http or grpc.

  1. The app should have a /subscribe route which will return a json list of Topics it wants to subscribe to (https://github.com/dapr/docs/blob/master/reference/api/pubsub.md#handling-topic-subscriptions)
    2 Lets say, the app subscribes to 2 topics: Deposit & Withdraw, then the app also needs to have 2 routes on /Deposit & /Withdraw to recieve the events for the subscribed topics, (https://github.com/dapr/docs/blob/master/reference/api/pubsub.md#delivering-events-to-subscribers)

@blublinsky
Copy link
Author

Thanks @amanbha.
It is a bit confusing, because publish is a GRPC API, but subscribe is not. Why is it asymmetric?
I see some of the methods for subscribe are in GRPCClient, but they seem not been implemented .
Am I missing something?

@amanbha
Copy link
Contributor

amanbha commented Oct 23, 2019

Thanks @amanbha.
It is a bit confusing, because publish is a GRPC API, but subscribe is not. Why is it asymmetric?
I see some of the methods for subscribe are in GRPCClient, but they seem not been implemented .
Am I missing something?

@blublinsky I understand the confusion, allow me to explain a bit more. User App and Dapr can interact with each other over gRPC or HTTP. The Java SDK is autogenerated from the proto files of gRPC apis in Dapr runtime.
You can also make http calls directly to publish the events to a topic

There is an HTTP and gRPC server running in Dapr runtime and your app acts as a client when making calls to it (so it can make calls over http or gRPC). When Dapr needs to call into your app over HTTP or gRPC, you need to have a HTTP or gRPC server running in your app. The examples which I gave you earlier explained about doing it over HTTP(your app running an HTTP server). You can do similar things over gRPC(your app running as gRPC server) as well.

@blublinsky
Copy link
Author

Thanks @amanbha.
Did some more experiments. I finally realized that DaprClient.proto defines an interface that I need to implement to respond to Dapr requests. The issue that I am getting into with this approach is that I need 2 GRPC channels one for invoking DAPR and one for responding to DAPR request.
Is there a way to tell DAPR environment to use these 2 channels, defining which one to use for what?

@blublinsky
Copy link
Author

After more experimentations, it looks like, the right configuration is:
dapr run --app-id scalaTest --grpc-port 50001 --app-port 50002 --protocol grpc --port 3500 -- sbt run,
but it does not work -
Caused by: io.netty.channel.AbstractChannel$AnnotatedConnectException: Connection refused: localhost/0:0:0:0:0:0:0:1:50001
If I remove
--app-port 50002 --protocol grpc
DAPR obviously does not know how to access my app.
So it looks like 2 GRCP channels are not supported

@amanbha
Copy link
Contributor

amanbha commented Oct 23, 2019

@blublinsky The command looks correct, when you provide the --protocol grpc flag, the app-port is treated as gRPC port. There will be 2 channels, App-> Dapr(Dapr runtime listening on port 50001) & Dapr->app(App listening on port 50002). It should have worked.
cc @yaron2 & @youngbupark for further help.

@blublinsky
Copy link
Author

I can provide a project if this will help

@amanbha
Copy link
Contributor

amanbha commented Oct 23, 2019

I can provide a project if this will help

Thanks @blublinsky , that would be very helpful.

@blublinsky
Copy link
Author

dapr.zip
Uploaded

@blublinsky
Copy link
Author

Its Scala, not Java, but should be the same

@blublinsky
Copy link
Author

blublinsky commented Oct 23, 2019

With more experiments it looks like Dapr currently does not support bidirectional communications with an applications. I tried to use HTTP to talk to Darp instead of GRPC, but with the same result.
Additionally, once this is fixed, feel free to use this example as scala APIs

@yaron2
Copy link
Member

yaron2 commented Oct 23, 2019

Hey @blublinsky , in order for Dapr to talk to your app via gRPC, your app needs to implement the daprclient service.
For Java/Scala, that would be:

https://github.com/dapr/java-sdk/blob/master/src/main/java/io/dapr/DaprClientProtos.java

See this document on how to use gRPC and Dapr:
https://github.com/dapr/docs/tree/master/howto/create-grpc-app

@blublinsky
Copy link
Author

Its implemented, take a look at the code provided and works by itself.
The issue is that bidirectional communications do not work. I can either talk to runtime or receive runtime messages, but not both in the same app

@yaron2
Copy link
Member

yaron2 commented Oct 23, 2019

In gRPC bidirectional communications implies a streaming nature, but that's just a design decision.

For example, Dapr will call your app on the GetTopicSubscriptions method to get your topic subscriptions, and then when a message comes it will call you via OnTopicEvent.

Regardless, you could publish a message by invoking Dapr over gRPC with the PublishEvent method.

@blublinsky
Copy link
Author

But it does not work. Please, take a look at enclosed code. I might be missing something,but I am creating two channels - one for listening on Dapr and one for accessing Dapr. each channel works by itself, but both in one app fail

@yaron2
Copy link
Member

yaron2 commented Oct 23, 2019

Yeah I'll take a look and report back.

@blublinsky
Copy link
Author

@yaron2 any feedback on this?
Also, is there are example of using Actors?

@artursouza
Copy link
Member

artursouza commented Dec 11, 2019

We are actively working on the Java-SDK now. We do have examples in this repo now:

https://github.com/dapr/java-sdk

For the WIP on the Java-SDK, follow https://github.com/dapr/java-sdk/tree/java_sdk_wip

@artursouza artursouza added the question Further information is requested label Dec 11, 2019
@artursouza
Copy link
Member

artursouza commented Jan 30, 2020

mukundansundar added a commit that referenced this issue Sep 13, 2023
* Add ElementType.Type to ActorType (#812)

Signed-off-by: LionTao <[email protected]>

Signed-off-by: LionTao <[email protected]>
Co-authored-by: Mukundan Sundararajan <[email protected]>
Co-authored-by: Artur Souza <[email protected]>
Signed-off-by: Mahmut Canga <[email protected]>

* Bump codecov/codecov-action from 3.1.0 to 3.1.1 (#788)

Bumps [codecov/codecov-action](https://github.com/codecov/codecov-action) from 3.1.0 to 3.1.1.
- [Release notes](https://github.com/codecov/codecov-action/releases)
- [Changelog](https://github.com/codecov/codecov-action/blob/master/CHANGELOG.md)
- [Commits](codecov/codecov-action@v3.1.0...v3.1.1)

---
updated-dependencies:
- dependency-name: codecov/codecov-action
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <[email protected]>

Signed-off-by: dependabot[bot] <[email protected]>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: Artur Souza <[email protected]>
Signed-off-by: Mahmut Canga <[email protected]>

* Update springboot to latest minor.patch version. (#826)

Signed-off-by: Mahmut Canga <[email protected]>

* Use runtime 1.10.0-rc.X and CLI 1.10.0-rc.X (#827)

Signed-off-by: Artur Souza <[email protected]>
Signed-off-by: Mahmut Canga <[email protected]>

* Upgrade the version to 1.9.0-SNAPSHOT (#829)

Signed-off-by: Artur Souza <[email protected]>
Signed-off-by: Mahmut Canga <[email protected]>

* Generate updated javadocs for 1.8.0 (#836)

Signed-off-by: Artur Souza <[email protected]>
Signed-off-by: Mahmut Canga <[email protected]>

* Update Dapr runtime and CLI to 1.10. (#837)

Signed-off-by: Artur Souza <[email protected]>
Signed-off-by: Mahmut Canga <[email protected]>

* Inject autoconfiguration in the Spring Boot 3 style (#831)

* Bump from spring boot 2.3.5.RELEASE to 2.7.8

Signed-off-by: Sergio <[email protected]>
(cherry picked from commit 9152c91)

* Ensure old versions of spring boot are still compatible

Signed-off-by: Sergio <[email protected]>

---------

Signed-off-by: champel <[email protected]>
Signed-off-by: Sergio <[email protected]>
Signed-off-by: Mahmut Canga <[email protected]>

* Bump from reactor 2.3.5.RELEASE to 2.7.8 (#830)

* Bump from reactor 2.3.5.RELEASE to 2.7.8

Signed-off-by: Sergio <[email protected]>

* Simplification

Signed-off-by: Sergio <[email protected]>

---------

Signed-off-by: Sergio <[email protected]>
Signed-off-by: Mahmut Canga <[email protected]>

* Test multiple reminder state types + improve timer tests. (#855)

Signed-off-by: Artur Souza <[email protected]>
Signed-off-by: Mahmut Canga <[email protected]>

* Convert Config API to Stable endpoints. (#846)

Signed-off-by: Mahmut Canga <[email protected]>

* Add PubSub subscriber examples over gPRC (#833)

* add grpc subscriber

Signed-off-by: MregXN <[email protected]>

* modify README.md

Signed-off-by: MregXN <[email protected]>

* modify README.md in examples

Signed-off-by: MregXN <[email protected]>

* Modify DaprApplication to support examples where protocol is not specified.

Signed-off-by: MregXN <[email protected]>

* modify formatter to pass checkstyle

Signed-off-by: MregXN <[email protected]>

* Update springboot to latest minor.patch version. (#826)

Signed-off-by: MregXN <[email protected]>

* Use runtime 1.10.0-rc.X and CLI 1.10.0-rc.X (#827)

Signed-off-by: Artur Souza <[email protected]>
Signed-off-by: MregXN <[email protected]>

* Upgrade the version to 1.9.0-SNAPSHOT (#829)

Signed-off-by: Artur Souza <[email protected]>
Signed-off-by: MregXN <[email protected]>

* Generate updated javadocs for 1.8.0 (#836)

Signed-off-by: Artur Souza <[email protected]>
Signed-off-by: MregXN <[email protected]>

* Update Dapr runtime and CLI to 1.10. (#837)

Signed-off-by: Artur Souza <[email protected]>
Signed-off-by: MregXN <[email protected]>

* Inject autoconfiguration in the Spring Boot 3 style (#831)

* Bump from spring boot 2.3.5.RELEASE to 2.7.8

Signed-off-by: Sergio <[email protected]>
(cherry picked from commit 9152c91)

* Ensure old versions of spring boot are still compatible

Signed-off-by: Sergio <[email protected]>

---------

Signed-off-by: champel <[email protected]>
Signed-off-by: Sergio <[email protected]>
Signed-off-by: MregXN <[email protected]>

* Bump from reactor 2.3.5.RELEASE to 2.7.8 (#830)

* Bump from reactor 2.3.5.RELEASE to 2.7.8

Signed-off-by: Sergio <[email protected]>

* Simplification

Signed-off-by: Sergio <[email protected]>

---------

Signed-off-by: Sergio <[email protected]>
Signed-off-by: MregXN <[email protected]>

* rerun checks

Signed-off-by: MregXN <[email protected]>

* modify the way of grpc server starts

Signed-off-by: MregXN <[email protected]>

* modify README

Signed-off-by: MregXN <[email protected]>

* Update pom.xml

Signed-off-by: MregXN <[email protected]>

---------

Signed-off-by: MregXN <[email protected]>
Signed-off-by: Artur Souza <[email protected]>
Signed-off-by: champel <[email protected]>
Signed-off-by: Sergio <[email protected]>
Signed-off-by: MregXN <[email protected]>
Co-authored-by: Artur Souza <[email protected]>
Co-authored-by: champel <[email protected]>
Co-authored-by: Mukundan Sundararajan <[email protected]>
Signed-off-by: Mahmut Canga <[email protected]>

* auto validate actors (#863)

Signed-off-by: Mukundan Sundararajan <[email protected]>
Signed-off-by: Mahmut Canga <[email protected]>

* Bump codecov/codecov-action from 3.1.1 to 3.1.4 (#862)

Bumps [codecov/codecov-action](https://github.com/codecov/codecov-action) from 3.1.1 to 3.1.4.
- [Release notes](https://github.com/codecov/codecov-action/releases)
- [Changelog](https://github.com/codecov/codecov-action/blob/main/CHANGELOG.md)
- [Commits](codecov/codecov-action@v3.1.1...v3.1.4)

---
updated-dependencies:
- dependency-name: codecov/codecov-action
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <[email protected]>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Signed-off-by: Mahmut Canga <[email protected]>

* Fix 787 (#832)

* prepare before testing

* Update tests

* fix checkstyle

---------

Co-authored-by: Artur Souza <[email protected]>
Signed-off-by: Mahmut Canga <[email protected]>

* Upgrade to 1.11 RCs. (#867)

Signed-off-by: Artur Souza <[email protected]>
Signed-off-by: Mahmut Canga <[email protected]>

* Init for workflows

Signed-off-by: Bill DeRusha <[email protected]>
Signed-off-by: Mahmut Canga <[email protected]>

* Updating some javadocs and Years.

Signed-off-by: Hannah Kennedy <[email protected]>
Signed-off-by: Mahmut Canga <[email protected]>

* Add missing Header

Signed-off-by: Hannah Kennedy <[email protected]>
Signed-off-by: Mahmut Canga <[email protected]>

* respond to PR feedback

Signed-off-by: Bill DeRusha <[email protected]>
Signed-off-by: Mahmut Canga <[email protected]>

* Update workflow example README

Signed-off-by: Bill DeRusha <[email protected]>
Signed-off-by: Mahmut Canga <[email protected]>

* Address PR feedback

Signed-off-by: Bill DeRusha <[email protected]>
Signed-off-by: Mahmut Canga <[email protected]>

* fixup deprecated pom.xml variable

Signed-off-by: Bill DeRusha <[email protected]>
Signed-off-by: Mahmut Canga <[email protected]>

* Updates based on PR feedback

Signed-off-by: Bill DeRusha <[email protected]>
Signed-off-by: Mahmut Canga <[email protected]>

* Update pom files per feedback

Signed-off-by: Bill DeRusha <[email protected]>
Signed-off-by: Mahmut Canga <[email protected]>

* GetInstanceState implementation (#1)

* addiny getInstanceMetadata, waitForInstanceStart and waitForInstanceCompletion implementation
---------

Co-authored-by: aymanmahmoud_microsoft <[email protected]>
Signed-off-by: Aymand Mahmoud <[email protected]>
Signed-off-by: Mahmut Canga <[email protected]>

* Management API

Signed-off-by: Mahmut Canga <[email protected]>

* remove try/catch

Signed-off-by: Mahmut Canga <[email protected]>

* implementing getIsReplaying() method for Authoring API (#7)

Co-authored-by: Julio Rezende <[email protected]>
Signed-off-by: Mahmut Canga <[email protected]>
Signed-off-by: Julio Rezende <[email protected]>

* Implementing getCurrentInstant() authoring method (#5)

Co-authored-by: Julio Rezende <[email protected]>
Signed-off-by: Mahmut Canga <[email protected]>
Signed-off-by: Julio Rezende <[email protected]>

* Activity Implementation (#3)

Signed-off-by: Mahmut Canga <[email protected]>

* fixing issue with getIsReplaying() call (#8)

Co-authored-by: Julio Rezende <[email protected]>
Signed-off-by: Mahmut Canga <[email protected]>
Signed-off-by: Julio Rezende <[email protected]>

* Generate updated javadocs for 1.9.0 (#878)

* Generate updated javadocs for 1.9.0

Signed-off-by: Artur Souza <[email protected]>

* Update _index.md

Signed-off-by: Artur Souza <[email protected]>

---------

Signed-off-by: Artur Souza <[email protected]>
Signed-off-by: Mahmut Canga <[email protected]>

* Add .sdkmanrc config file and JDK installation instructions (#873)

* Add .sdkmanrc file with installation instructions

Signed-off-by: Emanuel Alves <[email protected]>

* Update README.md

Signed-off-by: Artur Souza <[email protected]>

---------

Signed-off-by: Emanuel Alves <[email protected]>
Signed-off-by: Artur Souza <[email protected]>
Co-authored-by: Artur Souza <[email protected]>
Co-authored-by: Artur Souza <[email protected]>
Co-authored-by: Mukundan Sundararajan <[email protected]>
Signed-off-by: Mahmut Canga <[email protected]>

* Add unit testing example

Signed-off-by: Bill DeRusha <[email protected]>
Signed-off-by: Mahmut Canga <[email protected]>

* implementing getIsReplaying() method for Authoring API (#7)

Co-authored-by: Julio Rezende <[email protected]>

Signed-off-by: Julio Rezende <[email protected]>
Signed-off-by: Mahmut Canga <[email protected]>

* fix parent pom

Signed-off-by: Mahmut Canga <[email protected]>

* Send Event Implementation (#10)

Signed-off-by: Mahmut Canga <[email protected]>

* Implementing allOf, anyOf, createTimer methods (#11)

Co-authored-by: Julio Rezende <[email protected]>
Signed-off-by: Mahmut Canga <[email protected]>
Co-authored-by: Julio Rezende <[email protected]>

* Support remote endpoint. (#877)

* Support remote endpoint.

Signed-off-by: Artur Souza <[email protected]>

* Use GRPC_ENDPOINT and HTTP_ENDPOINT in integration tests.

Signed-off-by: Artur Souza <[email protected]>

* Fix happy path for waiting for sidecar test.

Signed-off-by: Artur Souza <[email protected]>

---------

Signed-off-by: Artur Souza <[email protected]>
Co-authored-by: Mukundan Sundararajan <[email protected]>
Signed-off-by: Mahmut Canga <[email protected]>

* Add callSubWorkflow Implementation

Co-authored-by: Aymand Mahmoud <[email protected]>
Signed-off-by: Mahmut Canga <[email protected]>
Signed-off-by: Aymand Mahmoud <[email protected]>

* rename DemoSubWorkflow

Co-authored-by: Aymand Mahmoud <[email protected]>
Signed-off-by: Aymand Mahmoud <[email protected]>
Signed-off-by: Mahmut Canga <[email protected]>

* continueAsNew Implementation (#13)

Signed-off-by: Mahmut Canga <[email protected]>

* remove duplicate class

Signed-off-by: Mahmut Canga <[email protected]>

* add missing mockito test dependency

Signed-off-by: Mahmut Canga <[email protected]>

* use new workflow client implementation

Signed-off-by: Mahmut Canga <[email protected]>

* moved implementations to new workflow and context

Signed-off-by: Mahmut Canga <[email protected]>

* relocate duplicate implemantation

Signed-off-by: Mahmut Canga <[email protected]>

* remove duplicate test and increase test coverage

Signed-off-by: Mahmut Canga <[email protected]>

* Implement retry and timeout policy for gRPC client. (#889)

* Implement retry and timeout policy for gRPC client.

Signed-off-by: Artur Souza <[email protected]>

* Fix invoke actor after aborted flow.

Signed-off-by: Artur Souza <[email protected]>

---------

Signed-off-by: Artur Souza <[email protected]>
Signed-off-by: Mahmut Canga <[email protected]>

* renamed getIsReplaying

Signed-off-by: Mahmut Canga <[email protected]>

* rollback changes on client

Signed-off-by: Mahmut Canga <[email protected]>

* move workflow runtime state package

Signed-off-by: Mahmut Canga <[email protected]>

* rename workflow instance state to status

Signed-off-by: Mahmut Canga <[email protected]>

* remove unnecessary else

Signed-off-by: Mahmut Canga <[email protected]>

* removed unknown state

Signed-off-by: Mahmut Canga <[email protected]>

* updated comment

Signed-off-by: Mahmut Canga <[email protected]>

* updated workflow failure details

Signed-off-by: Mahmut Canga <[email protected]>

* fix style issues

Signed-off-by: Mahmut Canga <[email protected]>

* rollback merge change

Signed-off-by: Mahmut Canga <[email protected]>

* fixed pom files

Signed-off-by: Mahmut Canga <[email protected]>

* rollback actors pom changes on autoformat

Signed-off-by: Mahmut Canga <[email protected]>

* fixe actors pom

Signed-off-by: Mahmut Canga <[email protected]>

* fix styling on actors pom

Signed-off-by: Mahmut Canga <[email protected]>

* fix pom spacing

Signed-off-by: Mahmut Canga <[email protected]>

* move test to match the package

Signed-off-by: Mahmut Canga <[email protected]>

* add missing dependencies

Signed-off-by: Mahmut Canga <[email protected]>

* increased test coverage

Signed-off-by: Mahmut Canga <[email protected]>

* moved workflow runtime package

Signed-off-by: Mahmut Canga <[email protected]>

* add exception for missing case

Signed-off-by: Mahmut Canga <[email protected]>

* add null check for metadata

Signed-off-by: Mahmut Canga <[email protected]>

* add runtime exception error messages

Signed-off-by: Mahmut Canga <[email protected]>

* update try catch scope

Signed-off-by: Mahmut Canga <[email protected]>

* update activity definition to an interface

Signed-off-by: Mahmut Canga <[email protected]>

* update comments

Signed-off-by: Mahmut Canga <[email protected]>

* removed redundant method

Signed-off-by: Mahmut Canga <[email protected]>

* PR updates

Signed-off-by: Mahmut Canga <[email protected]>

---------

Signed-off-by: LionTao <[email protected]>
Signed-off-by: Mahmut Canga <[email protected]>
Signed-off-by: dependabot[bot] <[email protected]>
Signed-off-by: Artur Souza <[email protected]>
Signed-off-by: champel <[email protected]>
Signed-off-by: Sergio <[email protected]>
Signed-off-by: MregXN <[email protected]>
Signed-off-by: MregXN <[email protected]>
Signed-off-by: Mukundan Sundararajan <[email protected]>
Signed-off-by: Bill DeRusha <[email protected]>
Signed-off-by: Hannah Kennedy <[email protected]>
Signed-off-by: Bill DeRusha <[email protected]>
Signed-off-by: Aymand Mahmoud <[email protected]>
Signed-off-by: Julio Rezende <[email protected]>
Signed-off-by: Emanuel Alves <[email protected]>
Signed-off-by: Mahmut Canga <[email protected]>
Co-authored-by: LionTao <[email protected]>
Co-authored-by: Mukundan Sundararajan <[email protected]>
Co-authored-by: Artur Souza <[email protected]>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: champel <[email protected]>
Co-authored-by: MregXN <[email protected]>
Co-authored-by: MatejNedic <[email protected]>
Co-authored-by: Bill DeRusha <[email protected]>
Co-authored-by: Hannah Kennedy <[email protected]>
Co-authored-by: Bill DeRusha <[email protected]>
Co-authored-by: Aymalla <[email protected]>
Co-authored-by: aymanmahmoud_microsoft <[email protected]>
Co-authored-by: swetakumari <[email protected]>
Co-authored-by: julio <[email protected]>
Co-authored-by: Julio Rezende <[email protected]>
Co-authored-by: Emanuel Alves <[email protected]>
Co-authored-by: Artur Souza <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

4 participants