org.springframework.dao.TransientDataAccessException Java Examples

The following examples show how to use org.springframework.dao.TransientDataAccessException. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: ResourcePersistenceHandler.java    From cloudbreak with Apache License 2.0 6 votes vote down vote up
@Override
public void accept(Event<ResourceNotification> event) {
    LOGGER.debug("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();
}
 
Example #2
Source File: ConsensusController.java    From hedera-mirror-node with Apache License 2.0 5 votes vote down vote up
@Override
public Flux<ConsensusTopicResponse> subscribeTopic(Mono<ConsensusTopicQuery> request) {
    return request.map(this::toFilter)
            .flatMapMany(topicMessageService::subscribeTopic)
            .map(TopicMessage::toResponse)
            .onErrorMap(ConstraintViolationException.class, e -> error(e, Status.INVALID_ARGUMENT))
            .onErrorMap(IllegalArgumentException.class, e -> error(e, Status.INVALID_ARGUMENT))
            .onErrorMap(NonTransientDataAccessResourceException.class, e -> error(e, Status.UNAVAILABLE, DB_ERROR))
            .onErrorMap(TimeoutException.class, e -> error(e, Status.RESOURCE_EXHAUSTED))
            .onErrorMap(TopicNotFoundException.class, e -> error(e, Status.NOT_FOUND))
            .onErrorMap(TransientDataAccessException.class, e -> error(e, Status.RESOURCE_EXHAUSTED))
            .onErrorMap(t -> unknownError(t));
}
 
Example #3
Source File: SqlRetryPolicy.java    From spring-cloud-aws with Apache License 2.0 5 votes vote down vote up
/**
 * Returns all the exceptions for which a retry is useful.
 * @return - Map containing all retryable exceptions for the
 * {@link BinaryExceptionClassifier}
 */
private static Map<Class<? extends Throwable>, Boolean> getSqlRetryAbleExceptions() {
	Map<Class<? extends Throwable>, Boolean> retryableExceptions = new HashMap<>();
	retryableExceptions.put(SQLTransientException.class, true);
	retryableExceptions.put(SQLRecoverableException.class, true);
	retryableExceptions.put(TransientDataAccessException.class, true);
	retryableExceptions.put(SQLNonTransientConnectionException.class, true);
	return retryableExceptions;
}
 
Example #4
Source File: ProductEventConsumer.java    From integration-patterns with MIT License 4 votes vote down vote up
@Inject
protected ProductEventConsumer(ProductEventProcessor messageProcessor, UnprocessableEventService unprocessableEventService) {
    super(messageProcessor, unprocessableEventService,
            ImmutableSet.of(UncategorizedDataAccessException.class, TransientDataAccessException.class,
                    CannotCreateTransactionException.class));
}