Skip to content

Instantly share code, notes, and snippets.

@Danthar
Created April 24, 2015 06:42
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Danthar/594d08dc26bc36cfab34 to your computer and use it in GitHub Desktop.
Save Danthar/594d08dc26bc36cfab34 to your computer and use it in GitHub Desktop.
Consume RabbitMq messages with Akka : Part 2
//this is with the easynetq librabry but could just as easily be anything else.
rabbitBus.Subscribe<MyMessageType>(subscriptionId, message => {
Log.Debug("message from rabbitmq received");
//this works! because of how Ask works (it creates a fake actor that is passed as sender behind the scenes)
var result = workers.Ask<WorkCompleted>(new StartWorkFor() {Details = message}).Result;
});
//however this...
Receive<string>(m => m.Equals("dothething"), m => {
rabbitBus.Subscribe<mycommand>(subscriptionId, command => {
//here we do a Tell. this worker eventually communicates back with WorkComplete
worker.Tell(new StartWorkFor());
});
});
Receive<WorkComplete>(_ => {
//this never gets called, unless..
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment