Open Closed

Howto integrate a standard template pro solution as new service in a microservice solution #3310


0
hakan.uskaner created
  • ABP Framework version: v5.3.0
  • UI type: Blazor-server
  • DB provider: EF Core / MongoDB
  • Tiered (MVC) or Identity Server Separated (Angular): yes

I have built up a microservice solution and would like to add an other project based on the standard template pro as service to it. At the end my solution will look similiar to you eshoponabp project, where you use postgres and mongo as db.

i did follow the doc from here: https://docs.abp.io/en/commercial/latest/startup-templates/microservice/add-microservice to generate a service with the same name. It seems that the parameter for the database provider is ignored (-d mongo) . It always creates a service based on EF. Is this a bug ?

I did also compare the generated files from the new service with the files from the standard template pro and found differences in the module files and structure. I would like to know howto modify the files from the standard template to be able to use it as service in the microservice solution.

As far as i can see, i need to edit all csproj files and *module.cs files to remove unneeded things and add at least something like "typeof(AbpDddDomainModule)," etc., remove Identity Project, move some files to other projects and so on.

I would like to have a detailed step by step guide for a demo project like eventhub /boookstore to see howto integrate it in a microservice solution, Any help would be great


7 Answer(s)
  • 0
    gterdem created
    Support Team

    i did follow the doc from here: https://docs.abp.io/en/commercial/latest/startup-templates/microservice/add-microservice to generate a service with the same name. It seems that the parameter for the database provider is ignored (-d mongo) . It always creates a service based on EF. Is this a bug ?

    We have MongoDB support for services in our to-do list, but it is not supported yet. You need to configure it manually.

    Adding a pro template to the microservice template will not make it a microservice. The only supported way is documented in Add new Microservices to the Solution. If you want to use the MongoDB for your newly created microservice, you can also follow Change Microservice project to use MongoDB Provider guide.

  • 0
    hakan.uskaner created

    I know that a pro template is not a microservice. But i want to move the relevant parts from pro template solution to a new microservice .. Thats why asked for a guide.. I think its a valid option for moving towards a microservice solution

  • 0
    gterdem created
    Support Team

    I know that a pro template is not a microservice. But i want to move the relevant parts from pro template solution to a new microservice .. Thats why asked for a guide.. I think its a valid option for moving towards a microservice solution

    What do you mean by relevant parts? You can move the domain layer to the domain, the application layer to the application layer. It shouldn't be any problem.

    The only exception with the microservice is the UI. Because there are 2 ways to build the UI;

    Can you provide some samples of the issue you are having?

  • 0
    hakan.uskaner created

    Yes here is one issue. I did follow your document "Add a new microservice to solution". I can reach my added new Service per Swagger on localhost port 44472. Thats site works.

    But i get an error on both gateways if i try to select my new service, that it failed to fetch due Cors Origin:

    Fetch error Failed to fetch https://localhost:44472/swagger/v1/swagger.json

    Fetch error Possible cross-origin (CORS) issue? The URL origin (https://localhost:44472) does not match the page (https://localhost:44325). Check the server returns the correct 'Access-Control-Allow-*' headers.

    I did double check the product service and compared with my new services. But i didn't find any differences so far.

    • Your document doesn't seem to be updated to 5.3.. There is no internal gateway, and the other gateways do not rely anymore on a project reference for the HttpApi Projects. I did update ocelot.json, the specific Module.cs, but still get the error.

    • Your document "Change Microservice project to use MongoDB Provider" changes everything to mongo. But i would only add one additional service with mongo. There is a difference , that both Migrations and Checker must work at same time.. and the document doesn't describe that clearly. I did look at eshoponabp and it a looks a bit different.

    What can i do for the gateways to acceppt my new service `??

    Maybe you could share a complete microservice-template-pro example based on mongdb with me.?

  • 0
    gterdem created
    Support Team

    Possible cross-origin (CORS) issue? The URL origin (https://localhost:44472) does not match the page (https://localhost:44325). Check the server returns the correct 'Access-Control-Allow-*' headers.

    What is running on port 44325? Your new microservice? You need to add https://localhost:44472 to your new microservice appsettings Cors configuration.

    Your document doesn't seem to be updated to 5.3.. There is no internal gateway, and the other gateways do not rely anymore on a project reference for the HttpApi Projects. I did update ocelot.json, the specific Module.cs, but still get the error.

    We have updated the documentation but maybe we forgot some of it. Can you point which documentation have internal gateway reference?

    Your document "Change Microservice project to use MongoDB Provider" changes everything to mongo. But i would only add one additional service with mongo. There is a difference , that both Migrations and Checker must work at same time.. and the document doesn't describe that clearly. I did look at eshoponabp and it a looks a bit different.

    It has actually commented code to activate MongoDB for a single microservice. You can also check the eShopOnAbp sample that CatalogService is using MongoDB.

  • 0
    hakan.uskaner created
    • your document "https://docs.abp.io/en/commercial/latest/startup-templates/microservice/add-microservice" contain infos about the internal gateway and project reference which doesn't exist anymore, this one needs an update

    • if i try to follow you document how to change to mongodb. i receive a lot of errors in vs

    • The Port 44325 is port of the WebGateway, The Port 44472 is the port of my new microservice. I also receive this error on the PublicWebGateway which runs at Port 44353. Both Gateways are added to the new microservice appsettings Cors configuration per default. Also if i open the new microservice page in tye directly (https://localhost:44472) . it works fine but not if try to access it over an gateway. I did follow also the section about the gateways in your microservcice document any didn't find any difference.

    I did reproduce it with these steps:

    • generate microservice: abp new AppMicro -t microservice-pro -u blazor-server -csf
    • abp new AppZero -t microservice-service-pro
    • follow gatway document to add it.
    • Start tye and test the new microservice appzero directly .. it will work. try to access it over one gateway. i do get the same error.
  • 0
    [email protected] created

    My environment

    ABP Framework version: v5.3.0
    UI type: angular
    DB provider: EF Core
    Identity Server Separated (Angular): yes
    

    same problem on my end, please let me know if you get this working please. S I have this configuration over Ports:

    WebGateway: https: 44325 AuthServer: https: 44322 IdentityService: https: 44388 ProductService: https: 44361 NewService: https: 44752

    AngularClient: http: 4200 ReactClient: http: 5200

    CORS: WebGateway: "http://localhost:4200,http://localhost:5200,https://localhost:44307,https://localhost:44325,https://localhost:44353,https://localhost:44367,https://localhost:44388,https://localhost:44381,https://localhost:44361" AuthServer: "http://localhost:4200,http://localhost:5200,https://localhost:44307,https://localhost:44325,https://localhost:44353,https://localhost:44367,https://localhost:44388,https://localhost:44381,https://localhost:44361", IdentityService: "http://localhost:4200,http://localhost:5200,https://localhost:44307,https://localhost:44325,https://localhost:44353,https://localhost:44367,https://localhost:44388,https://localhost:44381,https://localhost:44361" ProductService: "https://localhost:44325,https://localhost:44353" NewService: "http://localhost:4200,http://localhost:5200,https://localhost:44307,https://localhost:44325,https://localhost:44353,https://localhost:44367,https://localhost:44388,https://localhost:44381,https://localhost:44361"

    Result:

    NewService: Swagger is working, and openApi definition is working ProductService: Swagger is working, and openApi definition is working

    WebGateway: works over all old services, but when I try to switch to NewService Api definition from WebGateway it gives me a CORS error, if I pick ProductService it works, that not makes sense to me, it has be something else in between