我有视频流
http | customprocessor
自定义处理器(UsageProcessor)的代码如下
public class UsageProcessor {
private double ratePerSecond = 0.1;
private double ratePerMB = 0.05;
@Transformer(inputChannel = Processor.INPUT, outputChannel = Processor.OUTPUT)
public UsageCostDetail processUsageCost(UsageDetail usageDetail) {
UsageCostDetail usageCostDetail = new UsageCostDetail();
usageCostDetail.setUserId(usageDetail.getUserId());
usageCostDetail.setCallCost(usageDetail.getDuration() * this.ratePerSecond);
usageCostDetail.setDataCost(usageDetail.getData() * this.ratePerMB);
return usageCostDetail;
}
}
从POSTMAN发送以下JSON请求到流时>]
{"userId":"user1", "duration":200, "data":"3000"}
在使用情况处理器日志中获得以下错误
"Caused by: org.springframework.expression.spel.SpelEvaluationException: EL1004E: Method call: Method processUsageCost(byte[]) cannot be found on type"
但是在使用UsageDetailSender自动生成源数据的情况下,具有以下流的相同处理器可以正常工作>
custom source | custom processor where custom source is below "UsageDetailSender" and custom processor is above "UsageProcessor" @EnableScheduling @EnableBinding(Source.class) public class UsageDetailSender { @Autowired private Source source; private String[] users = {"user1", "user2", "user3", "user4", "user5"}; @Scheduled(fixedDelay = 1000) public void sendEvents() { UsageDetail usageDetail = new UsageDetail(); usageDetail.setUserId(this.users[new Random().nextInt(5)]); usageDetail.setDuration(new Random().nextInt(300)); usageDetail.setData(new Random().nextInt(700)); //message emitted to kafka output channel called output this.source.output().send(MessageBuilder.withPayload(usageDetail).build()); } }
[需要执行哪些操作以确保自定义处理器成功处理从HTTP源接收的数据,而没有
"Caused by: org.springframework.expression.spel.SpelEvaluationException: EL1004E: Method call: Method processUsageCost(byte[]) cannot be found on type"
我有一个流http | customprocessor自定义处理器(UsageProcessor)的代码如下:public class UsageProcessor {private double ratePerSecond = 0.1;私人双人间...
通过更改处理器代码解决了该问题。