Skip to content

Commit 79014c3

Browse files
authored
Merge pull request #101 from reactive-commons/feature/disable-event-listener
Add option to disable event listener
2 parents 1016ffe + 1cb1998 commit 79014c3

File tree

5 files changed

+25
-18
lines changed

5 files changed

+25
-18
lines changed

async/async-rabbit-starter-eda/async-commons-rabbit-starter-eda.gradle

+1
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ dependencies {
77
api project(':async-rabbit')
88
compileOnly 'org.springframework.boot:spring-boot-starter'
99
compileOnly 'org.springframework.boot:spring-boot-starter-actuator'
10+
implementation 'com.fasterxml.jackson.datatype:jackson-datatype-jsr310'
1011

1112
annotationProcessor 'org.springframework.boot:spring-boot-configuration-processor'
1213

async/async-rabbit-starter-eda/src/main/java/org/reactivecommons/async/rabbit/config/EventListenersConfig.java

+17-15
Original file line numberDiff line numberDiff line change
@@ -28,22 +28,24 @@ public ApplicationEventListener eventListener(MessageConverter messageConverter,
2828
AtomicReference<ApplicationEventListener> external = new AtomicReference<>();
2929
manager.forListener((domain, receiver) -> {
3030
AsyncProps asyncProps = asyncPropsDomain.getProps(domain);
31-
final ApplicationEventListener listener = new ApplicationEventListener(receiver,
32-
asyncProps.getBrokerConfigProps().getEventsQueue(),
33-
asyncProps.getBrokerConfigProps().getDomainEventsExchangeName(),
34-
handlers.get(domain),
35-
messageConverter, asyncProps.getWithDLQRetry(),
36-
asyncProps.getCreateTopology(),
37-
asyncProps.getMaxRetries(),
38-
asyncProps.getRetryDelay(),
39-
asyncProps.getDomain().getEvents().getMaxLengthBytes(),
40-
manager.getDiscardNotifier(domain),
41-
errorReporter,
42-
asyncProps.getAppName());
43-
if (DEFAULT_DOMAIN.equals(domain)) {
44-
external.set(listener);
31+
if (!asyncProps.getDomain().isIgnoreThisListener()) {
32+
final ApplicationEventListener listener = new ApplicationEventListener(receiver,
33+
asyncProps.getBrokerConfigProps().getEventsQueue(),
34+
asyncProps.getBrokerConfigProps().getDomainEventsExchangeName(),
35+
handlers.get(domain),
36+
messageConverter, asyncProps.getWithDLQRetry(),
37+
asyncProps.getCreateTopology(),
38+
asyncProps.getMaxRetries(),
39+
asyncProps.getRetryDelay(),
40+
asyncProps.getDomain().getEvents().getMaxLengthBytes(),
41+
manager.getDiscardNotifier(domain),
42+
errorReporter,
43+
asyncProps.getAppName());
44+
if (DEFAULT_DOMAIN.equals(domain)) {
45+
external.set(listener);
46+
}
47+
listener.startListener();
4548
}
46-
listener.startListener();
4749
});
4850

4951
return external.get();

async/async-rabbit-starter-eda/src/main/java/org/reactivecommons/async/rabbit/config/props/AsyncPropsDomain.java

+5-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
package org.reactivecommons.async.rabbit.config.props;
22

3+
import com.fasterxml.jackson.databind.ObjectMapper;
4+
import com.fasterxml.jackson.datatype.jsr310.JavaTimeModule;
35
import lombok.Getter;
46
import lombok.Setter;
57
import org.reactivecommons.async.rabbit.config.RabbitProperties;
@@ -20,6 +22,8 @@ public AsyncPropsDomain(@Value("${spring.application.name}") String defaultAppNa
2022
SecretFiller secretFiller) {
2123
super(configured);
2224
this.computeIfAbsent(DEFAULT_DOMAIN, k -> new AsyncProps());
25+
ObjectMapper mapper = new ObjectMapper();
26+
mapper.registerModule(new JavaTimeModule());
2327
super.forEach((key, value) -> { // To ensure that each domain has an appName
2428
if (value.getAppName() == null) {
2529
if (defaultAppName == null || defaultAppName.isEmpty()) {
@@ -35,7 +39,7 @@ public AsyncPropsDomain(@Value("${spring.application.name}") String defaultAppNa
3539
" RabbitProperties properties found, please use withDefaultRabbitProperties or define the" +
3640
"default " + key + " domain with properties explicitly");
3741
}
38-
value.setConnectionProperties(defaultRabbitProperties);
42+
value.setConnectionProperties(mapper.convertValue(defaultRabbitProperties, RabbitProperties.class));
3943
}
4044
if (value.getBrokerConfigProps() == null) {
4145
value.setBrokerConfigProps(new BrokerConfigProps(value));

async/async-rabbit-starter-eda/src/main/java/org/reactivecommons/async/rabbit/config/props/DomainProps.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -17,5 +17,5 @@ public class DomainProps {
1717
@NestedConfigurationProperty
1818
@Builder.Default
1919
private EventsProps events = new EventsProps();
20-
20+
private boolean ignoreThisListener = false;
2121
}

gradle.properties

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
version=2.2.2
1+
version=2.2.3
22
springBootVersion=3.2.5
33
reactorRabbitVersion=1.5.5
44
cloudEventsVersion=3.0.0

0 commit comments

Comments
 (0)