Code, JavaEE

CQRS – Create Task Story

[As a User I Want to Create a Task]

Artifacts:

  • 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


@Controller

public class TaskController {

private TaskService taskService;

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

    taskService.createTask(desc);
}

}

Package Structure

com.davidkingenterprise.appname

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.

Advertisements

Leave a Reply

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

WordPress.com Logo

You are commenting using your WordPress.com 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 )

Google+ photo

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

Connecting to %s