简体   繁体   English

如何使用一个单独的routebuilder映射2个经过不同编组和解组的服务?

[英]How do I map 2 services that are marshalled and unmarshalled differently using one single routebuilder?

I have 2 services( For now, lets assume service A and B). 我有2个服务(现在,假设服务A和B)。 Service A uses legacy code and is marshalled and unmarshalled differently in the processor. 服务A使用旧代码,并且在处理器中的编组和解组方式有所不同。 Service B uses the latest code(JaxB Binding) and is marshalled differently. 服务B使用最新的代码(JaxB绑定),并且以不同的方式编组。 Currently, I have written a Routebuilder that maps to the appropriate service based on the header(using choice operation: if header=X, map to processor A). 目前,我已经编写了一个Routebuilder,它基于标头映射到适当的服务(使用选择操作:如果header = X,则映射到处理器A)。 However, Service A still uses old processors to perform the marshalling and unmarshalling. 但是,服务A仍使用旧处理器来执行编组和拆组。 Is there a way to tell camel to route to a particular service based on how the service is marshalled or unmarshalled. 有没有一种方法可以告诉骆驼根据服务的编组方式或非编组方式路由到特定的服务。 If you need more clarifications, please let me know. 如果您需要更多说明,请告诉我。

Thanks, Gautham 谢谢Gautham

Well, first question that comes to mind is, why would you want to route based on implementation specific details? 好吧,第一个想到的问题是,为什么要基于实现特定的细节进行路由? If you change your marshalling you need to change your routing logic as well. 如果更改编组,则还需要更改路由逻辑。 It would be easier to split the mapping into seperate routes so service A exist in route A and service B in route B. Then you simply route to route A or route B based on header or some other information. 将映射拆分成单独的路由会更容易,因此服务A存在于路由A中,服务B存在于路由B中。然后,您可以根据标头或其他一些信息简单地路由到路由A或路由B。 That way, if you change the marshalling in the future or anything else you don't need to change your routing logic. 这样,如果您将来更改编组或其他任何内容,则无需更改路由逻辑。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM