title: How to Configure Spring Cloud StreamBridge to produce Avro?
body: <p>So I am trying to use StreamBridge to dynamically send messages to different topics. I am successful in doing so if my output is a <strong>Message&lt; String&gt;</strong>, but not <strong>Message&lt; GenericRecord&gt;</strong></p>
  <p>Code example:</p>
  <pre><code>@StreamListener(Sink.INPUT)
  public void process(@Payload GenericRecord messageValue,
                      @Header(KafkaHeaders.RECEIVED_MESSAGE_KEY) GenericRecord messageKey,
                      @Header(&quot;Type&quot;) String type) {
      log.info(&quot;Processing Event --&gt; &quot; + messageValue);
  
      // Code...
  
      // convert to Message&lt;GenericRecord&gt;
      Message&lt;GenericRecord&gt; message = ...
  
      streamBridge.send(type, message);
  
      log.info(&quot;Processed Event --&gt; &quot; + messageValue);
  }
  </code></pre>
  <p>The error I get is <code>Caused by: org.springframework.messaging.converter.MessageConversionException: Could not write JSON: Not a map:</code> which I am guessing is because streamBridge acceptedOutputTypes = application/json</p>
  <pre><code>2020-06-28 04:42:55.670  INFO 54347 --- [container-0-C-1] o.s.c.f.c.c.SimpleFunctionRegistry       : Looking up function 'streamBridge' with acceptedOutputTypes: [application/json]
  </code></pre>
  <p>I tried modify accepted output type to be avro by setting the following in my properties, which did not work.</p>
  <pre><code>spring.cloud.stream.function.definition=streamBridge
  spring.kafka.producer.key-serializer=io.confluent.kafka.serializers.KafkaAvroSerializer
  spring.kafka.producer.value-serializer=io.confluent.kafka.serializers.KafkaAvroSerializer
  spring.cloud.stream.bindings.streamBridge-out-0.content-type=application/*+avro
  spring.cloud.stream.bindings.streamBridge-out-0.producer.use-native-encoding=true
  </code></pre>
  <p>Any ideas on how to configure StreamBridge to be avro?</p>
  <p>edit: I also tried <code>streamBridge.send(type, message, MimeType.valueOf(&quot;application/*+avro&quot;))</code> but that also had a conversion error.</p>