0

I am developing solution where there are three webapi projcets. Each of them is secured with JWT tokens mechanism. So far webapis had not need to communicate. Finally they will be deployed on azure separetly and they will be using the same database.

I could generate a token with infinite lifespan and store it somewhere in the database, but something tells to me this is not right way to solve this issue.

Any help will be appreciated.

Question: How to allow them to communicate other way than generating a token with infinite lifespan?

8
  • What is your actual question? Commented Mar 22, 2019 at 13:24
  • "So far webapis had not need to communicate. Finally they will be deployed on azure separetly and they will be using the same database." so they're still not communicating with each other? What exactly is your question? Commented Mar 22, 2019 at 13:24
  • Now they need to communicate between them. Commented Mar 22, 2019 at 13:29
  • And how will they be communicating between each other? Commented Mar 22, 2019 at 13:34
  • Using http requests, but if there are better aprroches I can make a change. Commented Mar 22, 2019 at 13:38

1 Answer 1

1

Sounds like a use case for SQL Dependencies. An SQL dependency allows you to subscribe to an event that gets triggered when the result of a command differs. Something like so:

// I'll assume that a connection is already open
using (var command = new SqlCommand("SQL Command goes here")
{
    var dependency = new SqlDependency(command);
    dependency.OnChange += (object sender, SqlNotificationEventArgs e) => 
    {
        // Handle OnChange here
        Console.WriteLine(e.Info);
    }

    // You can do all the things with the SQL Command here as you normally could
    // for example execute it if it's a SELECT and read data
}

Be careful when using SQL dependencies as they're a bit more time consuming/ expensive as one would think, so try to keep them to a minimum

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.