Akka Camel RabbitMQ Creating New Connections Every Time -


i'm using akka-camel subscribe rabbitmq exchange. there several of these actors created... 1 per requested routingkey. exchange , queue doesn't change. each time new routingkey requested create new actor and, instead of new channel being created, brand new connection being created, undesirable. don't quite understand why new connection being created each time consumer actor being created.

here's actor code:

class commandconsumer(routingkey: string)   extends consumer actorlogging {    override def endpointuri = s"rabbitmq://localhost/hub_commands?exchangetype=topic&queue=test&autodelete=false&routingkey=$routingkey"    override def receive: receive = {     case msg: camelmessage => {       log.debug(s"received {}", msg.bodyas[string])       sender ! msg.bodyas[string]     }   } } 

i'm creating actor this:

context.actorof(commandconsumer.props("my.routing.key", sender)) 

update

here's need accomplish:

i'm writing tcp/ip server that, when client connection accepted, needs receive messages other components in back-end architecture. this, i'd use rabbitmq. after successful connection server, client send id, used part of routing key (e.g. command.<id>). rabbitmq connection , queue created when first client connects , routing key command.first_id. when next client connects add command.second_d routing key list of routing keys accepted, without creating new connection rabbitmq.

i believe expected. each akka camel actor have own camel context independent others. means each new actor create, creating new camel context new rabbitmq endpoint hold new rabbitmq connection , new channel.

if in scenario queue , exchange not change routing key, why don't have 1 akka camel actor consuming queue , actor managing bindings. every time there new routing key needs consumed, actor create rabbitmq connection, channel , call queuebind() new routing key. also, can have same actor unbinding undesired routing keys.


Comments

Popular posts from this blog

c++ - Difference between pre and post decrement in recursive function argument -

php - Nothing but 'run(); ' when browsing to my local project, how do I fix this? -

php - How can I echo out this array? -