All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.dell.cpsd.common.rabbitmq.retrypolicy.ResponseMessageRetryPolicy Maven / Gradle / Ivy

There is a newer version: 2.2.0
Show newest version
/**
 * Copyright © 2017 Dell Inc. or its subsidiaries.  All Rights Reserved.
 * Dell EMC Confidential/Proprietary Information
 */

package com.dell.cpsd.common.rabbitmq.retrypolicy;

import com.dell.cpsd.common.rabbitmq.retrypolicy.exception.ResponseMessageException;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.retry.RetryContext;
import org.springframework.retry.policy.SimpleRetryPolicy;

/**
 * Policy designed to be used with ResponseMessageException. Takes retry attempt count from exception itself.
 * 

*

* Copyright © 2017 Dell Inc. or its subsidiaries. All Rights Reserved. * Dell EMC Confidential/Proprietary Information *

*/ public class ResponseMessageRetryPolicy extends SimpleRetryPolicy { private static final Logger log = LoggerFactory.getLogger(ResponseMessageRetryPolicy.class); @Override public boolean canRetry(RetryContext context) { Throwable t = context.getLastThrowable(); if (t instanceof ResponseMessageException) { int maxRetryCount = ((ResponseMessageException) t).getMaxRetryCount(); return context.getRetryCount() < maxRetryCount; } log.warn("Policy is used for a wrong exception: {}. Falling back to SimpleRetryPolicy.", (t == null ? null : t.getClass().getSimpleName())); return super.canRetry(context); } }




© 2015 - 2024 Weber Informatics LLC | Privacy Policy