使用 Spring Cloud Dataflow 基于内容的路由 [英] Content based routing using Spring Cloud Dataflow

查看:45
本文介绍了使用 Spring Cloud Dataflow 基于内容的路由的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要使用 Spring Cloud Dataflow 实现基于内容的路由和过滤.

I need to achieve content based routing and filtering using Spring Cloud Dataflow.

例如如果我的 processor 的输入是一个字符串.如果字符串包含 say xyz 我需要将它传递给我的 Spring Cloud Stream 中的组件/步骤 X;否则我希望它转到我的流的组件/步骤 Y.

For e.g. If the input to my processor is a String. If the String contains say xyz I need to pass it to component/step X in my Spring Cloud Stream; otherwise I want it to go to component/step Y of my Stream.

我知道可以使用 router-sink 来实现相同的功能;但是我想使用路由\决策作为 processor;因为我的决策应用程序是我的 Stream 中的处理器.

I know router-sink can be used to achieve the same; however I wanted to use the routing\decision making as a processor; because my decision making apps are the processors in my Stream.

实现相同目标的最佳方法是什么?

What is the best way to achieve the same?

推荐答案

如果您在处理器中使用 StreamListener,您可以使用 StreamListener 注释多个方法String 参数,然后使用条件支持来确定将信息发送(路由)到哪里.这是docs<的相关部分/a>.尽管它谈论的是不同的 POJO,但您可以将这个概念扩展到您要完成的任务.

If you are using StreamListener in your processor, you can have multiple methods annotated with StreamListener taking a String argument, then using the conditional support to determine where to send (route) the information to. Here is the relevant section for this from the docs. Although it is talking about different POJO's, you can extend the concept to what you are trying to accomplish.

这篇关于使用 Spring Cloud Dataflow 基于内容的路由的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