Skip to content

Instantly share code, notes, and snippets.

View Romeh's full-sized avatar

MRomeh Romeh

View GitHub Profile
/**
* Tha main Event sourcing DDD aggregate class for order domain which handle the order commands within it is boundary context
*
* @author romeh
*/
@PersistentActor
public class OrderManager extends PersistentEntity<OrderCmd, OrderEvent, OrderState> {
/**
* how to handle supervisor strategy definition for the parent actor of the entity
/**
* the main order entity required configuration for event souring toolkit
*/
@Component
public class OrderEntityProperties implements PersistentEntityProperties<OrderManager, OrderCmd, OrderEvent> {
private Map<Class<? extends OrderEvent>, String> tags;
/**
* init the event tags map
*/
@PostConstruct
spring:
jackson:
default-property-inclusion: non_null
akka:
config: eventSourcing.conf
system-name: orderManagerSystem
/**
* get order state service API
*
* @param getOrderStatusCmd get Order state command
* @return order state
*/
public CompletableFuture<OrderState> getOrderStatus(OrderCmd.GetOrderStatusCmd getOrderStatusCmd) {
return PatternsCS.ask(getOrderEntity(), getOrderStatusCmd, timeout).toCompletableFuture()
.thenApply(handleGetState);
}
/**
* The main order domain REST API
*
* @author romeh
*/
@RestController
@RequestMapping("/orders")
@Api(value = "Order Manager REST API demo")
public class OrderRestController {
<plugin>
<groupId>org.xolstice.maven.plugins</groupId>
<artifactId>protobuf-maven-plugin</artifactId>
<version>0.5.1</version>
<configuration>
<protocExecutable>/usr/local/opt/protobuf/bin/protoc</protocExecutable>
</configuration>
<executions>
<execution>
<goals>
<dependency>
<groupId>ru.yandex.qatools.embed</groupId>
<artifactId>postgresql-embedded</artifactId>
<version>2.9</version>
</dependency>
<dependency>
<groupId>org.postgresql</groupId>
<artifactId>postgresql</artifactId>
<scope>runtime</scope>
</dependency>
/**
* the db spring configuration to use in production , to be replaced with actual production configuration , that is for local run only
*/
@Configuration
@EnableTransactionManagement
public class DbConfig {
private static final List<String> DEFAULT_ADDITIONAL_INIT_DB_PARAMS = Arrays
.asList("--nosync", "--locale=en_US.UTF-8");
/**
@Entity(name = "customer")
@Data
@AllArgsConstructor
@NoArgsConstructor
@Builder
public class Customer {
@Id
private long id;
private String name;
private String address;
/**
* main customer repository
*/
@Repository
@Transactional
public interface CustomerRepository extends CrudRepository<Customer, Long> {
Optional<Customer> findCustomerByName(String name);
}