MessageHandlingException在使用spring integration 5.1.3.RELEASE时出现在过滤器上

MessageHandlingException在使用spring integration 5.1.3.RELEASE时出现在过滤器上,spring,spring-integration,Spring,Spring Integration,因此,我尝试运行一个通过以下流程运行的测试: @EnableBinding({Sink.class,Source.class}) public class MyFlow { public @Bean IntegrationFlow myIntegrationFlow() { return IntegrationFlows.from("input") // .transform(new JsonToObjectTransformer()) // .filter(new MessageD

因此,我尝试运行一个通过以下流程运行的测试:

@EnableBinding({Sink.class,Source.class})
public class MyFlow {
public @Bean IntegrationFlow myIntegrationFlow() {
  return IntegrationFlows.from("input") //
  .transform(new JsonToObjectTransformer()) //
  .filter(new MessageDroolsFilter())
  .........
  get();
}

 public class MessageDroolsFilter implements MessageSelector {

   @Override
   public boolean accept(Message<?> message) {
     return true;
   }

 }
}
编辑:

我有一个路由器,我希望根据接收到的对象类型路由消息

private IntegrationFlow messagesFlow() {
  return sf -> sf //
      .routeToRecipients(routeMessages());
} 


private Consumer<RecipientListRouterSpec> routeMessages() {
  return sf -> sf
      .recipientFlow(new GenericSelector<MyObject1>() {

      @Override
      public boolean accept(MyObject1 source) {
        return source instanceof MyObject1;
      }},
        f -> f.transform(myTransformer)
              .filter(new DiscardHeaderMessageFilter()) 
              .handle(myHandler))
    .recipientFlow(new GenericSelector<MyObject2>() {
      @Override
      public boolean accept(MyObject2 source) {
        return source instanceof MyObject2;
      }
    }
    .defaultOutputChannel(DISCARD_CHANNEL);
}

看起来您的问题与前面提到的
.filter()
无关

请仔细查看堆栈跟踪:

at org.springframework.integration.filter.AbstractMessageProcessingSelector.accept(AbstractMessageProcessingSelector.java:62)
at org.springframework.integration.router.RecipientListRouter$Recipient.accept(RecipientListRouter.java:320)
因此,您在某个地方有一个
routeToRecipients()
,其中一个
recipients()
不符合预期

更新

错误是可以预料的:收件人列表路由器针对当前邮件与每个收件人进行协商。当您的消息是
MyObject1
时,第一个消息
.recipientFlow(new GenericSelector()
)运行良好,因为它的方法签名与您调用它的对象兼容。但是当相同的
MyObject1
到达第二个消息时-
.recipientFlow(new GenericSelector())
-,它无法调用它,因为类型不兼容

完全不清楚当参数正好是MyObject1时,为什么要在方法中执行MyObject1;的源实例

我想说的是,签名必须是这样的:

.recipientFlow(new GenericSelector<Object>() {

  @Override
  public boolean accept(Object source) {
    return source instanceof MyObject1;
  }}
.recipientFlow(新的GenericSelector(){
@凌驾
公共布尔接受(对象源){
MyObject 1的返回源实例;
}}

我的意思是通用的
对象
类型与发送的任何有效负载兼容。完全不清楚为什么IDE没有告诉您MyObject2的
源实例是冗余的,因为调用此方法时它总是
true
。只有当我们通过reflect调用它时,此方法对任何其他类型都失败的问题ion,就像SpEL的情况一样。

是的,谢谢,你说得对,我已经更新了原始问题,仍然有错误请查看我答案中的更新。
at org.springframework.integration.filter.AbstractMessageProcessingSelector.accept(AbstractMessageProcessingSelector.java:62)
at org.springframework.integration.router.RecipientListRouter$Recipient.accept(RecipientListRouter.java:320)
.recipientFlow(new GenericSelector<Object>() {

  @Override
  public boolean accept(Object source) {
    return source instanceof MyObject1;
  }}