As I understand, while using Schema registry confluent docker image ( not with zookeeper resiliency, but with kafka resiliency), we can advertise the hostname of the container to Kafka by using the SCHEMA_REGISTRY_HOST_NAME
env variable.
If I try to use the SCHEMA_REGISTRY_PORT
,
I get the following error :
PORT is deprecated. Please use SCHEMA_REGISTRY_LISTENERS instead.
Why cannot we set the port associated ? I can get this dynamic port ( the dynamic port the host machine mapped dynamically to my container) but how am I supposed to share it with Kafka ?
EDIT 1 :
To add more details, here is an example of assignment made by the schema registry coordinator :
[2019-10-25 11:55:47,813] INFO Finished rebalance with master election result: Assignment{version=1, error=0, master='sr-1-7a9a403a-63cc-4fed-b548-10ea440863d5', masterIdentity=version=1,host=10.135.124.179,port=29932,scheme=http,masterEligibility=true} (io.confluent.kafka.schemaregistry.masterelector.kafka.KafkaGroupMasterElector)
As you can see there is a hostname and a port ( in bold).
The hostname comes from the variable SCHEMA_REGISTRY_HOST_NAME
but according to the code, the port comes from here :
/**
* A Schema Registry instance's identity is in part the port it listens on. Currently the port can
* either be configured via the deprecated `port` configuration, or via the `listeners`
* configuration.
*
* <p>This method uses `Application.parseListeners()` from `rest-utils` to get a list of
* listeners, and returns the port of the first listener to be used for the instance's identity.
*
* <p></p>In theory, any port from any listener would be sufficient. Choosing the first, instead
* of say the last, is arbitrary.
*/
// TODO: once RestConfig.PORT_CONFIG is deprecated, remove the port parameter.
static SchemeAndPort getSchemeAndPortForIdentity(int port, List<String> configuredListeners,
String requestedScheme)
So the only way to advertize the port is by setting it using the listeners, which can be annoying ( but still feasible as a workaround).