Code, JavaEE

CQRS – Create Task Story

[As a User I Want to Create a Task]


  • Command
  • CommandHandler <Command>
  • Event
  • EventHandler <Event>
  • Aggregate Root
  • Repository
  • Service
  • Controller

Expressed in concrete terms:

  • CreateTaskCommand(id, description)
  • CreateTaskCommandHandler <CreateTaskCommand>
  • TaskCreatedEvent(id, description)
  • TaskCreatedEventHandler <TaskCreatedEvent>
  • Task(id, description)
  • TaskRepository
  • TaskService(createTask(id, description))
  • TaskController(handleCreateTask(…))

Implementation Details Example


public class TaskController {

private TaskService taskService;

@RequestMapping(value="/tasks", method=RequestMethod.POST)
public void handleCreateTask(@RequestParam("description") String desc) {



Package Structure


com.davidkingenterprise.appname.createtask (all artifacts for use case named create task)

What’s Missing

Details about how the domain synchronizes with the query side via denormalizers.

Additional complexity via busses for commands and events.


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s