小编Mir*_*lav的帖子

如何在Webflux应用程序中使Spring Cloud Stream消费者?

我有一个基于 Webflux 的微服务,它有一个简单的反应存储库:

    public interface NotificationRepository extends ReactiveMongoRepository<Notification, ObjectId> {
    }
Run Code Online (Sandbox Code Playgroud)

现在我想扩展这个微服务来使用来自 Kafka 的事件消息。然后该消息/事件将被保存到数据库中。

对于 Kafka 监听器,我使用了 Spring Cloud Stream。我创建了一些简单的消费者,它工作得很好 - 我能够使用消息并将其保存到数据库中。

    @Bean
    public Consumer<KStream<String, Event>> documents(NotificationRepository repository) {
        return input ->
                input.foreach((key, value) -> {
                    LOG.info("Received event, Key: {}, value: {}", key, value);
                    repository.save(initNotification(value)).subscribe();
                });
    }
Run Code Online (Sandbox Code Playgroud)

但这是连接 Spring Cloud Stream 消费者和反应式存储库的正确方法吗?看起来不像是我subscribe()最后必须打电话的时候。

我阅读了Spring Cloud Stream 文档(针对 3.0.0 版本),他们说

Native support for reactive programming - since v3.0.0 we no longer distribute spring-cloud-stream-reactive modules and instead relying on …
Run Code Online (Sandbox Code Playgroud)

reactive-programming apache-kafka project-reactor spring-cloud-stream spring-webflux

6
推荐指数
1
解决办法
4619
查看次数

jOOQ中的列大小

使用ResultSetI可以从中ResultSetMetaData获取以字符为单位的数据库列的大小(例如15 varchar(15)metaData.getColumnDisplaySize(index)。我可以用这种方式获得这种尺寸jOOQ吗?

因为ResultSet我对UDT有问题,并且已经在使用jOOQ数据库访问(并且与UDT配合良好),所以如果是的话,那将是完美的

sql jooq

3
推荐指数
1
解决办法
655
查看次数

来自 jaxws-tools:3.0.0 的 Wsimport 在 ClassNotFoundException 上崩溃

当我将 jaxws-tools 升级到 3.0.0 时,我的 wsimport Gradle 任务开始因 ClassNotFoundException 崩溃。

我有一个使用 Springinitializr 创建的简单 Gradle 项目。我其中有一个 wsimport 任务,是我根据 gradle wsimport问题以及其他来源创建的。build.gradle 如下所示

plugins {
    id 'org.springframework.boot' version '2.4.2'
    id 'io.spring.dependency-management' version '1.0.11.RELEASE'
    id 'java'
}

group = 'com.example'
version = '0.0.1-SNAPSHOT'
sourceCompatibility = '11'

configurations {
    jaxws
}

task wsimport {
    description = 'Generate classes from wsdl using wsimport'

    def wsdlFile = file("${projectDir}/src/main/resources/soap/wsdl/hello.wsdl")
    ext.classesDir = "${buildDir}/classes/generated"

    doLast {
        ant {
            mkdir(dir: classesDir)

            taskdef(name: 'wsimport',
                    classname: 'com.sun.tools.ws.ant.WsImport',
                    classpath: configurations.jaxws.asPath
            )
            wsimport(
                    destdir: …
Run Code Online (Sandbox Code Playgroud)

java jax-ws wsimport gradle

2
推荐指数
1
解决办法
4472
查看次数