Skip to content

Commit 23a8a67

Browse files
authored
Merge branch 'master' into bugfix/issue-13-messages-sending-problem
2 parents 3ccac1c + 34bde00 commit 23a8a67

File tree

4 files changed

+18
-4
lines changed

4 files changed

+18
-4
lines changed

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,7 @@ pulsar.connectionTimeoutSec=10
9191
pulsar.operationTimeoutSec=15
9292
pulsar.startingBackoffIntervalMs=100
9393
pulsar.maxBackoffIntervalSec=10
94+
pulsar.consumerNameDelimiter=
9495
```
9596

9697
Properties explained:
@@ -104,6 +105,7 @@ Properties explained:
104105
- `pulsar.operationTimeoutSec` - Operation timeout.
105106
- `pulsar.startingBackoffIntervalMs` - Duration of time for a backoff interval (Retry algorithm).
106107
- `pulsar.maxBackoffIntervalSec` - The maximum duration of time for a backoff interval (Retry algorithm).
108+
- `pulsar.consumerNameDelimiter` - Consumer names are connection of bean name and method with a delimiter. By default there is no delimiter and words are connected together.
107109

108110
## Contributing
109111

src/main/java/io/github/majusko/pulsar/PulsarProperties.java

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ public class PulsarProperties {
1313
private Integer operationTimeoutSec = 15;
1414
private Integer startingBackoffIntervalMs = 100;
1515
private Integer maxBackoffIntervalSec = 10;
16+
private String consumerNameDelimiter = "";
1617

1718
public String getServiceUrl() {
1819
return serviceUrl;
@@ -85,4 +86,12 @@ public Integer getMaxBackoffIntervalSec() {
8586
public void setMaxBackoffIntervalSec(Integer maxBackoffIntervalSec) {
8687
this.maxBackoffIntervalSec = maxBackoffIntervalSec;
8788
}
89+
90+
public String getConsumerNameDelimiter() {
91+
return consumerNameDelimiter;
92+
}
93+
94+
public void setConsumerNameDelimiter(String consumerNameDelimiter) {
95+
this.consumerNameDelimiter = consumerNameDelimiter;
96+
}
8897
}

src/main/java/io/github/majusko/pulsar/collector/ConsumerCollector.java

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
package io.github.majusko.pulsar.collector;
22

33
import io.github.majusko.pulsar.annotation.PulsarConsumer;
4+
import org.springframework.beans.factory.annotation.Value;
45
import org.springframework.beans.factory.config.BeanPostProcessor;
56
import org.springframework.context.annotation.Configuration;
6-
import org.springframework.stereotype.Component;
77

88
import java.util.Arrays;
99
import java.util.Map;
@@ -14,6 +14,9 @@
1414
@Configuration
1515
public class ConsumerCollector implements BeanPostProcessor {
1616

17+
@Value("${pulsar.consumerNameDelimiter:}")
18+
private String consumerNameDelimiter;
19+
1720
private Map<String, ConsumerHolder> consumers = new ConcurrentHashMap<>();
1821

1922
@Override
@@ -23,7 +26,7 @@ public Object postProcessBeforeInitialization(Object bean, String beanName) {
2326
consumers.putAll(Arrays.stream(beanClass.getDeclaredMethods())
2427
.filter($ -> $.isAnnotationPresent(PulsarConsumer.class))
2528
.collect(Collectors.toMap(
26-
method -> beanClass.getName() + "#" + method.getName(),
29+
method -> beanClass.getName() + consumerNameDelimiter + method.getName(),
2730
method -> new ConsumerHolder(method.getAnnotation(PulsarConsumer.class), method, bean))));
2831

2932
return bean;

src/test/java/io/github/majusko/pulsar/PulsarJavaSpringBootStarterApplicationTests.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -76,8 +76,8 @@ void testConsumerRegistration1() throws Exception {
7676

7777
@Test
7878
void testConsumerRegistration2() {
79-
final Class<TestConsumers> clazz = TestConsumers.class;
80-
final String descriptor = clazz.getName() + "#" + clazz.getMethods()[0].getName();
79+
final Class<TestConsumerConfiguration> clazz = TestConsumerConfiguration.class;
80+
final String descriptor = clazz.getName() + clazz.getMethods()[0].getName();
8181
final ConsumerHolder consumerHolder = consumerCollector.getConsumer(descriptor).orElse(null);
8282

8383
Assertions.assertNotNull(consumerHolder);

0 commit comments

Comments
 (0)