I am attempting to implement exactly-once delivery using Akka.Delivery between a local producer process and a remote consumer process. According to this article, I need to register the consumer controller with the producer controller. I have configured both projects and set everything up correctly. However, I am having issues with the registration process.
Here is the code block from the article:
private IActorRef CreateConsumerController()
{
var consumerControllerSettings = ConsumerController.Settings.Create(Context.System);
var consumerControllerProps = ConsumerController.Create<IMessageProtocol>(Context, Option<IActorRef>.None, consumerControllerSettings);
var consumerController = Context.ActorOf(consumerControllerProps, "consumer-controller");
consumerController.Tell(new ConsumerController.Start<IMessageProtocol>(Self));
consumerController.Tell(new ConsumerController.RegisterToProducerController<IMessageProtocol>(_producerController));
return consumerController;
}
I need help ensuring that the producer controller is properly registered with the consumer controller, or vice versa. How to actually get reference to producerController which is in remote process.
You'll need to establish an Akka.Remote connection between the producer and consumer first in order to get a reference to the ProducerController
.
In Akka.Cluster you could do this by just forming a cluster together and then constructing an ActorSelection
to the ProducerController
:
var pcPath = "/user/producerController"; // replace this with wherever your ProducerController is in the hierarchy
IActorRef producerControllerReference = await myActorSystem.ActorSelection(remoteMember.Address + pcPath).ResolveOne(CancellationToken.None);
^^ I'm typing this from memory so don't expect that to compile, but that's generally right.
If you're not using Akka.Cluster, you'll need to manually provide an Address
in either Address
or string
form and run the exact same type of code.