C
C#2y ago
volvic

❔ Create a HostedService using BackgroundService to listen to requests

Hello, I am currently trying to build a BankAccount project and I wrote my business logic. My next step is to create a service and host it so it can listen to clients request (Create account, Deposit) and do the work. As I understand is in my Worker class I need to write a code which will listen for requests in the ExecuteAsync method, but I can't figure it out how. I did once using grpc to listen for requests with a host and port server but I wish to explore other methods. How to manage to create a service handling my business logic and waiting for requests ? Any links/hints would be very helpful
14 Replies
phaseshift
phaseshift2y ago
So why are you doing this and not using normal endpoints, letting the server do the waiting for you?
volvic
volvic2y ago
Now that you are asking… I re-used the Host logic from my Grpc project (create the server wit host port) in the ExecuteAsync method, thinking it would work too So the classic way is to create endpoints using API to create my server side ?
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
volvic
volvic2y ago
yes, the usecase is to send requests(create account/deposit/withdraw money) and server reply with the data. I aim from the simplest and classic implementation of this, but not using grpc. The project manager wishes to test it by making api calls using swagger or other tool
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
volvic
volvic2y ago
what do you mean by bcksvc?
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
volvic
volvic2y ago
I see ! so I need to change my code for protobufs => this will help me create my clients and my server and I need to wrap it with API
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
volvic
volvic2y ago
yes, its the template
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
volvic
volvic2y ago
yes thats really practical. I was a bit hesitating about using already created templates but this should be the simplest to understand api with post get etc => request which will be handled by grpc and return the data many thanks to you, it is much clearer @TeBeConsulting ! this is my first post, the community here is awesome ! 🙂
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
Accord
Accord2y ago
Was this issue resolved? If so, run /close - otherwise I will mark this as stale and this post will be archived until there is new activity.