Splitter EIP 可以拆分 HashMap 还是必须是 List
can the Splitter EIP split a HashMap or does it have to be a List
我正在尝试使用 Camel Splitter EIP 来拆分 Map,它似乎无法正常工作并且无法拆分 Map。除非,我遗漏了一些东西,...如果可能的话,请提出建议。
谢谢!!!
使用 Camel EIP 拆分器拆分映射。
<process id="getassetlisting" ref="getAssetListing" />
<split id="as2"
strategyRef="tsAggregationStrategy" streaming="true">
<simple>${body}</simple>
<log id="sl2" loggingLevel="INFO" message="Split Line ${body}"/>
</split>
GetAssetListing 片段
public void process(Exchange exchange) throws Exception {
log.info("Get Asset Listing :: Start");
custkey = (String)exchange.getIn().getHeader("CUSTKEY");
log.info("GetAssetListing - CUSTKEY: " + custkey);
queryRecordToDB(custkey);
for(Map.Entry m:assetMap.entrySet()){
log.info("Key: " + m.getKey() + " Value: " + m.getValue());
}
exchange.getIn().setBody(assetMap);
log.info("Get Asset Listing :: finish");
}
预期:拆分作为 Map 的输入交换
入站分离器
{BC104_Expander=05d52eb9-6d45-4683-bff2-e079d1d2f745,BC105_Steam_Turbine=1ddeae49-07ab-4872-817d-ba1dc1528fa2,DCM101A_Motor=6eea4f40-9114-491d-b2fb-34f7e9b122de,BCG901_Gearbox=cd46fc06-dc08-42c7-a73e-839d3b27d683,BCM102_Motor=652e4041-3c2b-410a-8ba0-12a2a53ec730,BC101_Compressor=50480a32-cd65-4b93-94f8-4ba50=cf46dec5,[ =]=cd413f1e-816f-466d-a706-b87ead050bac,BC901_Steam_Turbine=b4acecbb-fac1-4a99-ab95-24e1bc7f4286,DC101A_Compressor=bbd0a7d7-cb11-4a64-9168-b13ece4b215d,DCM101B_Motor =12819b1c-8dec-49e6-82cd-72e0de36331f,BCM901_Generator=96de09f5-6dac-458f-bcaa-6d67a340e731,BCM101_Motor=6cf41883-36c1-4eca-8325-54588982bdc8,[=5268]=2 -e9d2-4f33-b4e5-9d2031eaa60b,BCG101_Gearbox=49366bcc-bb6a-426f-8c5c-6d65d675ac90,DC101B_Compressor=21a60cce-094d-4844-b448-e9a955de418f,BC102_Compressor=493980230 -4fee-a9a3-e187e4c658ee,DCG901_Gearbox=d015e136-1110-4b6a-a9d2-48dd2ebc8c81,BCG102_Gearbox=f4402fb9-a638-46e1-93d3-bcb927c44ee4}
Split 的预期输出
BC104_Expander=05d52eb9-6d45-4683-bff2-e079d1d2f745
BC105_Steam_Turbine=1ddeae49-07ab-4872-817d-ba1dc1528fa2
DCM101A_Motor=6eea4f40-9114-491d-b2fb-34f7e9b122de
BCG901_Gearbox=cd46fc06-dc08-42c7-a73e-839d3b27d683
BCM102_Motor=652e4041-3c2b-410a-8ba0-12a2a53ec730
BC101_Compressor=50480a32-cd65-4b93-94f8-4ba50cf6dec5
DC102_Expander=cd413f1e-816f-466d-a706-b87ead050bac BC901_Steam_Turbine=b4acecbb-fac1-4a99-ab95-24e1bc7f4286 DC101A_Compressor=bbd0a7d7-cb11-4a64-9168-b13ece4b215d
DCM101B_Motor=12819b1c-8dec-49e6-82cd-72e0de36331f
BCM901_Generator=96de09f5-6dac-458f-bcaa-6d67a340e731
BCM101_Motor=6cf41883-36c1-4eca-8325-54588982bdc8 DC901_Steam_Turbine=27f68800-e9d2-4f33-b4e5-9d2031eaa60b BCG101_Gearbox=49366bcc-bb6a-426f-8c5c-6d65d675ac90
DC101B_Compressor=21a60cce-094d-4844-b448-e9a955de418f BC102_Compressor=49380230-99eb-4fee-a9a3-e187e4c658ee
DCG901_Gearbox=d015e136-1110-4b6a-a9d2-48dd2ebc8c81
BCG102_Gearbox=f4402fb9-a638-46e1-93d3-bcb927c44ee4
你可以用 Camel 拆分 任何你想要的 :-)
老实说,我从来没有用 Map 尝试过,但是 如果开箱即用不支持它,您可以实现一个 Bean 来按照您想要的方式进行操作 .
在骆驼路线中,您只需说
.split().method("mySplitterBean", "splitBody")
您的实施
public class MySplitterBean {
public Map<String, String> splitBody(String body) {
.... your splitting logic
}
}
我正在尝试使用 Camel Splitter EIP 来拆分 Map,它似乎无法正常工作并且无法拆分 Map。除非,我遗漏了一些东西,...如果可能的话,请提出建议。
谢谢!!!
使用 Camel EIP 拆分器拆分映射。
<process id="getassetlisting" ref="getAssetListing" />
<split id="as2"
strategyRef="tsAggregationStrategy" streaming="true">
<simple>${body}</simple>
<log id="sl2" loggingLevel="INFO" message="Split Line ${body}"/>
</split>
GetAssetListing 片段
public void process(Exchange exchange) throws Exception {
log.info("Get Asset Listing :: Start");
custkey = (String)exchange.getIn().getHeader("CUSTKEY");
log.info("GetAssetListing - CUSTKEY: " + custkey);
queryRecordToDB(custkey);
for(Map.Entry m:assetMap.entrySet()){
log.info("Key: " + m.getKey() + " Value: " + m.getValue());
}
exchange.getIn().setBody(assetMap);
log.info("Get Asset Listing :: finish");
}
预期:拆分作为 Map 的输入交换
入站分离器 {BC104_Expander=05d52eb9-6d45-4683-bff2-e079d1d2f745,BC105_Steam_Turbine=1ddeae49-07ab-4872-817d-ba1dc1528fa2,DCM101A_Motor=6eea4f40-9114-491d-b2fb-34f7e9b122de,BCG901_Gearbox=cd46fc06-dc08-42c7-a73e-839d3b27d683,BCM102_Motor=652e4041-3c2b-410a-8ba0-12a2a53ec730,BC101_Compressor=50480a32-cd65-4b93-94f8-4ba50=cf46dec5,[ =]=cd413f1e-816f-466d-a706-b87ead050bac,BC901_Steam_Turbine=b4acecbb-fac1-4a99-ab95-24e1bc7f4286,DC101A_Compressor=bbd0a7d7-cb11-4a64-9168-b13ece4b215d,DCM101B_Motor =12819b1c-8dec-49e6-82cd-72e0de36331f,BCM901_Generator=96de09f5-6dac-458f-bcaa-6d67a340e731,BCM101_Motor=6cf41883-36c1-4eca-8325-54588982bdc8,[=5268]=2 -e9d2-4f33-b4e5-9d2031eaa60b,BCG101_Gearbox=49366bcc-bb6a-426f-8c5c-6d65d675ac90,DC101B_Compressor=21a60cce-094d-4844-b448-e9a955de418f,BC102_Compressor=493980230 -4fee-a9a3-e187e4c658ee,DCG901_Gearbox=d015e136-1110-4b6a-a9d2-48dd2ebc8c81,BCG102_Gearbox=f4402fb9-a638-46e1-93d3-bcb927c44ee4}
Split 的预期输出
BC104_Expander=05d52eb9-6d45-4683-bff2-e079d1d2f745
BC105_Steam_Turbine=1ddeae49-07ab-4872-817d-ba1dc1528fa2
DCM101A_Motor=6eea4f40-9114-491d-b2fb-34f7e9b122de
BCG901_Gearbox=cd46fc06-dc08-42c7-a73e-839d3b27d683
BCM102_Motor=652e4041-3c2b-410a-8ba0-12a2a53ec730
BC101_Compressor=50480a32-cd65-4b93-94f8-4ba50cf6dec5
DC102_Expander=cd413f1e-816f-466d-a706-b87ead050bac BC901_Steam_Turbine=b4acecbb-fac1-4a99-ab95-24e1bc7f4286 DC101A_Compressor=bbd0a7d7-cb11-4a64-9168-b13ece4b215d DCM101B_Motor=12819b1c-8dec-49e6-82cd-72e0de36331f BCM901_Generator=96de09f5-6dac-458f-bcaa-6d67a340e731 BCM101_Motor=6cf41883-36c1-4eca-8325-54588982bdc8 DC901_Steam_Turbine=27f68800-e9d2-4f33-b4e5-9d2031eaa60b BCG101_Gearbox=49366bcc-bb6a-426f-8c5c-6d65d675ac90 DC101B_Compressor=21a60cce-094d-4844-b448-e9a955de418f BC102_Compressor=49380230-99eb-4fee-a9a3-e187e4c658ee DCG901_Gearbox=d015e136-1110-4b6a-a9d2-48dd2ebc8c81 BCG102_Gearbox=f4402fb9-a638-46e1-93d3-bcb927c44ee4
你可以用 Camel 拆分 任何你想要的 :-)
老实说,我从来没有用 Map 尝试过,但是 如果开箱即用不支持它,您可以实现一个 Bean 来按照您想要的方式进行操作 .
在骆驼路线中,您只需说
.split().method("mySplitterBean", "splitBody")
您的实施
public class MySplitterBean {
public Map<String, String> splitBody(String body) {
.... your splitting logic
}
}