Skip to content

how to execute 2 branch components concurrently #3523

Description

@lizhe19

input:
generate:
mapping: root = {"reqCode":"123456","data":"info"}
interval: 0s
count: 1
pipeline:
processors:
- mapping: |
meta start = timestamp_unix_milli()
- log:
level: INFO
message: 'once requet record start time:${!now().ts_format("2006-01-02 15:04:05")}'
- parallel:
cap: 0
processors:
- branch:
processors:
- http:
headers:
Content-Type: application/json; charset=UTF-8
TEST: test
url: http://172.32.6.25:9357/test/http2
verb: POST
timeout: 30s
parallel: true
- catch:
- log:
level: ERROR
message: "request execption,request body=${!content()}"
- branch:
processors:
- http:
headers:
Content-Type: application/json; charset=UTF-8
TEST: test
url: http://172.32.6.25:9357/test/http3
verb: POST
timeout: 30s
parallel: true
- catch:
- log:
level: ERROR
message: "request execption,request body=${!content()}"
- log:
level: INFO
message: 'once request used time total:${!(timestamp_unix_milli() - metadata("start"))}ms'
output:
stdout: {}

Activity

  1. lizhe19 commented on Jul 3, 2025

    @lizhe19
    Author

    i can not found any answer from the help doc, i try the "parallel" component, but can not take effect. how should i do?

  2. mihaitodor commented on Jul 7, 2025

    @mihaitodor
    Contributor

    Hey @lizhe19, messages need to be batched if you want the parallel processor to have any effect. Since you have your processors in the pipeline section, they'll be executed in parallel according to pipeline.threads (see docs here). However, I guess you have a single message in there, given that generate.count is set to 1 (your sample yaml is not well formatted). You can set that to a higher value and get rid of the parallel processor. Alternatively, if you do have some other input which uses batching (or if you set generate.count and generate.batch_size to a values bigger than 1), you can make use of the parallel processor as well, but note that you'd get 2 levels of parallelism in that case if your processors are within the pipeline section.

    LE: Transferring this to a discussion as per #2026.

  3. lizhe19 commented on Jul 7, 2025

    @lizhe19
    Author
  4. locked and limited conversation to collaborators on Jul 7, 2025
  5. converted this issue into a discussion #3527 on Jul 7, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions