title: Issue with Spring Cloud Stream using the Default Schema Registry client instead of the Avro Schema Registry client
body: <p>We are using Kafka with Spring Cloud Stream and we need to connect to a Confluent Schema Registry in our Spring Boot component see <a href="https://github.com/donalthurley/KafkaConsumeScsAndConfluent" rel="nofollow noreferrer">https://github.com/donalthurley/KafkaConsumeScsAndConfluent</a>.</p>
  
  <p>We have added the following configuration to create the required ConfluentSchemaRegistryClient bean see <a href="https://github.com/donalthurley/KafkaConsumeScsAndConfluent/blob/master/src/main/java/com/example/kafka/KafkaConfig.java" rel="nofollow noreferrer">https://github.com/donalthurley/KafkaConsumeScsAndConfluent/blob/master/src/main/java/com/example/kafka/KafkaConfig.java</a> which should override the default schema registry from Spring Cloud Stream.</p>
  
  <p>However we have been seeing the following failure intermittently after some deployments.</p>
  
  <pre><code>org.springframework.messaging.MessageDeliveryException: failed to send Message to channel
  </code></pre>
  
  <p>The underlying cause shows this stack trace</p>
  
  <pre><code>Caused by: java.lang.NullPointerException
      at     org.springframework.cloud.stream.schema.client.DefaultSchemaRegistryClient.register(DefaultSchemaRegistryClient.java:71)
      at org.springframework.cloud.stream.schema.avro.AvroSchemaRegistryClientMessageConverter.resolveSchemaForWriting(AvroSchemaRegistryClientMessageConverter.java:238)
      at org.springframework.cloud.stream.schema.avro.AbstractAvroMessageConverter.convertToInternal(AbstractAvroMessageConverter.java:179)
      at org.springframework.messaging.converter.AbstractMessageConverter.toMessage(AbstractMessageConverter.java:201)
      at org.springframework.messaging.converter.AbstractMessageConverter.toMessage(AbstractMessageConverter.java:191)
      at org.springframework.messaging.converter.CompositeMessageConverter.toMessage(CompositeMessageConverter.java:83)
      at org.springframework.cloud.stream.binding.MessageConverterConfigurer$OutboundContentTypeConvertingInterceptor.doPreSend(MessageConverterConfigurer.java:322)
      at org.springframework.cloud.stream.binding.MessageConverterConfigurer$AbstractContentTypeInterceptor.preSend(MessageConverterConfigurer.java:351)
      at org.springframework.integration.channel.AbstractMessageChannel$ChannelInterceptorList.preSend(AbstractMessageChannel.java:611)
      at org.springframework.integration.channel.AbstractMessageChannel.send(AbstractMessageChannel.java:453)
  </code></pre>
  
  <p>The fact that the DefaultSchemaRegistryClient is being invoked by the AvroSchemaRegistryClientMessageConverter would indicate to us that there is a problem with the wiring of our ConfluentSchemaRegistryClient bean.</p>
  
  <p>Is there something else required in our configuration to ensure the ConfluentSchemaRegistryClient bean is wired  correctly?</p>