Hi all,

I am working on integration test for 4 microservices written in MSF4J.

1 - A Microservice
2 - B Microservice
3 - C Microservice
4 - D Microservice

These are implemented in a way to deploy them separately.

Application code (where we deploy the microservice using microservice
runner) will look similar to this.


public class Application {


    public static void main(String[] args) {

        Application application = new Application();
        application.runMS(8081);

    }

    public void runMS(int port) {

        MicroservicesRunner msRunner = new MicroservicesRunner(port);

        msRunner.deploy(new AService())

                .addExceptionMapper(
                        new AKeyExceptionMapper(),
                        new AExceptionMapper(),
                        new NotFoundExceptionMapper())
                .start();

}
}


For the integration test, I want to start these four microservices with the
exception mappers. To achieve this, I tried to start this microservice in
separate threads as bellow. (in TestNG Suite)

//Run A microservice
new Thread(() -> new pathtoA.Application().runMS(8081)).start();

//Run B microservice
new Thread(() -> new pathtoB.Application().runMs(8082)).start();

//Run C microservice
new Thread(() -> new pathtoC.Application().runMs(8083)).start();

//Run D microservice
new Thread(() -> new pathtoD.Application().runMs(8084)).start();


*But I'm having a problem wherein all the four ports, only DService is
getting deployed.   AFAIU this is because having multiple *
org.wso2.msf4j.MicroserviceRunner* classes in the same JVM and only one
getting loaded. *

*I have a requirement where I need to run all 4 microservice in one JVM
because of resource issues. ** Is there a way to achieve this without going
to separate JVM for each service?*


Please note those Exception mappers belong to each of the microservice
packages. And should also be tested with integration test. So that I cannot
run these service like this.

MicroservicesRunner msRunner = new MicroservicesRunner(port1,port2, port3);
microservicesRunner.deploy(serviceA, serviceB,
serivice3).addExceptionMapper(Amapper, Bmapper, cMapper).start();


Thanks and regards.
-- 
Irshad Nilam
Software Engineering Intern
WSO2

Email  : [email protected]
Mobile :      +94 77 3669262
<http://wso2.com/signature>
_______________________________________________
Dev mailing list
[email protected]
http://wso2.org/cgi-bin/mailman/listinfo/dev

Reply via email to