Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/314.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Apache camel Akka/Camel非类型ConsumerActor未从基于文件的队列中消费_Apache Camel_Akka - Fatal编程技术网

Apache camel Akka/Camel非类型ConsumerActor未从基于文件的队列中消费

Apache camel Akka/Camel非类型ConsumerActor未从基于文件的队列中消费,apache-camel,akka,Apache Camel,Akka,我正试图使用以下lib版本从“scratch”(读作“noob”)开始组装我的第一个Akka/Camel应用程序: 阿克卡骆驼:2.2.0-RC1 根据我能找到的所有文档(Akka文档、用户组等),我要从基于文件的队列中消费所需做的全部工作就是以以下方式设置我的系统: 主要类别: actorSystem = ActorSystem.create("my-system"); Props props = new Props(Supervisor.class); ActorRef supervi

我正试图使用以下lib版本从“scratch”(读作“noob”)开始组装我的第一个Akka/Camel应用程序:

  • 阿克卡骆驼:2.2.0-RC1
根据我能找到的所有文档(Akka文档、用户组等),我要从基于文件的队列中消费所需做的全部工作就是以以下方式设置我的系统:

主要类别:

actorSystem = ActorSystem.create("my-system");

Props props = new Props(Supervisor.class);
ActorRef supervisor = actorSystem.actorOf(props, "supervisor");

Camel camel = CamelExtension.get(actorSystem);
CamelContext camelContext = camel.context();
camelContext.start();
主管级别:

import akka.actor.ActorRef;
import akka.actor.Props;
import akka.camel.javaapi.UntypedConsumerActor;
import org.apache.camel.Message;

/**
 * Manages creation and supervision of UploadBatchWorkers.
 */
public class Supervisor extends UntypedConsumerActor {    
    @Override
    public String getEndpointUri() {
        return "file:///Users/myhome/queue";
    }

    @Override
    public void preStart() {
        String test = "test";
    }

    @Override
    public void onReceive(Object message) {
        if (message instanceof CamelMessage) {
            // do something
        }
    }
我的问题是,即使我知道supervisor对象正在创建,并且在对preStart()方法的“test”行进行调试时中断(更不用说,如果我显式地“告诉”它处理得很好),它也不会从定义的端点消耗,即使我有另一个应用程序向同一个端点生成消息


知道我做错了什么吗?

尝试将
onReceive
中的
instanceof
更改为:

if (message instanceof CamelMessage){
  //do processing here
}

其中,
CamelMessage
来自包
akka.camel
。这就是akka camel文档中的示例所做的

好的,问题是我自己的错,如果您查看UntypedConsumerActor继承的消费者特征,在示例代码中可以清楚地看到

此方法:

@Override
public void preStart() {
    String test = "test";
}
重写其父级的preStart()方法,对吗?好的,父方法实际上是向即时创建的端点注册使用者的方法,因此虽然可以重写它,但必须调用super(),否则它将无法工作


希望这对以后的人有用

谢谢,我试过了,但这与是否调用该方法无关。使消费者开始使用队列的任何切换都不会发生。