需要关于aws S3的Spring Integration示例的示例代码作为inBound和apache kafka作为出站[关闭]

问题描述 投票:0回答:1

在Spring Integration上需要示例,将aws s3作为入站,将apache kafka作为出站。

我想从aws s3读取数据并需要解析它们并将其生成为apache kafka主题

amazon-s3 apache-kafka spring-integration spring-cloud-stream
1个回答
1
投票

这是一些代码片段。它不起作用,但至少可以从一开始。这里没有人会为你编写代码:

<bean id="s3SessionFactory" 
           class="org.springframework.integration.aws.support.S3SessionFactory"/>

<int-aws:s3-inbound-channel-adapter channel="s3Channel"
                   session-factory="s3SessionFactory"
                   filename-pattern="*.txt"
                   local-directory="."
                   remote-directory-expression="'my_bucket'">
    <int:poller fixed-rate="1000"/>
</int-aws:s3-inbound-channel-adapter>


<int:transformer input-channel="s3Channel" output-channel="kafkaChannel"
       ref="myTransformer"/>

<int-kafka:outbound-channel-adapter
                                kafka-template="template"
                                channel="kafkaChannel"
                                topic="foo"
                                message-key-expression="'bar'"
                                partition-id-expression="2">
</int-kafka:outbound-channel-adapter>

<bean id="template" class="org.springframework.kafka.core.KafkaTemplate">
    <constructor-arg>
        <bean class="org.springframework.kafka.core.DefaultKafkaProducerFactory">
            <constructor-arg>
                <map>
                    <entry key="bootstrap.servers" value="localhost:9092" />
                </map>
            </constructor-arg>
        </bean>
    </constructor-arg>
</bean>
© www.soinside.com 2019 - 2024. All rights reserved.