Hi ONAP Developers and PTLs,



I'm pleased to announce that MSB JAVA SDK is provided to facilitate the point 
to point communication between ONAP Microservices now.




It's pretty simple and straightforward to use it.




First, add this dependency to your project pom file.


  <dependency>


          <groupId>org.onap.msb.sdk</groupId>


                        <artifactId>msb-java-sdk</artifactId>


                        <version>1.0.0-SNAPSHOT</version>


        </dependency>  

    

Then, you can access the REST service like a normal JAVA object. MSB JAVA SDK 
takes care of service dicovery and routing for you, an it also maps the JSON 
response to a simple JAVA object, make it very handy for the developers.


String MSB_IP="127.0.0.1"

int MSB_Port=10081
 
MSBServiceClient msbClient = new MSBServiceClient(MSB_IP, MSB_Port)
 
RestServiceCreater restServiceCreater =

    new RestServiceCreater(msbClient)
 
AnimalServiceClient implProxy =

    restServiceCreater.createService(AnimalServiceClient.class)
 
Animal animal = implProxy.queryAnimal("panda").execute().body()

System.out.println("animal:" + animal)




An full example is also available for your reference here: 
https://gerrit.onap.org/r/gitweb?p=msb/java-sdk.gita=treef=exampleh=1c331f86cbcbdb8cc2935d8ac41169da1a523ec5hb=refs/heads/master




Currently, only JAVA SDK is provided. If you project is based on Python or you 
don't have time to switch to MSB JAVA SDK, you can still leverage MSB Internal 
API Gateway to access the services. For that, the only thing to do is send the 
request to the MSB internal API gateway IP and Port.




Besides,

If you would like to test it, please start MSB using docker first.


1. Run the Consul dockers.
sudo docker run -d --net=host --name msb_consul consul agent -dev



2. Run the MSB dockers.
sudo docker run -d --net=host --name msb_discovery zhaohuabing/msb_discovery
sudo docker run -d --net=host -e "ROUTE_LABELS=visualRange:1" --name 
internal_msb_apigateway zhaohuabing/msb_apigateway






3. Check the MSB portal to make sure everything is OK


http://127.0.0.1/msb




Cheers,

Huabing
_______________________________________________
onap-discuss mailing list
onap-discuss@lists.onap.org
https://lists.onap.org/mailman/listinfo/onap-discuss

Reply via email to