Red Hat Integration - Service Registry
  • Preface
  • Installation
    • Setting Up Project
    • PostgreSQL Database Deployment
      • Install Crunchy Postgres for Kubernetes Operator
      • Deploy PostgreSQL Database
    • Service Registry Deployment
      • Install Service Registry Operator
      • Configuring Service Registry
  • Testing
    • Testing Service Registry
    • REST API Testing Using Postman
    • Performance Testing Using hey
  • Security
    • Securing Service Registry
    • Red Hat Single Sign-On Deployment
      • Installing Red Hat Single Sign-On Operator
      • Deploy Red Hat Single Sign-On
      • Create Keycloak Realm For Service Registry
    • Configuring Service Registry
      • Service Registry with HTTPS
      • Service Registry without HTTPS (less secure)
      • Configuring Service Registry
      • Enable HTTP Basic Authentication
      • Enable Annonymous Read Access
      • Enable Role-Based Authorization
    • Testing Secure Service Registry API
  • Client Application
    • Create SSO Client for Application
    • Kafka Client Application
  • Appendix
    • CRD References
    • Installation Helper Script
    • Service Registry & SSO Integration with Self-Signed Certificate
Powered by GitBook
On this page
  • Example Application
  • Kafka serializer/deserializer (SerDes) configuration properties
  • Running Example Application
  1. Client Application

Kafka Client Application

PreviousCreate SSO Client for ApplicationNextCRD References

Last updated 2 years ago

This section provides sample code snippets to configure Service Registry Kafka serializer/deserializer (SerDes) configuration properties to access the secure Service Registry server.

Apicurio Registry supports both OAuth and BASIC auth at the same time. a custom authentication handler has been implemented to use OAuth Client Credentials flow to support BASIC auth. In other words, the client can provide BASIC auth credentials, and the server-side custom handler will extract the username/password and then use OAuth Client Credentials flow against the Keycloak server to obtain an access token. Once that is done, everything else works the same as if the client had provided an OAuth bearer token to begin with.

Visit for detailed information on how to configure Kafka SerDes in your producer and consumer Java client applications.

Example Application

We're going to use for demostration. Visit for more Java example applications.

Kafka serializer/deserializer (SerDes) configuration properties

Based on the authentication mechanism you're using for Service Registry, you need to update the when creating Kaka and object as the snippets below.

Basic Authentication configuration

props.putIfAbsent(SerdeConfig.AUTH_USERNAME, "test-kafka-registry");
props.putIfAbsent(SerdeConfig.AUTH_PASSWORD, "93b77291-ccbb-4fc1-9264-562e8c421ffd");

OAuth configuration

props.putIfAbsent(SerdeConfig.AUTH_CLIENT_ID, "test-kafka-registry");
props.putIfAbsent(SerdeConfig.AUTH_CLIENT_SECRET, "93b77291-ccbb-4fc1-9264-562e8c421ffd");
props.putIfAbsent(SerdeConfig.AUTH_TOKEN_ENDPOINT, "https://keycloak-service-registry.apps.cluster-qmkwt.qmkwt.sandbox19.opentlc.com/auth/realms/registry/protocol/openid-connect/token");

Running Example Application

If the Kafka serializer/deserializer (SerDes) configuration properties are correct, you should be able to see application output similar to this when you run the application. This means the client application can connect and authenticate to Service Registry successfully.

Starting example SimpleAvroExample
SLF4J: Failed to load class "org.slf4j.impl.StaticLoggerBinder".
SLF4J: Defaulting to no-operation (NOP) logger implementation
SLF4J: See http://www.slf4j.org/codes.html#StaticLoggerBinder for further details.
Producing (5) messages.
Messages successfully produced.
Closing the producer.
Creating the consumer.
Subscribing to topic SimpleAvroExample
Consuming (5) messages.
No messages waiting...
No messages waiting...
No messages waiting...
Consumed a message: Hello (0)! @ Sun Oct 30 13:40:42 ICT 2022
Consumed a message: Hello (1)! @ Sun Oct 30 13:40:44 ICT 2022
Consumed a message: Hello (2)! @ Sun Oct 30 13:40:44 ICT 2022
Consumed a message: Hello (3)! @ Sun Oct 30 13:40:44 ICT 2022
Consumed a message: Hello (4)! @ Sun Oct 30 13:40:44 ICT 2022
Done (success).

Process finished with exit code 0
official document
this example application
Apicurio Registry Example Applications repository
example application code
Producer
Consumer