基于对象值的骆驼路由 [英] Camel routing based on object value

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

问题描述

我有两条简单的Camel路由,用于写入jms队列并从中读取.我正在将序列化的对象放入队列.我可以反序列化它,并将其成功转换为json.

I have two simple Camel routes working for writing to a jms queue and reading from it. I am putting a serialized object to the queue. I am able to deserialize it and covert it to json successfully.

写作路线:

from("direct:message").to("jms:myqueu")

我的阅读路线:

from("jms:myqueu")
.marshal()
.json(JsonLibrary.Gson).
.to("file://cc")

现在我要检查对象中的字段并根据该字段进行路由.该字段也不应成为最终json的一部分.

Now i want to check a field within the object and route based on that.Also that field should not be part of the final json.

我可以检查对象中的值并基于该值进行路由(例如写入不同的文件吗?).我可以在pojo中添加注释,以避免最终json中的字段

Can i check the value within the object and route based on that( like write to different files?). I can add the annotation in the pojo to avoid the field in final json

我想到了将对象转换为json,然后发送到队列.然后我可以使用jsonpath进行条件路由.但是我该如何省略最终json中的字段?

I thought of converting object to json, and then sending to queue. Then i can use jsonpath for conditional routing. But then how can i omit a field from final json?

推荐答案

是的,您可以使用基于内容的路由来检查传入对象中的任何字段,然后根据该路由进行路由.

Yes, you can use content based routing to check any field in incoming object and do the routing based on that.

ref: http://camel.apache.org/content-based-router. html

要在json编组期间忽略字段,可以使用@JsonIgnore-Jackson批注.

To ignore a field during json marshalling , you can use @JsonIgnore - Jackson annotation.

这篇关于基于对象值的骆驼路由的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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