Code, JavaEE

CQRS – Making Sense of the Workflow

1. User Interface – user clicks create button to create a new Task.

2. Controller -> Validator -> JMSMessageSender (send to Queue.Request and JMSType=’CreateTaskRequest’)

3. JSON created and send over queue

{ "command":"pkg.CreateTask", "task": { "description":"Learn CQRS end to end with an example", "complete":"false", "timestamp":"1234567890" } }

4. JMS Listener (onMessage(Message message))


CreateTaskCommand command = convertMessageToCommand (message);

 CreateTaskHandler handler = new CreateTaskHandler(command);

 handler.handle();

 :handle

 Task task = new Task(Uuid(), command.description, command.complete);

 repository.store(task);    // store to in memory store and database

 TaskCreatedEvent taskCreatedEvent = new TaskCreatedEvent(task);

 taskCreateEvent.apply();

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