Hi Azeez The code you shared does not work as expected in MSF4J 2.0.0. This is an issue in MSF4J 2.0.0. [1]
I was using MSF4J 2.0.0 version for my initial implementation. It is working fine with the latest version. Thanks https://github.com/wso2/msf4j/issues/483 On Wed, Jan 10, 2018 at 9:57 AM, Irshad Nilam <[email protected]> wrote: > Hi Azeez and Thusitha, > > I must have had problems because of starting separate threads. Thanks for > pointing that out, I'll follow this approach and will update this thread. > > Thanks and Regards. > > On Wed, Jan 10, 2018 at 1:27 AM, Thusitha Thilina Dayaratne < > [email protected]> wrote: > >> Hi Irshad, >> >> As Azeez mentioned this should work out of the box. We are doing same >> thing in our test cases as well[1]. You don't have to create a separate >> thread since MicroserveRunner internals will do that for you. >> >> [1] - https://github.com/wso2/msf4j/blob/master/core/src/test/java >> /org/wso2/msf4j/HttpServerTest.java#L125 >> >> Thanks >> Thusitha >> >> On Tue, Jan 9, 2018 at 8:40 PM, Afkham Azeez <[email protected]> wrote: >> >>> I tried the following and things worked as expected. >>> >>> @Path("/hello") >>> public class HelloService { >>> >>> private String id; >>> >>> public HelloService(String id) { >>> this.id = id; >>> } >>> >>> @GET >>> @Path("/{name}") >>> public String hello(@PathParam("name") String name) { >>> System.out.println("Hello"); >>> return "Hello " + name + " from " + id; >>> } >>> } >>> >>> --------- >>> >>> public class Application { >>> public static void main(String[] args) { >>> new MicroservicesRunner(8080) >>> .deploy(new HelloService("1")) >>> .start(); >>> new MicroservicesRunner(8081) >>> .deploy(new HelloService("2")) >>> .start(); >>> new MicroservicesRunner(8082) >>> .deploy(new HelloService("3")) >>> .start(); >>> new MicroservicesRunner(8083) >>> .deploy(new HelloService("4")) >>> .start(); >>> } >>> } >>> --- >>> >>> Is that not working for you as expected? >>> >>> On Tue, Jan 9, 2018 at 12:26 PM, Irshad Nilam <[email protected]> wrote: >>> >>>> 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 <077%20366%209262> >>>> <http://wso2.com/signature> >>>> >>>> >>> >>> >>> -- >>> *Afkham Azeez* >>> Senior Director, Platform Architecture; WSO2, Inc.; http://wso2.com >>> Member; Apache Software Foundation; http://www.apache.org/ >>> * <http://www.apache.org/>* >>> *email: **[email protected]* <[email protected]> >>> * cell: +94 77 3320919 <077%20332%200919>blog: **http://blog.afkham.org* >>> <http://blog.afkham.org> >>> *twitter: **http://twitter.com/afkham_azeez* >>> <http://twitter.com/afkham_azeez> >>> *linked-in: **http://lk.linkedin.com/in/afkhamazeez >>> <http://lk.linkedin.com/in/afkhamazeez>* >>> >>> *Lean . Enterprise . Middleware* >>> >>> _______________________________________________ >>> Dev mailing list >>> [email protected] >>> http://wso2.org/cgi-bin/mailman/listinfo/dev >>> >>> >> >> >> -- >> >> > > > > -- > Irshad Nilam > Software Engineering Intern > WSO2 > > Email : [email protected] > Mobile : +94 77 3669262 <+94%2077%20366%209262> > <http://wso2.com/signature> > > -- 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
