Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make EnableRabbitRetryAndDlq applicable to ElementType.ANNOTATION_TYPE #30

Merged
merged 1 commit into from
Dec 17, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
*
* The <code>discardWhen</code> attribute has higher precedence over <code>exceptions</code> attribute.
*/
@Target(ElementType.METHOD)
@Target({ ElementType.METHOD, ElementType.ANNOTATION_TYPE })
@Retention(RetentionPolicy.RUNTIME)
public @interface EnableRabbitRetryAndDlq {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,10 @@
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;

import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
import java.lang.reflect.Method;
import java.util.Collections;
import java.util.HashMap;
Expand Down Expand Up @@ -214,6 +218,18 @@ public void should_send_dlq_when_only_directToDlqWhen_exceptions_contains_and_no
verifySentToRetryNeverCalled();
verifyIfDlqWasCalled(1);
}

@Test
@DirectToDqlWhenNumberFormatExceptionListener
public void should_send_dlq_when_only_directToDlqWhen_exceptions_contains_and_no_other_defined_when_it_is_using_a_custom_annotation() throws Throwable {
ProceedingJoinPoint joinPoint = mockJointPointWithDeathAndThrowing(
"should_send_dlq_when_only_directToDlqWhen_exceptions_contains_and_no_other_defined", 1, NumberFormatException.class);

aspect.validateMessage(joinPoint);

verifySentToRetryNeverCalled();
verifyIfDlqWasCalled(1);
}

private void verifySentToRetryNeverCalled() {
verify(queueComponent, never()).sendToRetryOrDlq(any(Message.class), any());
Expand Down Expand Up @@ -283,4 +299,15 @@ private static TunedRabbitProperties createQueueProperties() {
queueProperties.setMaxRetriesAttempts(3);
return queueProperties;
}
}



@Retention(RetentionPolicy.RUNTIME)
@Target(ElementType.METHOD)
@EnableRabbitRetryAndDlq(event = "some-event",
directToDlqWhen = NumberFormatException.class
)
public @interface DirectToDqlWhenNumberFormatExceptionListener {

}
}