Search code examples
spring-cloud-dataflow

How to store the payload at any point to use it later


I've deployed spring-cloud-dataflow with Docker. These are the used containers:

  • springcloud/spring-cloud-dataflow-server-local:1.7.0.RELEASE
  • wurstmeister/zookeeper
  • wurstmeister/kafka:1.1.0

[other containers not involved in the issue ...]

Documentation consulted:

https://docs.spring.io/spring-cloud-dataflow/docs/1.7.0.RELEASE/reference/htmlsingle/


I am trying to create a stream in which i need to store the payload to use it later.

enter image description here

http | groovy-transform | httpclient_get: httpclient | httpclient_post: httpclient | log

There is some way to solve this need?


Solution

  • It's not clear from your generic description what the best approach would be. A couple of options:

    1. Fan out to the get and post

      http | groovy-transform > :request
      :request > httpclient-get |log
      :request > httpclient-post|log

    The streams can be joined:

     http | groovy-transform > :request     
     :request > httpclient-get > :response     
     :request > httpclient-post > :response
     :response > log
    
    1. Use a Header enricher processor to add the original payload as a header along with some code to extract the header in httpclient_post.

    Note if you are using the kafka binder with kafka < 0.11 client, you need to explicitly enable custom headers: For example:

    stream create hetest --definition "time | header-enricher --headers=foo='bar' | log --expression=headers"    
    stream deploy hetest --properties "app.*.spring.cloud.stream.kafka.binder.headers=foo"