Bartłomiej Paluch
Bartłomiej Paluch

Reputation: 41

Spring cloud streams kafka routing,expression overgrowth

I have an application that tries to change the @StreamListener approach to a functional approach, as @StreamListener is deprecated and might be removed someday soon.

The old approach allowed us to use the following conception:

@StreamListener(target = Channel.INPUT_ENROLL, condition = "headers['type']=='Type1'" ...)
handleType1{...}

@StreamListener(target = Channel.INPUT_ENROLL, condition = "headers['type']=='Type2'" ...)
handleType2{...}

...

@StreamListener(target = Channel.INPUT_ENROLL, condition = "headers['type']=='Typen'" ...)
handleTypen{...}

In the project, the routing expression would become something like this, which seems imposible to maintain:

routing-expression: "header['type'] == 'type1' ? 'handleType1' : "header['type'] == 'type2' ? 'handleType2':..."header['type'] == 'typen' ? 'handleTypen' : 'handleUnsupportedType'"

Is there any way other than this to maintain the code?

Upvotes: 1

Views: 229

Answers (1)

Related Questions