繁体   English   中英

Flume-HDFS的单个文件中包含2条消息

[英]Flume - 2 messages in a single file in HDFS

我正在尝试使用Apache Flume从IBM MQ接收消息。 我得到以下配置:

# Source definition
u.sources.s1.type=jms
u.sources.s1.initialContextFactory=ABC
u.sources.s1.connectionFactory=<my connection factory>
u.sources.s1.providerURL=ABC
u.sources.s1.destinationName=r1
u.sources.s1.destinationType=QUEUE
# Channel definition
u.channels.c1.type=file
u.channels.c1.capacity=10000000
u.channels.c1.checkpointDir=/checkpointdir
u.channels.c1.transactionCapacity=10000
u.channels.c1.dataDirs=/datadir
# Sink definition
u.sinks.r1.type=hdfs
u.sinks.r1.channel=c1
u.sinks.r1.hdfs.path=/message/%Y%m%d
u.sinks.r1.hdfs.filePrefix=e_
u.sinks.r1.hdfs.fileSuffix=.xml
u.sinks.r1.hdfs.fileType = DataStream
u.sinks.r1.hdfs.writeFormat=Text
u.sinks.r1.hdfs.useLocalTimeStamp=TRUE

问题是当我提取邮件时,有2条消息被合并为1条单个消息。

例如:假设Source发送3条xml消息:

  1. <id>1</id><name>Test 1</name>

  2. <id>2</id><name>Test 2</name>

  3. <id>3</id><name>Test 3</name>

当我在HDFS中收到相同的消息时,请在2个xml文件中获取消息,如下所示:

event_1.xml

<id>1</id><name>Test 1</name>
<id>2</id><name>Test 2</name>

event_2.xml

<id>3</id><name>Test 3</name>

预期结果是将所有3条xml消息都放在HDFS的3个单独文件中,例如event_1.xml; event_2.xml; event_3.xml

在接收器中使用以下配置解决了该问题:

hdfs.rollSize=0
hdfs.rollInterval=1
hdfs.rollCount=1

这有助于将消息作为单个消息接收,而不是将两个消息聚合为一个消息。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM