mirror of https://github.com/dapr/java-sdk.git
Add support for @PostMapping("/path") to pub/sub topic subscriptions (#583)
* Remove duplicate dependency * Transform into managed dependencies * Remove old JUnit version from dependencies * Add tests for DaprBeanPostProcessor * Also register PostMappings that use value * Modify existing pub/sub test to no use @PostMapping(path="...") * Remove added dependencies on AssertJ, Spring Test and Servlet API * Remove test in favour of the sdk-tests one Co-authored-by: Artur Souza <artursouza.ms@outlook.com>
This commit is contained in:
parent
ac93218c5a
commit
3c3a5277d6
|
@ -55,11 +55,6 @@
|
||||||
<artifactId>dapr-sdk-actors</artifactId>
|
<artifactId>dapr-sdk-actors</artifactId>
|
||||||
<version>${project.version}</version>
|
<version>${project.version}</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
|
||||||
<groupId>junit</groupId>
|
|
||||||
<artifactId>junit</artifactId>
|
|
||||||
<scope>test</scope>
|
|
||||||
</dependency>
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.mockito</groupId>
|
<groupId>org.mockito</groupId>
|
||||||
<artifactId>mockito-core</artifactId>
|
<artifactId>mockito-core</artifactId>
|
||||||
|
@ -74,13 +69,11 @@
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.junit.jupiter</groupId>
|
<groupId>org.junit.jupiter</groupId>
|
||||||
<artifactId>junit-jupiter-api</artifactId>
|
<artifactId>junit-jupiter-api</artifactId>
|
||||||
<version>5.5.2</version>
|
|
||||||
<scope>test</scope>
|
<scope>test</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.springframework</groupId>
|
<groupId>org.springframework</groupId>
|
||||||
<artifactId>spring-beans</artifactId>
|
<artifactId>spring-beans</artifactId>
|
||||||
<version>5.2.10.RELEASE</version>
|
|
||||||
<scope>compile</scope>
|
<scope>compile</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
|
|
|
@ -21,7 +21,7 @@ import java.util.HashMap;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Handles Dapr annotations in Springboot Controllers.
|
* Handles Dapr annotations in Spring Controllers.
|
||||||
*/
|
*/
|
||||||
@Component
|
@Component
|
||||||
public class DaprBeanPostProcessor implements BeanPostProcessor {
|
public class DaprBeanPostProcessor implements BeanPostProcessor {
|
||||||
|
@ -77,6 +77,8 @@ public class DaprBeanPostProcessor implements BeanPostProcessor {
|
||||||
|
|
||||||
if (mapping != null && mapping.path() != null && mapping.path().length >= 1) {
|
if (mapping != null && mapping.path() != null && mapping.path().length >= 1) {
|
||||||
route = mapping.path()[0];
|
route = mapping.path()[0];
|
||||||
|
} else if (mapping != null && mapping.value() != null && mapping.value().length >= 1) {
|
||||||
|
route = mapping.value()[0];
|
||||||
}
|
}
|
||||||
|
|
||||||
String topicName = embeddedValueResolver.resolveStringValue(topic.name());
|
String topicName = embeddedValueResolver.resolveStringValue(topic.name());
|
||||||
|
|
|
@ -35,7 +35,7 @@ public class SubscriberController {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Topic(name = "testingtopic", pubsubName = "messagebus")
|
@Topic(name = "testingtopic", pubsubName = "messagebus")
|
||||||
@PostMapping(path = "/route1")
|
@PostMapping("/route1")
|
||||||
public Mono<Void> handleMessage(@RequestBody(required = false) CloudEvent envelope) {
|
public Mono<Void> handleMessage(@RequestBody(required = false) CloudEvent envelope) {
|
||||||
return Mono.fromRunnable(() -> {
|
return Mono.fromRunnable(() -> {
|
||||||
try {
|
try {
|
||||||
|
|
Loading…
Reference in New Issue