Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/google-apps-script/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Spring integration 更改弹簧集成过滤器内的有效负载_Spring Integration - Fatal编程技术网

Spring integration 更改弹簧集成过滤器内的有效负载

Spring integration 更改弹簧集成过滤器内的有效负载,spring-integration,Spring Integration,我正在编写一个带有Spring集成的过滤器 在这个过滤器中,我检查一组先决条件。如果不满足任何先决条件,我将需要更改消息有效负载(甚至标头),以添加用户要执行的操作集,以满足它,并通过discart通道将其返回给用户 我可以使用服务激活器,但我认为过滤器在这种情况下更具描述性 最干净的方法是什么 这是一种伪代码: @Filter public boolean checkEventPreconditions(Message<?> messageIn) { //Here I am

我正在编写一个带有Spring集成的过滤器

在这个过滤器中,我检查一组先决条件。如果不满足任何先决条件,我将需要更改消息有效负载(甚至标头),以添加用户要执行的操作集,以满足它,并通过discart通道将其返回给用户

我可以使用服务激活器,但我认为过滤器在这种情况下更具描述性

最干净的方法是什么

这是一种伪代码:

@Filter
public boolean checkEventPreconditions(Message<?> messageIn)
{
    //Here I am returning the set of actions to satisfied preconditions
    List<Integer> actionsId = returnActions();

    if(actionsId.isEmpty())
    {
        return true;
    }
    else
    {
        //Here I need to add actionsId to the message
        return false;
    }

}
@过滤器
公共布尔CheckEventPremissions(messageIn)
{
//在这里,我将操作集返回到满足的前提条件
List actionsId=returnActions();
if(actionsId.isEmpty())
{
返回true;
}
其他的
{
//在这里,我需要将actionsId添加到消息中
返回false;
}
}

谢谢

不,不要混淆问题:过滤器只需检查是否进一步发送消息或丢弃消息。 更改消息是transformer的责任。
因此,您要做的应该放在discardflow中。

问题是,我知道在创建returnActions方法(涉及执行groovy脚本)时是否应该对消息进行分类。如果我将最后一部分传递给discard流,我将需要再次执行groovy脚本……因此,只需将
returnActions()
的结果放在消息头中,并重用筛选器和discrad流中的值。OK。这将是一个更好的方法。谢谢