REST Proxy Readme

Overview

The REST proxy provides basic produce, consume and Avro schema resolve capabilities for clients which can’t use the java kafka-client library. There are three main flows: send a message along with a schema, retrieve a schema ID and send message(s) along with the ID for smaller POST payloads, and GET a list of messages. The schemas below give a high-level overview of processing; camelcased boxes and messages refer to classes and DTO’s in the code. See the source code for more details; error and exception handling is left out of the diagrams.

Send message and schema

In this case, the full schema for the key and value messages is sent along with the request. Note that the schema will be verified by looking it up in the schema registry; if the schema is not found there the call results in a 404 Not Found.

Actor client

client -> StreamController++: POST ProduceStreamRequest\n(schema + message)
StreamController -> SecurityService ++: isProduceAuthorized
SecurityService --> StreamController --: AuthorizationResult
StreamController -> ProducerService ++: ProduceRequest
ProducerService -> AvroService ++: lookupSchema
AvroService --> ProducerService --: schema ID
ProducerService --> StreamController --: ProduceResponse
StreamController --> client --: ProduceStreamResponse

Retrieve schema ID before sending

In this case, first a schema lookup is performed, the retrieved schema ID is sent along with the message. This results in smaller POST payloads if more than one message with the same schema is going to be sent.

Actor client
Participant AvroController
Participant StreamController

client -> AvroController ++: POST SchemaRequest
AvroController -> SecurityService ++: isRetrieveSchemaAuthorized
SecurityService --> AvroController --: AuthorizationResult
AvroController -> AvroService ++: getSubject
AvroService --> AvroController --: subject (String)
AvroController -> AvroService ++: lookupSchema
AvroService --> AvroController --: id (Optional<Integer>)
AvroController --> client --: SchemaResponse

client -> StreamController++: POST ProduceStreamRequest\n(schema ID + message)
StreamController -> SecurityService ++: isProduceAuthorized
SecurityService --> StreamController --: AuthorizationResult
StreamController -> ProducerService ++: ProduceRequest
ProducerService --> StreamController --: ProduceResponse
StreamController --> client --: ProduceStreamResponse

Consume messages

This will return a list of retrieved messages. The polling timeout and maximum number of messages to return can be passed along in the request.

Actor client

client -> StreamController ++: consumeMessages
StreamController -> SecurityService ++: isConsumeAuthorized
SecurityService --> StreamController --: AuthorizationResult
StreamController -> ConsumerService ++: ConsumeRequest
ConsumerService --> StreamController --: List<ConsumedMessage>
StreamController --> client --: List<ConsumedStreamMessage>