use of org.springframework.dao.TransientDataAccessException in project cloudbreak by hortonworks.
the class ResourcePersistenceHandler method accept.
@Override
public void accept(Event<ResourceNotification> event) {
LOGGER.info("Resource notification event received: {}", event);
ResourceNotification notification = event.getData();
RetryUtil.withDefaultRetries().retry(() -> {
ResourceNotification notificationPersisted;
switch(notification.getType()) {
case CREATE:
notificationPersisted = cloudResourcePersisterService.persist(notification);
break;
case UPDATE:
notificationPersisted = cloudResourcePersisterService.update(notification);
break;
case DELETE:
notificationPersisted = cloudResourcePersisterService.delete(notification);
break;
default:
throw new IllegalArgumentException("Unsupported notification type: " + notification.getType());
}
notificationPersisted.getPromise().onNext(new ResourcePersisted());
}).checkIfRecoverable(e -> e instanceof TransientDataAccessException).ifNotRecoverable(e -> notification.getPromise().onError(e)).run();
}
Aggregations