Closed gauravsingh96 closed 1 year ago
Ok I see spelFunction is not the right function to do this. I am now doing it through headerEnricherFunction but I have to specify each header property and set it to empty string. Is there a way I can set all headers to empty string and not have to specify each separately. The new definition looks like
java -jar http-source-kafka-3.2.1.jar --spring.cloud.stream.bindings.output.destination=output --spring.cloud.stream.function.definition=httpSupplier,headerEnricherFunction --header.enricher.headers=prop1='' \n prop2='' \n prop3='' --header.enricher.overwrite=true --spring.cloud.stream.function.bindings.httpSupplierheaderEnricherFunction-out-0=output
It seems that the best way to solve this is using the HeaderFilter
from spring-integration
.
We will look at adding a header-filter
processor that wraps the functionality like header-enricher
wraps HeaderEnricher
from spring-integration
@corneil : I am assuming that this new function headerFilterFunction would be auto-configured to be used in composite function definition in any source application ( as is currently in my definition with headerEnricher). Also, any timeline when this could be released ?
PS - Looking forward to this feature.
We are preparing the release of 4.0.0-M1 soon which also upgrades the stream-apps to Boot 3.
If you follow the header-enricher-function and processor code you should be able to create your own processor to remove headers. There are 2 headers which you cannot delete: id
and timestamp
I am actually trying to avoid creating a separate processor. So I think best would be to wait till you guys configure it in the source applications.
See spring.cloud.stream.bindings.output.producer.header-mode=none
: https://docs.spring.io/spring-cloud-stream/docs/current/reference/html/spring-cloud-stream.html#_producer_properties
Try
Maven artifact:
org.springframework.cloud.stream.app:header-filter-processor-kafka:4.0.0-SNAPSHOT
org.springframework.cloud.stream.app:header-filter-processor-rabbit:4.0.0-SNAPSHOT
We should be publishing the docker image soon.
Docker:
springcloudstream/header-filter-processor-rabbit:4.0.0-SNAPSHOT
springcloudstream/header-filter-processor-kafka:4.0.0-SNAPSHOT
Closing via workaround in https://github.com/spring-cloud/stream-applications/issues/442#issuecomment-1497586720
Hi Team,
is there a way to clear entire header content using the spelFunction ? I am trying below definition but it gives error -
org.springframework.messaging.MessageHandlingException: Expression evaluation failed: headers=null; nested exception is org.springframework.expression.spel.SpelEvaluationException: EL1010E: Property or field 'headers' cannot be set on object of type 'org.springframework.messaging.support.GenericMessage' - maybe not public or not writable?
Definition:
java -jar http-source-kafka-3.2.1.jar --spring.cloud.stream.bindings.output.destination=output --spring.cloud.stream.function.definition=httpSupplier,spelFunction --spel.function.expression=headers=null --spring.cloud.stream.function.bindings.httpSupplierspelFunction-out-0=output