代码之家  ›  专栏  ›  技术社区  ›  samba

需要Spring集成示例代码aws S3作为入站和apache kafka作为出站的示例[已关闭]

  •  0
  • samba  · 技术社区  · 8 年前

    需要aws s3入站和apache kafka出站的Spring集成示例。

    我想从aws s3读取数据,需要对其进行解析并将其生成到apache kafka主题

    1 回复  |  直到 8 年前
        1
  •  1
  •   Artem Bilan    8 年前

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

    <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>