基于对象值的骆驼路由 [英] Camel routing based on object value
问题描述
我有两个简单的 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.
参考:http://camel.apache.org/content-based-router.html
要在 json marshalling 期间忽略字段,您可以使用 @JsonIgnore - Jackson 注释.
To ignore a field during json marshalling , you can use @JsonIgnore - Jackson annotation.
这篇关于基于对象值的骆驼路由的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!