Multiple Cases

    • the first branch accepts events with a time that is is even
    • the second branch accepts events with a time that is is odd

    The events produced by each branch are then sent to the service.

    Please refer to the sample overview for the prerequisites.

    1. kubectl create -f ./filters.yaml -f ./transformers.yaml
    1. apiVersion: serving.knative.dev/v1
    2. kind: Service
    3. metadata:
    4. name: event-display
    5. spec:
    6. template:
    7. spec:
    8. containers:
    9. - image: gcr.io/knative-releases/knative.dev/eventing-contrib/cmd/event_display

    Change default below to create the Sequence in the Namespace where you want your resources to be created.

    The parallel.yaml file contains the specifications for creating the Parallel.

    1. apiVersion: flows.knative.dev/v1
    2. kind: Parallel
    3. metadata:
    4. name: odd-even-parallel
    5. spec:
    6. channelTemplate:
    7. apiVersion: messaging.knative.dev/v1
    8. kind: InMemoryChannel
    9. branches:
    10. - filter:
    11. apiVersion: serving.knative.dev/v1
    12. kind: Service
    13. name: even-filter
    14. subscriber:
    15. apiVersion: serving.knative.dev/v1
    16. kind: Service
    17. name: even-transformer
    18. - filter:
    19. ref:
    20. apiVersion: serving.knative.dev/v1
    21. kind: Service
    22. name: odd-filter
    23. subscriber:
    24. ref:
    25. apiVersion: serving.knative.dev/v1
    26. kind: Service
    27. name: odd-transformer
    28. reply:
    29. ref:
    30. apiVersion: serving.knative.dev/v1
    31. kind: Service
    32. name: event-display
    1. kubectl create -f ./parallel.yaml
    1. kubectl create -f ./ping-source.yaml

    You can now see the final output by inspecting the logs of the event-display pods. Note that since we set the PingSource to emit every minute, it might take some time for the events to show up in the logs.

    Let’s look at the event-display log:

    1. kubectl logs -l serving.knative.dev/service=event-display --tail=30 -c user-container
    2. ☁️ cloudevents.Event
    3. Context Attributes,
    4. type: dev.knative.sources.ping
    5. source: /apis/v1/namespaces/default/pingsources/ping-source
    6. id: 015a4cf4-8a43-44a9-8702-3d4171d27ba5
    7. time: 2020-03-03T21:24:00.0007254Z
    8. datacontenttype: application/json; charset=utf-8
    9. Extensions,
    10. knativehistory: odd-even-parallel-kn-parallel-kn-channel.default.svc.cluster.local; odd-even-parallel-kn-parallel-0-kn-channel.default.svc.cluster.local
    11. traceparent: 00-41a139bf073f3cfcba7bb7ce7f1488fc-68a891ace985221a-00
    12. Data,
    13. {
    14. "message": "we are even!"
    15. }
    16. ☁️ cloudevents.Event
    17. Validation: valid
    18. Context Attributes,
    19. specversion: 1.0
    20. type: dev.knative.sources.ping
    21. source: /apis/v1/namespaces/default/pingsources/ping-source
    22. id: 52e6b097-f914-4b5a-8539-165650e85bcd
    23. time: 2020-03-03T21:23:00.0004662Z
    24. datacontenttype: application/json; charset=utf-8
    25. Extensions,
    26. knativehistory: odd-even-parallel-kn-parallel-kn-channel.default.svc.cluster.local; odd-even-parallel-kn-parallel-1-kn-channel.default.svc.cluster.local
    27. traceparent: 00-58d371410d7daf2033be226860b4ee5d-05d686ee90c3226f-00
    28. Data,
    29. {
    30. }