Skip to content

Update Spring Boot DaprBeanPostProcessor to evaluate expressions Topic attribute values #554

@rovangju

Description

@rovangju

Assuming a spring app with an application.properties file containing

pubsubProp=banana

Current behavior (kotlin for example)

@Topic(name = "/api/banana", pubsubName = "\${pubsubProp}") //  pubsubName treated as literal string: \${pubsubProp}
@PostMapping("/api/banana")
suspend fun doItAgain(ce: CloudEvent) {
    // stuff
}

Proposed behavior (kotlin for example)

@Topic(name = "/api/banana", pubsubName = "\${pubsubProp}") // resolves to "banana" 
@PostMapping("/api/banana")
suspend fun doItAgain(ce: CloudEvent) {
    // stuff
}

Proposed method

This could be achieved by modifying the DaprBeanPostProcessor class to evaluate the attribute value with an EmbeddedValueResolver with the spring context.

This would also support other SPEL, e.g.: ${pubsubProp:defaultValue}, etc.

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions