Skip to content
This repository was archived by the owner on Aug 13, 2020. It is now read-only.

Commit 2c6a9c4

Browse files
committed
Do not shutter the JmsEnvelopeSender when called from the Command-Controller component
1 parent d3b64d9 commit 2c6a9c4

File tree

3 files changed

+28
-1
lines changed

3 files changed

+28
-1
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ on [Keep a CHANGELOG](http://keepachangelog.com/). This project adheres to
88
## [6.0.17] - 2019-10-04
99
### Changed
1010
- Storing of Commands whilst shuttered is now idempotent
11+
- Do not shutter the JmsEnvelopeSender when called from the Command-Controller component
1112

1213
## [6.0.16] - 2018-09-23
1314
### Changed

messaging/messaging-jms/src/main/java/uk/gov/justice/services/messaging/jms/JmsEnvelopeSenderProducer.java

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
package uk.gov.justice.services.messaging.jms;
22

3+
import static uk.gov.justice.services.core.annotation.Component.COMMAND_CONTROLLER;
4+
35
import uk.gov.justice.services.common.annotation.ComponentNameExtractor;
46

57
import javax.enterprise.inject.Produces;
@@ -20,10 +22,14 @@ public class JmsEnvelopeSenderProducer {
2022
@Produces
2123
public JmsEnvelopeSender createJmsEnvelopeSender(final InjectionPoint injectionPoint) {
2224

23-
if (componentNameExtractor.hasComponentAnnotation(injectionPoint)) {
25+
if (componentNameExtractor.hasComponentAnnotation(injectionPoint) && !isCommandController(injectionPoint)) {
2426
return new ShutteringJmsEnvelopeSender(envelopeSenderSelector);
2527
}
2628

2729
return new DefaultJmsEnvelopeSender(jmsSender);
2830
}
31+
32+
private boolean isCommandController(final InjectionPoint injectionPoint) {
33+
return COMMAND_CONTROLLER.equals(componentNameExtractor.componentFrom(injectionPoint));
34+
}
2935
}

messaging/messaging-jms/src/test/java/uk/gov/justice/services/messaging/jms/JmsEnvelopeSenderProducerTest.java

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
import static org.hamcrest.core.IsNot.not;
77
import static org.junit.Assert.assertThat;
88
import static uk.gov.justice.services.core.annotation.Component.COMMAND_API;
9+
import static uk.gov.justice.services.core.annotation.Component.COMMAND_CONTROLLER;
910
import static uk.gov.justice.services.core.annotation.Component.EVENT_PROCESSOR;
1011
import static uk.gov.justice.services.core.annotation.Component.QUERY_API;
1112
import static uk.gov.justice.services.test.utils.common.MemberInjectionPoint.injectionPointWithMemberAsFirstMethodOf;
@@ -32,6 +33,7 @@ public class JmsEnvelopeSenderProducerTest {
3233
private InjectionPoint adaptorEventProcessorInjectionPoint = injectionPointWithMemberAsFirstMethodOf(TestEventProcessorAdaptor.class);
3334
private InjectionPoint adaptorQueryApiInjectionPoint = injectionPointWithMemberAsFirstMethodOf(TestQueryApiAdaptor.class);
3435
private InjectionPoint noAnnotationInjectionPoint = injectionPointWithMemberAsFirstMethodOf(TestNoAnnotation.class);
36+
private InjectionPoint adaptorCommandControllerInjectionPoint = injectionPointWithMemberAsFirstMethodOf(TestCommandControllerAdaptor.class);
3537

3638
@Mock
3739
private JmsSender jmsSender;
@@ -68,6 +70,14 @@ public void shouldProduceShutteringJmsEnvelopeSenderForEventProcessorComponent()
6870
assertThat(jmsEnvelopeSender, is(instanceOf(ShutteringJmsEnvelopeSender.class)));
6971
}
7072

73+
@Test
74+
public void shouldProduceDefaultJmsEnvelopeSenderWhenCommandControllerAnnotation() {
75+
76+
final JmsEnvelopeSender jmsEnvelopeSender = jmsEnvelopeSenderProducer.createJmsEnvelopeSender(adaptorCommandControllerInjectionPoint);
77+
78+
assertThat(jmsEnvelopeSender, is(instanceOf(DefaultJmsEnvelopeSender.class)));
79+
}
80+
7181
@Test
7282
public void shouldProduceDefaultJmsEnvelopeSenderWhenNoComponentAnnotation() {
7383

@@ -142,4 +152,14 @@ public static class TestNoAnnotation {
142152
public void dummyMethod() {
143153
}
144154
}
155+
156+
@FrameworkComponent(COMMAND_CONTROLLER)
157+
public static class TestCommandControllerAdaptor {
158+
159+
@Inject
160+
InterceptorChainProcessor interceptorChainProcessor;
161+
162+
public void dummyMethod() {
163+
}
164+
}
145165
}

0 commit comments

Comments
 (0)