Created
August 23, 2018 04:16
-
-
Save jaocamp/61dd504c1ca2963f83f3cc00f1f8ff31 to your computer and use it in GitHub Desktop.
CQRS e Event Sourcing com Axon Framework e Spring Boot - EventController.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package br.com.coderef.controller; | |
import lombok.AllArgsConstructor; | |
import org.axonframework.eventhandling.EventMessage; | |
import org.axonframework.eventsourcing.eventstore.EventStore; | |
import org.springframework.transaction.annotation.Transactional; | |
import org.springframework.web.bind.annotation.GetMapping; | |
import org.springframework.web.bind.annotation.PathVariable; | |
import org.springframework.web.bind.annotation.RequestMapping; | |
import org.springframework.web.bind.annotation.RestController; | |
import java.util.List; | |
import java.util.stream.Collectors; | |
@RestController | |
@AllArgsConstructor | |
@RequestMapping("/events") | |
public class EventController { | |
private EventStore eventStore; | |
@GetMapping | |
@RequestMapping("/{aggregateId}") | |
@Transactional(readOnly = true) | |
public List<EventMessage> listEvents(@PathVariable String aggregateId) { | |
return eventStore.readEvents(aggregateId) | |
.asStream() | |
.collect(Collectors.toList()); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment