Core Concepts

Web Client

Introduction

Modern connected applications routinely require access to external services in the cloud. To facilitate this, KOS provides access to a Jetty HttpClient instance, which can be used to perform both synchronous and asynchronous HTTP requests. By using this existing client instance, applications can avoid resource management associated with creating new clients or including additional client libraries.

Overview

While Jetty’s HttpClient is feature-rich, it does not provide the convenience of JSON-type conversion available in other libraries such as Spring’s RestTemplate. To address this, KOS provides a JsonTemplate instance which wraps HttpClient and provides type conversion similar to RestTemplate.

KOS is based on a microservices architecture, which means that HTTP requests are a common method of communication with the outside world as well as between applications, both locally and within clusters. Although a standard HTTP client can be used in all of these cases, KOS provides different clients for these different use cases.

As mentioned above, when connecting to external services in the cloud using HTTP, JsonTemplate and the underlying Jetty HttpClient is the preferred client. However, when communicating between applications or within a cluster, ApiClient should be used.

KOS provides clustering support that utilizes a mesh network between nodes. This network abstracts away IP addresses and utilizes a concept of node names. ApiClient is cluster-aware and allows requests to be sent to nodes as opposed to IP addresses.

ApiClient is also highly optimized for endpoints that are in the same JVM, bypassing the network stack entirely, effectively performing a function call to an endpoint. In addition, the ApiClient methods are identical between local and cluster calls, so that using ApiClient to interface to an application also allows the application to be moved to another node in the cluster without changing application logic (other than replacing the node name in the ApiClient calls). In addition, both ApiClient and JsonTemplate return the same responses, which allows common code to process responses regardless of the client used.

For more information about clustering within KOS, see Clustering.

Previous
Next
On this page
Java Development
Seamlessly transition from Legacy+ systems to Freestyle microdosing and advanced distributed dispense systems.
UI Development
Using KOS SDKs, integrating Consumer and Non-consumer facing UIs becomes seamless, giving you less hassle and more time to create.
Video Library
Meet some of our development team, as they lead you through the tools, features, and tips and tricks of various KOS tools.
Resources
Familiarize yourself with KOS terminology, our reference materials, and explore additional resources that complement your KOS journey.
Copyright © 2024 TCCC. All rights reserved.