Chapter 7. Accessing the Inference Model with Java
In the previous chapter, you learned to develop and expose a model that produces data by using an inference API. That chapter covered half of the development; you learned only how to expose the model, but how about consuming this model from another service? Now it’s time to cover the other half, which involves writing the code to consume the API.
In this chapter, we’ll complete the previous example. You’ll create Java clients to consume the Fraud Inference API to detect whether a given transaction can be considered fraudulent. We’ll also show you how to write clients for Spring Boot and Quarkus by using both REST and gRPC.
Connecting to an Inference API with Quarkus
Quarkus provides two methods for implementing REST clients:
-
The Jakarta REST client is the standard Jakarta EE approach for interacting with RESTful services.
-
The MicroProfile REST client provides a type-safe approach to invoke RESTful services over HTTP, using as much of the Jakarta RESTful Web Services spec as possible. The REST client is defined as a Java interface, making it type-safe and providing the network configuration with Jakarta RESTful Web Services annotations.
In this section, you’ll develop a Quarkus service consuming the Fraud Detection model by using the MicroProfile REST client.
The Architecture
Let’s create a Quarkus service sending requests to the Fraud Inference API developed in the previous chapter. This service contains a list of all ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access