2

how to deploy a microservice writted by WSF4J?

like this: Navigate to the /bin directory and run the following command to start the MSF4J server. ./carbon.sh

where is the carbon.sh ?

Bee
  • 12,251
  • 11
  • 46
  • 73
Mike
  • 419
  • 1
  • 6
  • 16

1 Answers1

0

MSF4J is a framework, and there is no server for that. Once you build your msf4j project, it creates a fat jar which can run alone, like this.

java -jar helloworld-*.jar 

You can find the hello world sample here.

Edit: Instead of the fat jar, you also can make it an OSGi bundle, and run it on Carbon 5 kernel with msf4j feature installed in it. For that go inside resources directory, and build it as per the instructions, given in here. It will create a kernel server with msf4j in it. You can run that and deploy your microservice.

Bee
  • 12,251
  • 11
  • 46
  • 73
  • So, I would like to write the microservice like this:https://github.com/wso2/msf4j/tree/master/samples/stockquote/bundle. Then ,this sample is what to do? I do it like the above http site and to write a microservice as a bundle – Mike Dec 20 '16 at 06:59
  • what is the differences between the fat jar mod and the bundle mode? – Mike Dec 20 '16 at 07:48
  • fat jar can run on its own. it includes all dependencies it needs. osgi bundle's required dependencies should be provided from an osgi environment. So you need a server to run that. – Bee Dec 20 '16 at 07:50
  • ok, If there are so many microservices ,how to deploy them with the fat jar mode? each microservice has its own http port. If each jar was started ,it need many ports – Mike Dec 20 '16 at 07:58
  • @mike When you deploy a microservice in OSGi container you don't have to provide a port. The server port is determined at the container startup time. By default, it will be 9090. If you want to change that port or add more transport you can provide a config file to do that. – Thusitha Thilina Dayaratne Dec 20 '16 at 08:11
  • @ThusithaThilinaDayaratne, as you say :deploy a microservice in OSGi container. can you give me a sample that deploy a microservice in OSGi container? – Mike Dec 20 '16 at 08:15
  • @mike In OSGI environment you need to implement the Microservice interface from your service class. Then you can register your service implementation under Microservice interface either as an OSGi service component or directly using the bundle context. https://github.com/wso2/msf4j/blob/master/samples/stockquote/bundle/src/main/java/org/wso2/msf4j/stockquote/StockQuoteService.java#L52 we register microservice as a OSGi service component. – Thusitha Thilina Dayaratne Dec 20 '16 at 08:52
  • This will install the msf4j and other required features to the kernel and build up a product. You can find the product in the resources/target directory .Go to the target/wso2msf4j-/bin directory Then run the following command to start the MSF4J server. ./carbon.sh @ThusithaThilinaDayaratne after clean install ,there is no this file, then how to do next? I do that with your official code – Mike Dec 20 '16 at 08:53
  • en ?by the way ,how to deploy a microservice with carbon? is there a sample? – Mike Dec 20 '16 at 13:45
  • Does `mvn clean install` complete without any errors? If yes, there should be the server zip inside target dir. – Bee Dec 20 '16 at 14:15
  • no any errors. however,there is no the server zip . Shoul I send you a screenshot by an e-mail? – Mike Dec 20 '16 at 15:19
  • Make it 2.1.0 and plz send a screenshot as well. – Bee Dec 20 '16 at 15:36
  • meanwhile,I modifed the pom.xml 2.1.0-SNAPSHOT to 2.1.0. because ,there is no depdency of 2.1.0-SNAPSHOT. does it matter ? – Mike Dec 20 '16 at 15:36
  • does the http site copty screenshot ?Itry and not successed. can you give me your e-mail address? – Mike Dec 20 '16 at 15:41
  • Is there another way that I use 4.4.1 carbon ws2oservers.sh to start my microservice bundle? – Mike Dec 20 '16 at 16:14
  • @ThusithaThilinaDayaratne – Mike Dec 20 '16 at 16:14
  • You can't use carbon kernel 4.4.1 to deploy Mircoservices. As you have mentioned yu need to change the version to 2.1.0 and build. – Thusitha Thilina Dayaratne Dec 21 '16 at 00:49
  • yeah,I have changed the msf4j.verison to 2.1.0 ,But it is successful to build and there is no the server zip as you have mentioned – Mike Dec 21 '16 at 02:04
  • a part of the bundle's pom.xml . 1.0.6 2.1.4 2.0.0 2.1.0 2.1.0 5.1.0 6.0.0 1.0.05.0.0 – Mike Dec 21 '16 at 02:09
  • osgi> install file:D:\ProgramData\vianet2\v3\t\msf4j-master\samples\stockquote\bundle\target\stockquote-bundle-2.1.1-SNAPSHOT.jar gogo: BundleException: Error reading bundle content. what is the problem? @ThusithaThilinaDayaratne – Mike Dec 21 '16 at 02:58
  • In fact ,there is no the zip wso2 MSF4J product in your official code .@ThusithaThilinaDayaratne – Mike Dec 21 '16 at 03:10
  • There are some issues in the documentation. We will fix them in next releases. Please follow the below steps 1. Go to samples/stockquote/bundle/resource directory 2. Change the MSF4J version to 2.1.0 in the pom.xml 3. Run a mvn clean install 4. Go to target/wso2msf4j-2.1.0/osgi directory 5. Create a directory and names it as dropins 6. Copy your build stockquote bundle to that folder 7. Go to target/wso2msf4j-2.1.0/bin directory 8. Start the server using carbon.sh|bat script – Thusitha Thilina Dayaratne Dec 21 '16 at 04:40
  • if i exit from the osgi console after sh carbon.sh,the bundle which have started is stopped and disapper. That is to say that there is no microservice bundle. – Mike Dec 21 '16 at 06:22
  • The osgi console on my terminal shell can't be always opened. – Mike Dec 21 '16 at 06:24
  • @ThusithaThilinaDayaratne – Mike Dec 21 '16 at 06:24
  • another question,if I moved my bundle jar (ms3-2.1.0.jar) to dropins and ./carbon.sh ,there is no my bundle to installed. – Mike Dec 21 '16 at 06:40
  • When you put the bundle in dropins directory whenever server start it will be installed. But if you install the bundle using OSGi console then it get removed in next start – Thusitha Thilina Dayaratne Dec 21 '16 at 06:51
  • I have not enough reputation. I put it the bundle jar in the dropins directory and sh carbon.sh . as you say,the bundle will be installed. But I use "lb" command to search my bundle and did not find it. The following screen :65 ACTIVE org.wso2.carbon.metrics.core_2.0.0 68 ACTIVE org.wso2.carbon.metrics.jdbc.core_2.0.0 69 ACTIVE org.wso2.carbon.metrics.jdbc.reporter_2.0.0 70 ACTIVE org.wso2.carbon.transport.http.netty_2.1.4 71 ACTIVE reflections_0.9.10.wso2v1 72 ACTIVE snakeyaml_1.16.0.wso2v1 – Mike Dec 21 '16 at 07:54
  • by the way , what does do? plz can you explain the effect? – Mike Dec 21 '16 at 07:58
  • When you put the bundle in dropins directory whenever server start it will be installed. I do it as you say, there is no my bundle yet. @ThusithaThilinaDayaratne – Mike Dec 21 '16 at 13:19