AtomicLiquid
AtomicLiquid
CC#
Created by muskagap on 12/30/2022 in #help
❔ How to properly design microservice architecture in ASP Net Core?
I'm coming from the java world, so it's somewhat different than .NET
28 replies
CC#
Created by muskagap on 12/30/2022 in #help
❔ How to properly design microservice architecture in ASP Net Core?
But not really sure if that would make sense either haha
28 replies
CC#
Created by muskagap on 12/30/2022 in #help
❔ How to properly design microservice architecture in ASP Net Core?
Child solutions was meant to be child projects😅
28 replies
CC#
Created by muskagap on 12/30/2022 in #help
❔ How to properly design microservice architecture in ASP Net Core?
I'm gonna try to add to what Anton has already written, and my takes on it:
1. Should I create multiple services under one solution?
As Anton have already said, this really depends on the scope/size of your application/each microservice. If you have several team members working on it, you should definitely divide it into separate git repos to avoid conflicts. If you're a relatively small team, then I would create one parent solution with a child solution for each microservice.

2. Should I create a new solution for each service?
Yes, but whether or not to keep them in the same git repo depends on the size of the application/the project. Read 1.

3. Should I create API Gateway as an app in seperate solution or under existing solution (e.g. along with one of the services)?
Again, depends on the scope of your project. If you need/want services such as load balancing, networking and will potentially run the solution on several nodes (servers), then I'd use something like Kubernetes or Docker Swarm to handle the gateway to your microservices API's. If you decide to do the orchestration themselves, I would use something like KrakenD to handle the gateway stuff for you, or you can create an app yourself.

4. Should I always containerize microservices or not?
I highly suggest doing so, the issue with not containerizing them is that it requires you to handle all runtimes and stuff yourself, aka installing .NET core etc. There's also other considerations when not containerizing your apps, but for a microservice solution, I don't see a reason why you wouldn't want containers, it makes your life easier.

5. Is it possible to deploy microservices apps without containerization?
Ofcourse it is, but you need to handle alot of configuration stuff yourself, making features such as CD (Continous Deployment) much harder to implement. The reason being that you manually have to go into your server, pull the changes from your repo and redeploy.

6. I have one server with one database where all data is stored. I read that each service should have its own database. Can I use one database for each service (but each service will be using different tables , not share the same tables)?
Ofcourse you can, but the problem with such a solution is that if your one database runs into issues (crashes, gets corrupted and such), your whole application goes down, which often breaks the principles of why you want a microservice architecture in the first place. If you have a database instance per microservice, then if one of the databases dies, you still have all other microservices running, because they are not dependent on each other.

7. Does it make sense to create seperate service where all required data from database/s is stored (e.g. data from a few servers)? And then other services (e.g. Payments, Products, Clients etc.) would communicate with this data service to make CRUD operations? Normally, each service should have its own database but what about this approach?
Again, definitely a solution that could work, but then the microservices becomes dependent on each other. It's your choice and it depends on your (or your customer's) requirements for your application/architecture.
1. Should I create multiple services under one solution?
As Anton have already said, this really depends on the scope/size of your application/each microservice. If you have several team members working on it, you should definitely divide it into separate git repos to avoid conflicts. If you're a relatively small team, then I would create one parent solution with a child solution for each microservice.

2. Should I create a new solution for each service?
Yes, but whether or not to keep them in the same git repo depends on the size of the application/the project. Read 1.

3. Should I create API Gateway as an app in seperate solution or under existing solution (e.g. along with one of the services)?
Again, depends on the scope of your project. If you need/want services such as load balancing, networking and will potentially run the solution on several nodes (servers), then I'd use something like Kubernetes or Docker Swarm to handle the gateway to your microservices API's. If you decide to do the orchestration themselves, I would use something like KrakenD to handle the gateway stuff for you, or you can create an app yourself.

4. Should I always containerize microservices or not?
I highly suggest doing so, the issue with not containerizing them is that it requires you to handle all runtimes and stuff yourself, aka installing .NET core etc. There's also other considerations when not containerizing your apps, but for a microservice solution, I don't see a reason why you wouldn't want containers, it makes your life easier.

5. Is it possible to deploy microservices apps without containerization?
Ofcourse it is, but you need to handle alot of configuration stuff yourself, making features such as CD (Continous Deployment) much harder to implement. The reason being that you manually have to go into your server, pull the changes from your repo and redeploy.

6. I have one server with one database where all data is stored. I read that each service should have its own database. Can I use one database for each service (but each service will be using different tables , not share the same tables)?
Ofcourse you can, but the problem with such a solution is that if your one database runs into issues (crashes, gets corrupted and such), your whole application goes down, which often breaks the principles of why you want a microservice architecture in the first place. If you have a database instance per microservice, then if one of the databases dies, you still have all other microservices running, because they are not dependent on each other.

