How to create spring bean which is “Kafka SINK” bean to refresh the context from config server

I hope to add a listener that allow me to pull messages from Kafka topic. Upon receiving message and filtering based on application name, context refresh request is sent to Spring Config Server, which refreshes properties from Spring Config Server.

However, my application is not spring boot application, and I found that almost every document I read need spring boot application to achieve that goal. Is there any possibility I can add such stream listener in Spring Bean without Spring boot Application?

I have created a bean KafkaListener. And also added annotation like @EnableBinding(Sink.class). But the annotation I added throw java.lang.NoSuchMethodError, then block the running process, cannot reach the constructor part.

Here is my code

public class ApiApplication {

    public void configRefreshSink(RefreshRemoteApplicationEvent event) {"ApiApplication.configRefreshSink() called");
        String applicationToRefreshContext = event.getDestinationService();
        if (applicationToRefreshContext.startsWith(this.applicationName)) {
            Set<String> keys = contextRefresher.refresh();
  "Received remote refresh request. Keys refreshed: " + keys);
        }"Received remote refresh request. Destination: " + event.getDestinationService());

These are the errors I got

Caused by: org.springframework.beans.BeanInstantiationException: Failed to instantiate []: Constructor threw exception; nested exception is java.lang.NoSuchMethodError: org/springframework/util/Assert.notNull(Ljava/lang/Object;Ljava/util/function/Supplier;)V (loaded from file:xxxxx/repository/org/springframework/spring-core/4.3.22.RELEASE/spring-core-4.3.22.RELEASE.jar by

Leave a Reply

1 Comment threads
0 Thread replies
Most reacted comment
Hottest comment thread
1 Comment authors
Jason Recent comment authors
newest oldest most voted
Notify of
  1. The error

NoSuchMethodError: org/springframework/util/Assert.notNull(Ljava/lang/Object;Ljava/util/function/Supplier;)V

means that the version of Spring Framework is too old – that method was added in Spring Framework 5.0

  1. Spring Cloud Stream (@StreamListener) requires Spring Boot; it won’t work without Boot.