Skip to content
On this page

Connecting to your Grid

At this point, you should now have your TSF grid running locally, and understand how to add / modify your services and re-deploy those changes in your grid. The next step is to look at 2 different ways that you can connect to your grid and make requests for these services - this uses the other 2 projects (TSFClientExample and TSFSpringBootExample) that you downloaded in the previous step. For an in-depth look at how to write your client code, click here.

The 2 different ways to connect to your TSF grid are (both are described below):

  • Directly within your IDE workspace
  • Through a UI via a tomcat server

Directly

In our TSFClientExample project, you will see some example client code in src/main/java/com/example/client. You can play around with the existing client code, and add your own to connect to a new service executing within your TSF.

  • Once you have completed your client code changes, and want to test sending a message to the TSF grid, simply run your client code as a Java application in your workspace IDE.

You should see a message saying that it was able to connect to the grid, and get a response back. If you look at your TSF instance logs for the server that you have running in the grid, you should see the logs of processing that service.

Tomcat

Another way to connect to your TSF grid is through a UI that hits a URL on a spring boot tomcat server. To test this simply, our example walks you through starting a tomcat container, hitting a URL through the browser, which sends a request to the TSF, and displays the response back to the browser (You can add your own UI to make this process more sophisticated).

Follow the below instructions using our TSFSpringBootExample project to get this set up:

  1. Download the spring boot base image artifact from the download page on our website. Choose the appropriate platform, and the JDK version you would like our TSF jars to be compiled in.

  2. Load the downloaded tar into a docker image, using the below command

docker load -i <downloaded directory of tar>

This should have loaded the image tsf/tsf-spring-boot-java<jdk-version>:1.0

Now it is time to make changes to add your own endpoint URL to hit from the browser. To do this, open the file TSFSpringBootTestController.java. The URLs that can be hit from the browser are defined here, and these methods make calls to the TSF grid when hit. Again, you can play around with the existing URLs, and add your own.

Once you are done with your changes, follow the remainder of the steps to start your tomcat container.

  1. Open TSFSpringBootExample/src/main/resources/application.properties and follow the instruction in this file for which value to use for the server.address property. If you are following the below instructions to start the tomcat in a container, change the server.address to 0.0.0.0

  2. Build the TSFSpringBootExample project using Maven build - You should see this build successfully build the jar named tsf-spring-boot-example-0.0.1-SNAPSHOT.jar in your target folder.

  3. In the TSFSpringBootExample/build/Dockerfile, update the FROM like to use the spring boot base image that you just downloaded. Note: The ${SPRING_BOOT_IMAGE_TAG} is set to 1.0 so this does not have to be changed if it matches with your loaded image tag.

  4. Build the docker image using the following commands:

cd <Path to eclipse project>/TSFSpringBootExample
sh build/build.sh

This should have built the image tsf/spring-boot-example:test.

  1. Run the tomcat container using the following command:
docker run --network tsf-test --ip 10.0.0.99 -p 9999:9999 \
-d --name tomcat tsf/spring-boot-example:test

You should see Spring boot successfully start up in your tomcat container logs.

That's it! You are now ready to test everything end-to-end.

Go to your browser and attempt to hit one of the urls that that you created using the following format:

http://localhost:9999/service/<URL path of your choice>

Note, all URLs need to have the service prefix - for example, if you wanted to hit the testEcho example provided, you could run:

http://localhost:9999/service/testEcho/Hello

Created by Team Tessell