offline job - actor vs future onSuccess hook

I was wondering what is the best practices for invoking little offline jobs. Examples:

  • Send email, once an entity is persisted.
  • Update external service when something happens in my app.
  • Run an offline calculation and persist it (something which is not part of the critical flow of my app)
  • And more..

I am aware of the capabilities of akka actor system , and also scala future.But I am not sure what is the best tool for this kind of use case.

I will go with the onSuccess hook of a future most of the times, and only use actors if I need to hold a state that need to be updated. (onSuccess have it's disadvantages, hard to pushback, and hard to test)

So if we look on a code example:

val myCriticalFlowFuture = dao.doSomething() myCriticalFlowFuture.onSuccess(_ => sendEmail()) myCriticalFlowFuture 


dao.doSomething().map(_ => eventBus.publish(SendMailMessage(Payload(email)))) 

What do you think?


Category: scala Time: 2016-07-31 Views: 9
Tags: scala akka actor

Related post

iOS development

Android development

Python development

JAVA development

Development language

PHP development

Ruby development


Front-end development


development tools

Open Platform

Javascript development

.NET development

cloud computing


Copyright (C), All Rights Reserved.

processed in 0.165 (s). 12 q(s)