Do not requeue messages that violate a constraint (#442)
* Do not requeue constraintviolation Signed-off-by: kaizimmerm <kai.zimmermann@bosch-si.com> * Add MessageConversionException Signed-off-by: kaizimmerm <kai.zimmermann@bosch-si.com> * Add CancelActionNotAllowedException Signed-off-by: kaizimmerm <kai.zimmermann@bosch-si.com> * Add MessageHandlingException Signed-off-by: kaizimmerm <kai.zimmermann@bosch-si.com>
This commit is contained in:
committed by
Michael Hirsch
parent
822c822948
commit
45f3ca0787
@@ -10,6 +10,9 @@ package org.eclipse.hawkbit.amqp;
|
||||
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
import javax.validation.ConstraintViolationException;
|
||||
|
||||
import org.eclipse.hawkbit.repository.exception.CancelActionNotAllowedException;
|
||||
import org.eclipse.hawkbit.repository.exception.EntityNotFoundException;
|
||||
import org.eclipse.hawkbit.repository.exception.InvalidTargetAddressException;
|
||||
import org.eclipse.hawkbit.repository.exception.TenantNotExistException;
|
||||
@@ -19,6 +22,8 @@ import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.amqp.rabbit.listener.ConditionalRejectingErrorHandler;
|
||||
import org.springframework.amqp.rabbit.listener.FatalExceptionStrategy;
|
||||
import org.springframework.amqp.support.converter.MessageConversionException;
|
||||
import org.springframework.messaging.MessageHandlingException;
|
||||
|
||||
/**
|
||||
* Custom {@link FatalExceptionStrategy} that markes defined hawkBit internal
|
||||
@@ -59,11 +64,23 @@ public class DelayedRequeueExceptionStrategy extends ConditionalRejectingErrorHa
|
||||
}
|
||||
|
||||
private boolean invalidMessage(final Throwable cause) {
|
||||
return doesNotExist(cause) || cause instanceof TooManyStatusEntriesException
|
||||
|| cause instanceof InvalidTargetAddressException || cause instanceof ToManyAttributeEntriesException;
|
||||
return doesNotExist(cause) || quotaHit(cause) || invalidContent(cause) || invalidState(cause);
|
||||
}
|
||||
|
||||
private boolean invalidState(final Throwable cause) {
|
||||
return cause instanceof CancelActionNotAllowedException;
|
||||
}
|
||||
|
||||
private boolean quotaHit(final Throwable cause) {
|
||||
return cause instanceof TooManyStatusEntriesException || cause instanceof ToManyAttributeEntriesException;
|
||||
}
|
||||
|
||||
private boolean doesNotExist(final Throwable cause) {
|
||||
return cause instanceof TenantNotExistException || cause instanceof EntityNotFoundException;
|
||||
}
|
||||
|
||||
private boolean invalidContent(final Throwable cause) {
|
||||
return cause instanceof ConstraintViolationException || cause instanceof InvalidTargetAddressException
|
||||
|| cause instanceof MessageConversionException || cause instanceof MessageHandlingException;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -15,13 +15,10 @@ import org.eclipse.hawkbit.exception.SpServerError;
|
||||
* Thrown if cancellation of action is requested where the action cannot be
|
||||
* cancelled (e.g. the action is not active or is already a canceled action) or
|
||||
* controller provides cancellation feedback on an action that is actually not
|
||||
* in caneling state.
|
||||
* in canceling state.
|
||||
*
|
||||
*/
|
||||
public final class CancelActionNotAllowedException extends AbstractServerRtException {
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user