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

Commit

Permalink
Do not shutter the JmsEnvelopeSender when called from the Command-Con…
Browse files Browse the repository at this point in the history
…troller component
  • Loading branch information
mapingo committed Oct 4, 2019
1 parent d3b64d9 commit 2c6a9c4
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 1 deletion.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ on [Keep a CHANGELOG](http://keepachangelog.com/). This project adheres to
## [6.0.17] - 2019-10-04
### Changed
- Storing of Commands whilst shuttered is now idempotent
- Do not shutter the JmsEnvelopeSender when called from the Command-Controller component

## [6.0.16] - 2018-09-23
### Changed
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package uk.gov.justice.services.messaging.jms;

import static uk.gov.justice.services.core.annotation.Component.COMMAND_CONTROLLER;

import uk.gov.justice.services.common.annotation.ComponentNameExtractor;

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

if (componentNameExtractor.hasComponentAnnotation(injectionPoint)) {
if (componentNameExtractor.hasComponentAnnotation(injectionPoint) && !isCommandController(injectionPoint)) {
return new ShutteringJmsEnvelopeSender(envelopeSenderSelector);
}

return new DefaultJmsEnvelopeSender(jmsSender);
}

private boolean isCommandController(final InjectionPoint injectionPoint) {
return COMMAND_CONTROLLER.equals(componentNameExtractor.componentFrom(injectionPoint));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import static org.hamcrest.core.IsNot.not;
import static org.junit.Assert.assertThat;
import static uk.gov.justice.services.core.annotation.Component.COMMAND_API;
import static uk.gov.justice.services.core.annotation.Component.COMMAND_CONTROLLER;
import static uk.gov.justice.services.core.annotation.Component.EVENT_PROCESSOR;
import static uk.gov.justice.services.core.annotation.Component.QUERY_API;
import static uk.gov.justice.services.test.utils.common.MemberInjectionPoint.injectionPointWithMemberAsFirstMethodOf;
Expand All @@ -32,6 +33,7 @@ public class JmsEnvelopeSenderProducerTest {
private InjectionPoint adaptorEventProcessorInjectionPoint = injectionPointWithMemberAsFirstMethodOf(TestEventProcessorAdaptor.class);
private InjectionPoint adaptorQueryApiInjectionPoint = injectionPointWithMemberAsFirstMethodOf(TestQueryApiAdaptor.class);
private InjectionPoint noAnnotationInjectionPoint = injectionPointWithMemberAsFirstMethodOf(TestNoAnnotation.class);
private InjectionPoint adaptorCommandControllerInjectionPoint = injectionPointWithMemberAsFirstMethodOf(TestCommandControllerAdaptor.class);

@Mock
private JmsSender jmsSender;
Expand Down Expand Up @@ -68,6 +70,14 @@ public void shouldProduceShutteringJmsEnvelopeSenderForEventProcessorComponent()
assertThat(jmsEnvelopeSender, is(instanceOf(ShutteringJmsEnvelopeSender.class)));
}

@Test
public void shouldProduceDefaultJmsEnvelopeSenderWhenCommandControllerAnnotation() {

final JmsEnvelopeSender jmsEnvelopeSender = jmsEnvelopeSenderProducer.createJmsEnvelopeSender(adaptorCommandControllerInjectionPoint);

assertThat(jmsEnvelopeSender, is(instanceOf(DefaultJmsEnvelopeSender.class)));
}

@Test
public void shouldProduceDefaultJmsEnvelopeSenderWhenNoComponentAnnotation() {

Expand Down Expand Up @@ -142,4 +152,14 @@ public static class TestNoAnnotation {
public void dummyMethod() {
}
}

@FrameworkComponent(COMMAND_CONTROLLER)
public static class TestCommandControllerAdaptor {

@Inject
InterceptorChainProcessor interceptorChainProcessor;

public void dummyMethod() {
}
}
}

0 comments on commit 2c6a9c4

Please sign in to comment.