Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/381.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java 带有apache kafka的反应式非阻塞方法Micronaut_Java_Rx Java_Micronaut_Micronaut Rest_Micronaut Kafka - Fatal编程技术网

Java 带有apache kafka的反应式非阻塞方法Micronaut

Java 带有apache kafka的反应式非阻塞方法Micronaut,java,rx-java,micronaut,micronaut-rest,micronaut-kafka,Java,Rx Java,Micronaut,Micronaut Rest,Micronaut Kafka,我试图从Micronaut kafka实现中获得非阻塞响应,但是返回值不起作用 public class ProductManager implements IProductManager{ private final ApplicationContext applicationContext; public ProductManager(ApplicationContext applicationContext) { this.applicationC

我试图从Micronaut kafka实现中获得非阻塞响应,但是返回值不起作用

public class ProductManager implements IProductManager{
    private final ApplicationContext applicationContext;
    
    public ProductManager(ApplicationContext applicationContext) {
        this.applicationContext = applicationContext;
    }

    @Override
    public ProductViewModel findFreeText(String text) {
       
        final ProductViewModel model = new ProductViewModel();
        IProductProducer client = applicationContext.getBean(IProductProducer.class);
         client.findFreeText(text).subscribe(item -> {
          System.out.println(item);
        });
         return model;
    }
}
subscribe方法不起作用,调试器永远不会达到这一点。我想从卡夫卡侦听器中获取值

卡夫卡制作人

@KafkaClient
public interface IProductProducer {
    
    @Topic(ProductTopicConstants.GET_FREE_TEXT_SEARCH)
    Flowable<ProductViewModel> findFreeText(String text);
}
@KafkaListener(offsetReset = OffsetReset.EARLIEST)
public class ProductListener {
    private static final Logger LOG = LoggerFactory.getLogger(ProductListener.class);

    @Topic(ProductTopicConstants.GET_FREE_TEXT_SEARCH)
    public Flowable<Product>> findByFreeText(String text) {
        LOG.info("Listening value = ", text);
        
        return Flowable.just(new Product("This is the test", 0,"This is test description"));
    }
}
@KafkaClient
公共接口IPProductProducer{
@主题(ProductTopicConstants.GET\u FREE\u TEXT\u SEARCH)
可流动findFreeText(字符串文本);
}
卡夫卡听众

@KafkaClient
public interface IProductProducer {
    
    @Topic(ProductTopicConstants.GET_FREE_TEXT_SEARCH)
    Flowable<ProductViewModel> findFreeText(String text);
}
@KafkaListener(offsetReset = OffsetReset.EARLIEST)
public class ProductListener {
    private static final Logger LOG = LoggerFactory.getLogger(ProductListener.class);

    @Topic(ProductTopicConstants.GET_FREE_TEXT_SEARCH)
    public Flowable<Product>> findByFreeText(String text) {
        LOG.info("Listening value = ", text);
        
        return Flowable.just(new Product("This is the test", 0,"This is test description"));
    }
}
@KafkaListener(offsetReset=offsetReset.earlime)
公共类ProductListener{
私有静态最终记录器LOG=LoggerFactory.getLogger(ProductListener.class);
@主题(ProductTopicConstants.GET\u FREE\u TEXT\u SEARCH)
公共可流动>findByFreeText(字符串文本){
LOG.info(“侦听值=”,text);
返回可流动。只是(新产品(“这是测试”,0,“这是测试说明”);
}
}
Micronaut非阻塞方法文件


您使用的是Micronaut 1.0.0.M3吗?@JeffScottBrown Na我使用的是Micronaut 2.1.0,这只是我指的文档。这不是对您问题的回答,但您应该使用与您使用的软件版本相对应的文档。这些可能包括和。是的,有道理,但是这些文档也有相同的说明。这并不能解释为什么断点从未被击中,但是
ProductManager
中的
findFreeText
方法在
model
填充之前不容易返回吗?您使用的是Micronaut 1.0.0.M3吗?@JeffScottBrown我使用的是Micronaut 2.1.0,这只是我指的文档。这不是对你问题的回答,但你应该使用与你使用的软件版本相对应的文档。这些可能包括和。是的,有道理,但是这些文档也有相同的说明。这并不能解释为什么断点从未被命中,但是
ProductManager
中的
findFreeText
方法在
model
填充之前不容易返回吗?