Code Monkey home page Code Monkey logo

cargotracker-j12015's Introduction

Cargo Tracker and Micro-services

This project takes the original cargo tracker application which is, in the terminology of microservices a monolith, and splits out the pathfinder service as a separate micro service.

PathFinder Microservice

The Pathfinder micro service was originally embedded into the core Cargo tracker application. In this project it is separated out as an individual RESTful service with its own maven project pathfinder.

The Pathfinder application can then be run on Payara Micro using the command;

java -jar payara-micro.jar --deploy pathfinder-1.0-SNAPSHOT.war --autoBindHttp

This can also be run multiple times to "scale out" the micro service.

Load balancing configuration snippets for Nginx and HAProxy are provided at the root of the project to show how you would configure these tools to integrate the cargo tracker application and the pathfinder micro service into a functional service.

CargoTracker Monolith

The cargo-monolith maven project is the original Cargo Tracker application with the path finder functionality extracted and removed.

To ensure the application knows the URL of the path finder microservice the URL must be specified. There are two options for this;

  • You must edit the ejb-jar.xml in the WEB-INF directory and set below to the correct URL
            <env-entry>
                <env-entry-name>graphTraversalUrl</env-entry-name>
                <env-entry-type>java.lang.String</env-entry-type>
                <env-entry-value>http://127.0.0.1/pathfinder/rest/graph-traversal/shortest-path</env-entry-value>
            </env-entry>

Alternatively the ExternalRoutingService EJB can also retrieve the URL directly from JNDI. If you bind the URL to JNDI at /graphTraversalUrlJNDI

This can be done in GlassFish using the asadmin command

create-custom-resource --restype java.lang.String --factoryclass org.glassfish.resources.custom.factory.PrimitivesAndStringFactory --property value="http\:\/\/127.0.0.1\/pathfinder\/rest\/graph-traversal\/shortest-path" graphTraversalUrlJNDI

Once this has been configured the cargo-tracker.war file can be deployed to GlassFish

Running the Application

To run the application you must run GlassFish or Payara Server and deploy the configured cargo-tracker application as described above. You must also run one or more Payara Micro instances. Payara Micro automatically binds to the next available http port starting from 8080 when using the command line above.

Once you have the application deployed and Payara Micro running cargo tracker can be accessed via http://127.0.0.1/cargo-tracker/. To see the Pathfinder micro service in action navigate to;

  • Administration Interface
  • Book
  • run through the booking wizard.

In your Payara Micro log you will see a message like below when the service is called;

[2015-09-30T15:30:55.051+0100] [Payara 4.1] [INFO] [] [net.java.pathfinder.api.GraphTraversalService] [tid: _ThreadID=23 _ThreadName=http-listener(5)] [timeMillis: 1443623455051] [levelValue: 800] Path Finder Service called for USNYC to USDAL

If you are using the nginx snippet or haproxy snippet you should see load balancing between the Payara Micro instances. Demonstrating how easy it is to scale out the microservice.

cargotracker-j12015's People

Contributors

smillidge avatar

Watchers

James Cloos avatar Felipe Moraes avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.