1

I'm developing an application with Spring Cloud Stream 3.1.3 and binder kafka with schema registry. This is the class I wrote for the Producer

@Slf4j
@EnableAutoConfiguration
@Component
public class Producer {

    private static final String PARTITION_KEY = "partitionKey";
    private static final String MESSAGE_ID = "messageId";

    @Autowired
    private StreamBridge streamBridge;

    public void produce(int messageId, Object message) {
        log.info("Sending test message through Kafka: {}", message);
        Message<Object> toProduce = MessageBuilder
                .withPayload(message)
                .setHeader(PARTITION_KEY, messageId)
                .build();

        streamBridge.send("produceMessage-out-0", toProduce);
    }
}

When streamBridge.send is invoked I get this error:

java.lang.ClassCastException: class org.springframework.cloud.stream.function.StreamBridge$$Lambda$1557/0x0000000800ab4c40 cannot be cast to class org.springframework.cloud.function.context.catalog.SimpleFunctionRegistry$FunctionInv
ocationWrapper (org.springframework.cloud.stream.function.StreamBridge$$Lambda$1557/0x0000000800ab4c40 and org.springframework.cloud.function.context.catalog.SimpleFunctionRegistry$FunctionInvocationWrapper are in unnamed module of
loader 'app')

Help is appreciated. Thanks

EDIT: I found this issue that describes my problem.

https://github.com/spring-cloud/spring-cloud-stream/issues/2101

Is there a workaround in order to make my code work with 3.1.3 version?

Vin
  • 701
  • 1
  • 9
  • 30

0 Answers0