骆驼多消费者实施问题 [英] Camel Multiple Consumers Implementation Issue

查看:84
本文介绍了骆驼多消费者实施问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

比方说,我有一个Job Scheduler,其中有4个使用者A,B,C和D.类型X的作业必须路由到使用者A,类型Y的使用者路由到消费者B,依此类推.使用者A,B,C和D将作为独立的应用程序运行,而不受本地或远程的任何依赖.

Let's say I have a Job Scheduler which has 4 consumers A, B, C and D. Jobs of type X will have to be routed to Consumer A, type Y to Consumer B and so on. Consumers A, B, C and D are to run as independent applications without any dependency, either locally or remotely.

消费者使用不同的时间来完成其工作,然后将其路由到Job Scheduler进行汇总.

The consumers take varying times to complete their jobs, which are subsequently routed to the Job Scheduler for aggregation.

可能还需要其中一名消费者的克隆人才能共享其合格的工作.但是,一个作业只能处理一次.

Clones of one of the consumers may also be needed to share its eligible jobs. A job should however be processed only once.

基于内容的路由器是否是最佳解决方案?请注意,我需要自定义的工作计划程序,因为它只有智能才能在消费者之间分配工作.

Is Content-based router the best solution for this? Mind you, I need the custom job scheduler, because it only has the intelligence to split up a job among the consumers.

还是有更好的方法来解决这个问题?我不需要代理的那些功能,例如自动切换到另一个使用者(负载平衡)以及发生故障的情况.

Or is there any better way to handle this? I don't require those features of the broker like automatically switching over to another consumer (load balancing) and such in case of a failure.

推荐答案

我不能完全确定我是否关注您.听起来这是一个非常简单的异步处理方案.

I'm not completly sure that I follow you. This sounds like a rather straight forward scenario for asychronous processing.

我不确定您打算如何将这些作业发送到Camel应用程序,但是鉴于您可以在某个地方接收到它们,您可能会使用基于内容的简单路由器继续前进.

I'm not sure how you plan to send these jobs to the Camel application, but given you can receive them somewhere you could probably go ahead with a simple content based router.

鉴于您对消费者的需求,我会选择JMS队列(使用Apache ActiveMQ或类似的代理中间件),每种作业类型一个队列.这样可以轻松地将使用者分配到不同的计算机上,而无需真正更改代码.

Given your requirements for the consumers, I would go for JMS queues (using Apache ActiveMQ or similar broker middleware), one queue per job type. This makes it easy to distribute consumers to different machines without really changing the code.

// Central node routes
from("xxx:routeJob")
   .choice()
       .when(header("type").isEqualTo("x"))
           .to("jms:queue:processJobTypeX")
       .when(header("type").isEqualTo("y"))
           .to("jms:queue:processJobTypeY")
       .otherwise()
           .to("jms:queue:processJobTypeZ"); 

 from("jms:queue:aggregateJob")
    .bean(aggregate);

// different camel application (may be duplicated for multiple instances).
from("jms:queue:processJobTypeX")
  .bean(heavyProcessing)
  .to("jms:queue:aggregateJob");

// Yet another camel application
from("jms:queue:processJobTypeY")
  .bean(lightProcessing)
  .to("jms:queue:aggregateJob");

请重新访问您的问题以获得更好的答案:)

Please revisit your question for a better answer :)

这篇关于骆驼多消费者实施问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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