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
/** | |
* 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); | |
} |
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
spring: | |
jackson: | |
default-property-inclusion: non_null | |
akka: | |
config: eventSourcing.conf | |
system-name: orderManagerSystem |
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
/** | |
* 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 |
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
/** | |
* 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 |
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
<dependency> | |
<groupId>spring-akka-event-sourcing</groupId> | |
<artifactId>springboot-akka-event-sourcing-starter</artifactId> | |
<version>1.0</version> | |
</dependency> |
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
@Override | |
// if you want to do atomic update over cache entry | |
public void updateAlertEntry(String serviceId, String serviceCode, AlertEntry alertEntry) { | |
//get the JSR cache reference | |
final Cache<String, List<AlertEntry>> alertsCache = getAlertsCache(); | |
// then invoke atomic update on the cache entry | |
alertsCache.invoke(serviceId, (mutableEntry, objects) -> { | |
if (mutableEntry.exists() && mutableEntry.getValue() != null) { | |
logger.debug("updating alert entry into the cache store invoke: {},{}",serviceId,serviceCode); | |
final List<AlertEntry> alertEntries = mutableEntry.getValue(); |
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
@Autowired | |
private javax.cache.CacheManager cacheManager; | |
// get access to your cache for further operation | |
private Cache<String, List<AlertEntry>> getAlertsCache() { | |
return cacheManager.getCache(CacheNames.Alerts.name()); | |
} | |
// close the cache manager upon shutting down | |
@PreDestroy |
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
<config | |
xmlns:jsr107='http://www.ehcache.org/v3/jsr107' | |
xmlns='http://www.ehcache.org/v3'> | |
<service> | |
<jsr107:defaults enable-management="true" enable-statistics="true"/> | |
</service> | |
<!-- file persistance enabling--> | |
<persistence directory="./cache"></persistence> | |
<!-- the 2 caches we will create--> | |
<cache alias="AlertsConfig" uses-template="config-cache"/> |
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
@SpringBootApplication | |
// enable spring boot caching | |
@EnableCaching | |
public class AlertManagerApplication { | |
public static void main(String[] args) { | |
SpringApplication.run(AlertManagerApplication.class, args); | |
} |
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
<!-- ehcache and JSR dependencies--> | |
<dependency> | |
<groupId>org.ehcache</groupId> | |
<artifactId>ehcache</artifactId> | |
<version>${ehcache}</version> | |
</dependency> | |
<dependency> | |
<groupId>javax.cache</groupId> | |
<artifactId>cache-api</artifactId> | |
</dependency> |