7. Does it make sense to create seperate service where all required data from database/s is stored (e.g. data from a few servers)? And then other services (e.g. Payments, Products, Clients etc.) would communicate with this data service to make CRUD operations? Normally, each service should have its own database but what about this approach?
Again, definitely a solution that could work, but then the microservices becomes dependent on each other. It's your choice and it depends on your (or your customer's) requirements for your application/architecture.
I'm not an expert on this, but these are my two cents after working with microservices for the last 4-5 years based on my own experiences.
28 replies
CC#
Created by Malibloo on 12/30/2022 in #help
❔ JSON Serialization Weird Model
Yeah, Object should and Fields could be renamed to something more accurate of what you're trying to achieve using this model, just remember to annotate them properly within the parent component, e.g [JsonProperty("Object")].
49 replies
CC#
Created by Malibloo on 12/30/2022 in #help
❔ JSON Serialization Weird Model
@Malibloo
49 replies
CC#
Created by Malibloo on 12/30/2022 in #help
❔ JSON Serialization Weird Model
What I would do is to just create the models, and by looking at the example JSON you've posted, you can re-use a lot of the components. By using ChatGPT, it suggested this data model:
public class Subject
{
public Element Element { get; set; }
}

public class Element
{
[JsonProperty("@SbId")]
public int SbId { get; set; }

public Fields Fields { get; set; }

public List<Object> Objects { get; set; }
}

public class Fields
{
public int StId { get; set; }
public string Ds { get; set; }
public DateTime Da { get; set; }
}

public class Object
{
[JsonProperty("SubjectLink")]
public SubjectLink SubjectLink { get; set; }

[JsonProperty("SubjectAttachment")]
public SubjectAttachment SubjectAttachment { get; set; }
}

public class SubjectLink
{
public Element Element { get; set; }
}

public class SubjectAttachment
{
public Element Element { get; set; }
}
public class Subject
{
public Element Element { get; set; }
}

public class Element
{
[JsonProperty("@SbId")]
public int SbId { get; set; }

public Fields Fields { get; set; }

public List<Object> Objects { get; set; }
}

public class Fields
{
public int StId { get; set; }
public string Ds { get; set; }
public DateTime Da { get; set; }
}

public class Object
{
[JsonProperty("SubjectLink")]
public SubjectLink SubjectLink { get; set; }

[JsonProperty("SubjectAttachment")]
public SubjectAttachment SubjectAttachment { get; set; }
}

public class SubjectLink
{
public Element Element { get; set; }
}

public class SubjectAttachment
{
public Element Element { get; set; }
}
49 replies
CC#
Created by AtomicLiquid on 12/25/2022 in #help
✅ Dapper InsertAsync fails on Postgres with relation does not exist
Thanks again!
20 replies
CC#
Created by AtomicLiquid on 12/25/2022 in #help
✅ Dapper InsertAsync fails on Postgres with relation does not exist
Interesting! How would you implement such a feature though?
20 replies
CC#
Created by AtomicLiquid on 12/25/2022 in #help
✅ Dapper InsertAsync fails on Postgres with relation does not exist
Thanks a lot for the well detailed answers, it's really appreciated!
20 replies
CC#
Created by AtomicLiquid on 12/25/2022 in #help
✅ Dapper InsertAsync fails on Postgres with relation does not exist
Seems like using the [Column] annotation is the way to go then.
20 replies
CC#
Created by AtomicLiquid on 12/25/2022 in #help
✅ Dapper InsertAsync fails on Postgres with relation does not exist
Yeah, definitely seems like there's trade-offs no matter how I decide to name the tables. If I decide to not add the column annotation and rename all tables and fields to camel case, I will still face the same problems when I change back to using a MySQL database...
20 replies
CC#
Created by AtomicLiquid on 12/25/2022 in #help
✅ Dapper InsertAsync fails on Postgres with relation does not exist
Yep, definitely is sort of a dangerous road to tread... Over to the original issue again, I am now facing an issue with the CRUD operations from Dapper again, is that it seems that I have to add the Column annotation for every single field within the database model, because it defaults to lowercase. We're creating a tool that will be used by several different server admins, and it's open-source. This makes the solution of adding the quote_ident setting to the conf file a bit tedious for the users using our tool. Does this mean we should consider using camelCase throughout the tables and fields instead of capitalizing the first letter? Or is there another way?
20 replies
CC#
Created by AtomicLiquid on 12/25/2022 in #help
✅ Dapper InsertAsync fails on Postgres with relation does not exist
Not sure if this is your expertise, but how would I go about creating Dapper queries that will work for several different database types, such as MSSQL, SQLite, MySQL etc? What do I have to keep in mind?
20 replies
CC#
Created by AtomicLiquid on 12/25/2022 in #help
✅ Dapper InsertAsync fails on Postgres with relation does not exist
You're a champ! Thanks alot for the reply.
20 replies
CC#
Created by AtomicLiquid on 11/19/2022 in #help
✅ Not able to Insert data to table using Dapper
Alright, great to know. We're using Dapper because its quite a bit faster than EF, just have to get used to it. Thanks alot for the response!
12 replies