I want to create a camel akka actor, it will consume from a MQTT server. But when I recive a message from the MQTT server it throws an error and tell me thant the actor doesn't exist.
My actor
public class GetListener extends UntypedConsumerActor{
private String endpointUri = "mqtt://get?subscribeTopicNames=TOPIC/TO/SUBSCRIBE/#";
@Override
public String getEndpointUri() {
return endpointUri;
}
@Override
public void onReceive(Object message) throws Throwable {
System.out.println(message.toString());
}
}
My main class
public class Main {
public static void main(String[] args) {
final ActorSystem system = ActorSystem.create("mqtt_listener");
MQTTComponent mqtt = new MQTTComponent();
mqtt.setHost("url");
mqtt.setUserName("username");
mqtt.setPassword("password");
Camel camel = CamelExtension.get(system);
CamelContext camelContext = camel.context();
camelContext.addComponent("mqtt", mqtt);
final ActorRef getListener = system.actorOf(Props.create(GetListener.class),"get_listener");
}
}
The error:
[DEBUG] [03/20/2017 09:40:00.072] [main] [EventStream(akka://mqtt_listener)] logger log1-Logging$DefaultLogger started
[DEBUG] [03/20/2017 09:40:00.074] [main] [EventStream(akka://mqtt_listener)] Default Loggers started
[DEBUG] [03/20/2017 09:40:00.080] [mqtt_listener-akka.actor.default-dispatcher-3] [akka://mqtt_listener/system] now supervising Actor[akka://mqtt_listener/system/deadLetterListener#764565502]
[DEBUG] [03/20/2017 09:40:00.081] [mqtt_listener-akka.actor.default-dispatcher-4] [akka://mqtt_listener/system/deadLetterListener] started (akka.event.DeadLetterListener@60b7f843)
[DEBUG] [03/20/2017 09:40:00.081] [mqtt_listener-akka.actor.default-dispatcher-3] [akka://mqtt_listener/system] now supervising Actor[akka://mqtt_listener/system/eventStreamUnsubscriber-1#552703831]
[DEBUG] [03/20/2017 09:40:00.083] [mqtt_listener-akka.actor.default-dispatcher-2] [akka://mqtt_listener/system/eventStreamUnsubscriber-1] started (akka.event.EventStreamUnsubscriber@4fe3dfa6)
[DEBUG] [03/20/2017 09:40:00.084] [mqtt_listener-akka.actor.default-dispatcher-3] [akka://mqtt_listener/system/log1-Logging$DefaultLogger] now watched by Actor[akka://mqtt_listener/system/eventStreamUnsubscriber-1#552703831]
[DEBUG] [03/20/2017 09:40:00.084] [mqtt_listener-akka.actor.default-dispatcher-5] [akka://mqtt_listener/system/deadLetterListener] now watched by Actor[akka://mqtt_listener/system/eventStreamUnsubscriber-1#552703831]
[DEBUG] [03/20/2017 09:40:00.109] [mqtt_listener-akka.actor.default-dispatcher-2] [akka://mqtt_listener/user] now supervising Actor[akka://mqtt_listener/user/camel-supervisor#-614549969]
Loaded 189 type converters
Apache Camel 2.18.3 (CamelContext: mqtt_listener) is starting
StreamCaching is enabled on CamelContext: mqtt_listener
JMX is disabled
StreamCaching in use with spool directory: C:\Users\User\AppData\Local\Temp\camel\camel-tmp-d8096f43-d6b1-4be8-8f6d-a4b819eb66c5 and rules: [Spool > 128K body size]
Total 0 routes, of which 0 are started.
Apache Camel 2.18.3 (CamelContext: mqtt_listener) started in 0.066 seconds
[DEBUG] [03/20/2017 09:40:00.622] [main] [akka.camel.internal.DefaultCamel(akka://mqtt_listener)] Started CamelContext[mqtt_listener] for ActorSystem[mqtt_listener]
[DEBUG] [03/20/2017 09:40:00.626] [mqtt_listener-akka.actor.default-dispatcher-5] [akka://mqtt_listener/user/camel-supervisor/activationTracker] started (akka.camel.internal.ActivationTracker@2fceac9b)
[DEBUG] [03/20/2017 09:40:00.626] [mqtt_listener-akka.actor.default-dispatcher-3] [akka://mqtt_listener/user/camel-supervisor] started (akka.camel.internal.CamelSupervisor@2841250f)
[DEBUG] [03/20/2017 09:40:00.626] [mqtt_listener-akka.actor.default-dispatcher-3] [akka://mqtt_listener/user/camel-supervisor] now supervising Actor[akka://mqtt_listener/user/camel-supervisor/activationTracker#-635350442]
[DEBUG] [03/20/2017 09:40:00.626] [mqtt_listener-akka.actor.default-dispatcher-3] [akka://mqtt_listener/user/camel-supervisor] now supervising Actor[akka://mqtt_listener/user/camel-supervisor/registry#1165920753]
[DEBUG] [03/20/2017 09:40:00.630] [mqtt_listener-akka.actor.default-dispatcher-4] [akka://mqtt_listener/user/camel-supervisor/registry/producerRegistrar] started (akka.camel.internal.ProducerRegistrar@7931b7bd)
[DEBUG] [03/20/2017 09:40:00.630] [mqtt_listener-akka.actor.default-dispatcher-5] [akka://mqtt_listener/user] now supervising Actor[akka://mqtt_listener/user/get_listener#1461216176]
[DEBUG] [03/20/2017 09:40:00.630] [mqtt_listener-akka.actor.default-dispatcher-2] [akka://mqtt_listener/user/camel-supervisor/registry] started (akka.camel.internal.Registry@78a12aba)
[DEBUG] [03/20/2017 09:40:00.631] [mqtt_listener-akka.actor.default-dispatcher-2] [akka://mqtt_listener/user/camel-supervisor/registry] now supervising Actor[akka://mqtt_listener/user/camel-supervisor/registry/producerRegistrar#-2115751173]
[DEBUG] [03/20/2017 09:40:00.631] [mqtt_listener-akka.actor.default-dispatcher-2] [akka://mqtt_listener/user/camel-supervisor/registry] now supervising Actor[akka://mqtt_listener/user/camel-supervisor/registry/consumerRegistrar#2039347646]
[DEBUG] [03/20/2017 09:40:00.631] [mqtt_listener-akka.actor.default-dispatcher-6] [akka://mqtt_listener/user/camel-supervisor/registry/consumerRegistrar] started (akka.camel.internal.ConsumerRegistrar@281cb0e3)
[DEBUG] [03/20/2017 09:40:00.634] [mqtt_listener-akka.actor.default-dispatcher-3] [akka://mqtt_listener/user/get_listener] started (es.ipp.akka.sended.GetListener@338ca26e)
[DEBUG] [03/20/2017 09:40:00.635] [mqtt_listener-akka.actor.default-dispatcher-3] [akka://mqtt_listener/user/get_listener] now watched by Actor[akka://mqtt_listener/user/camel-supervisor#-614549969]
Supplied URI 'mqtt://get?subscribeTopicNames=TOPIC/TO/SUBSCRIBE/#' contains unsafe characters, please check encoding
Connecting to tcp://168.192.1.11:1883 using 10 seconds timeout
MQTT Connection connected to tcp://168.192.1.11:1883
Route: akka://mqtt_listener/user/get_listener started and consuming from: mqtt://get?subscribeTopicNames=TOPIC/TO/SUBSCRIBE/#
[DEBUG] [03/20/2017 09:40:00.947] [hawtdispatch-DEFAULT-2] [akka.actor.LocalActorRefProvider(akka://mqtt_listener)] look-up of unknown path [akka://mqtt_listener/user/get_listener] failed
Error processing exchange.. Exchange[ID-ME-61712-1489999200163-0-2]. Caused by: [akka.camel.ActorNotRegisteredException - Actor [akka://mqtt_listener/user/get_listener] doesn't exist]
akka.camel.ActorNotRegisteredException: Actor [akka://mqtt_listener/user/get_listener] doesn't exist
at akka.camel.internal.component.ActorProducer.$anonfun$actorFor$1(ActorComponent.scala:175) ~[akka-camel_2.12-2.4.17.jar:?]
at scala.Option.getOrElse(Option.scala:121) ~[scala-library-2.12.1.jar:?]
at akka.camel.internal.component.ActorProducer.actorFor(ActorComponent.scala:175) ~[akka-camel_2.12-2.4.17.jar:?]
at akka.camel.internal.component.ActorProducer.fireAndForget(ActorComponent.scala:172) ~[akka-camel_2.12-2.4.17.jar:?]
at akka.camel.internal.component.ActorProducer.processExchangeAdapter(ActorComponent.scala:143) ~[akka-camel_2.12-2.4.17.jar:?]
at akka.camel.internal.component.ActorProducer.process(ActorComponent.scala:120) ~[akka-camel_2.12-2.4.17.jar:?]
at org.apache.camel.processor.SendProcessor.process(SendProcessor.java:145) ~[camel-core-2.18.3.jar:2.18.3]
at org.apache.camel.processor.RedeliveryErrorHandler.process(RedeliveryErrorHandler.java:542) [camel-core-2.18.3.jar:2.18.3]
at org.apache.camel.processor.CamelInternalProcessor.process(CamelInternalProcessor.java:197) [camel-core-2.18.3.jar:2.18.3]
at org.apache.camel.processor.CamelInternalProcessor.process(CamelInternalProcessor.java:197) [camel-core-2.18.3.jar:2.18.3]
at org.apache.camel.component.mqtt.MQTTConsumer.processExchange(MQTTConsumer.java:51) [camel-mqtt-2.18.2.jar:2.18.2]
at org.apache.camel.component.mqtt.MQTTEndpoint$2.onPublish(MQTTEndpoint.java:257) [camel-mqtt-2.18.2.jar:2.18.2]
at org.fusesource.mqtt.client.CallbackConnection$8.onPublish(CallbackConnection.java:521) [mqtt-client-1.14.jar:1.14]
at org.fusesource.mqtt.client.CallbackConnection.toReceiver(CallbackConnection.java:911) [mqtt-client-1.14.jar:1.14]
at org.fusesource.mqtt.client.CallbackConnection.processFrame(CallbackConnection.java:808) [mqtt-client-1.14.jar:1.14]
at org.fusesource.mqtt.client.CallbackConnection.access$1700(CallbackConnection.java:73) [mqtt-client-1.14.jar:1.14]
at org.fusesource.mqtt.client.CallbackConnection$6.onTransportCommand(CallbackConnection.java:425) [mqtt-client-1.14.jar:1.14]
at org.fusesource.hawtdispatch.transport.TcpTransport.drainInbound(TcpTransport.java:713) [hawtdispatch-transport-1.22.jar:1.22]
at org.fusesource.hawtdispatch.transport.TcpTransport$6.run(TcpTransport.java:592) [hawtdispatch-transport-1.22.jar:1.22]
at org.fusesource.hawtdispatch.internal.NioDispatchSource$3.run(NioDispatchSource.java:209) [hawtdispatch-1.22.jar:1.22]
at org.fusesource.hawtdispatch.internal.SerialDispatchQueue.run(SerialDispatchQueue.java:100) [hawtdispatch-1.22.jar:1.22]
at org.fusesource.hawtdispatch.internal.pool.SimpleThread.run(SimpleThread.java:77) [hawtdispatch-1.22.jar:1.22]
Failed delivery for (MessageId: ID-ME-61712-1489999200163-0-1 on ExchangeId: ID-ME-61712-1489999200163-0-2).
Exhausted after delivery attempt: 1 caught: akka.camel.ActorNotRegisteredException: Actor [akka://mqtt_listener/user/get_listener] doesn't exist
Message History
---------------------------------------------------------------------------------------------------------------------------------------
RouteId ProcessorId Processor Elapsed (ms)
[akka://mqtt_listen] [akka://mqtt_listen] [mqtt://get?subscribeTopicNames=TOPIC/TO/SUBSCRIBE ] [ 23]
[akka://mqtt_listen] [to1 ] [akka://mqtt_listener/user/get_listener?autoAck=true&replyTimeout=60000 millise] [ 15]
Where I have to register the actor to catch correctly the message?