[英]how to extract Collection payload records from Spring cloud data flow aggregator application output in next Transformer module
I am using SCDF [ Spring Cloud Data Flow ] and in my stream I am aggregating payloads and in next transformer module I would like to get size of the received payload [ Which is a collection object output by aggregator application as per aggregation feature ] 我正在使用SCDF [Spring Cloud Data Flow],并且在我的流中,我正在聚合有效负载,并且在下一个转换器模块中,我想获取接收到的有效负载的大小[这是聚合器应用程序根据聚合功能输出的收集对象]
Example Stream : 示例流:
stream create file_agr_trc_log --definition "file --directory=/Users/keerthikanth/Documents/GroovySampleCodes/test --filename-pattern='UNITINFO_DWH.txt' --mode=lines --outputType=plain/text | aggregator --release='size() == 1000' --aggregation=\"#this.![new String(payload)]\" --group-timeout=4 --message-store-type=simple --correlation='T(Thread).currentThread().id' | log " --deploy
File /Users/keerthikanth/Documents/GroovySampleCodes/test/UNITINFO_DWH.txt contains 文件/Users/keerthikanth/Documents/GroovySampleCodes/test/UNITINFO_DWH.txt包含
A 一种
B 乙
C C
D d
E Ë
F F
G G
H H
I 一世
After execution of stream , Aggregator app which used aggregation [ --aggregation=\\"#this.![new String(payload)]\\" ] produced output a collection like below in log application 流执行后,使用聚合[--aggregation = \\“#this。![new String(payload)] \\”]的Aggregator应用在日志应用中生成了如下所示的集合
[ A, B,C,D,E,F,G,H,I ] [A,B,C,D,E,F,G,H,I]
Actual Problem : 实际问题:
When I applied new custom transformer application after aggregator app inorder to find size and first record of collection , I am getting wrong records when i tried to fetch first record of collection i,e Getting [ as first element "," as second element "A" as third element . 当我在聚合器应用程序之后应用新的自定义转换器应用程序以查找集合的大小和第一条记录时,当我尝试获取集合的第一条记录时,我得到了错误的记录,即[作为第一个元素“,”作为第二个元素“ A作为第三要素。
So indirectly when collection payload output from aggregator module , it is getting converted to string. 因此,当从聚合器模块输出收集有效负载时,间接将其转换为字符串。
I tried to apply spring.cloud.stream.bindings.output.content-type='application/x-java-object;type=java.util.List' in aggregator and spring.cloud.stream.bindings.input.content-type='application/x-java-object;type=java.util.List' in custom transformer but still facing same issue like it is considering all the elements as part of collection including [ , ] charectors 我试图在聚合器和spring.cloud.stream.bindings.input.content-中应用spring.cloud.stream.bindings.output.content-type ='application / x-java-object; type = java.util.List'自定义转换器中的type ='application / x-java-object; type = java.util.List',但仍面临着同样的问题,因为它正在考虑将所有元素视为集合的一部分,包括[,]字符
Another Stream with content-type 另一个具有内容类型的流
stream create file_agr_trc_log --definition "file --directory=/Users/keerthikanth/Documents/GroovySampleCodes/test --filename-pattern='UNITINFO_DWH.txt' --mode=lines --outputType=plain/text | aggregator --aggregation=\"#this.![new String(payload)]\" --release='size() == 1000' --group-timeout=4 --message-store-type=simple --correlation='T(Thread).currentThread().id' --spring.cloud.stream.bindings.output.content-type='application/x-java-object;type=java.util.List' | transCount --spring.cloud.stream.bindings.input.content-type='application/x-java-object;type=java.util.List' | log " --deploy
Customer Transformer : 客户变压器:
@EnableBinding(Processor.class)
public class processorApp {
@ServiceActivator(inputChannel = Processor.INPUT, outputChannel = Processor.OUTPUT)
public String transformer(Collection payloadList) {
System.out.println("Size of Payload" + payloadList.size());
System.out.println("Payload "+ payloadList.iterator().next().toString() );
return payload;
}
Can anyone suggest me on how to fetch size of the received collection payload from aggregator app in custom transformer. 谁能建议我如何从自定义转换器中的聚合器应用中获取接收到的集合有效负载的大小。 even after applying content-type it is not considering. 即使在应用内容类型之后也没有考虑。 Even with default aggregation also same situation as providing list output but receiving transformer considering every character as a element of the list 即使使用默认聚合,情况也与提供列表输出相同,但是接收转换器将每个字符都视为列表的元素
My output should be like First element - total size of elements in that collection 我的输出应该像第一个元素-该集合中元素的总大小
A - 8 Size A-8尺寸
Why would you expect it to be a collection if your aggregation app actually produces the String based on instruction provided by you: --aggregation=\\"#this.![new String(payload)]\\"
. 如果您的聚合应用程序实际上根据您提供的指令生成了String,您为什么会期望它是一个集合:-- --aggregation=\\"#this.![new String(payload)]\\"
。
Basically you don't need to provide any aggregation
option for your case since it will default to java.util.List
. 基本上,您不需要为案例提供任何 aggregation
选项,因为它将默认为java.util.List
。 Please see the aggregator's README for more details 请参阅聚合器的自述文件以了解更多详细信息
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.