tree: 44eb6c960150857bfdab776fa6dda28a8e8d2e6a [path history] [tgz]
  1. log-sink.kamelet.yaml
  2. log-sink.pipe.yaml
  3. readme.md
  4. timer-events.yaml
  5. timer-source.kamelet.yaml
  6. timer-source.pipe.yaml
generic-examples/kamelets/timer-source-log-sink/readme.md

Timer Source to Log Sink

This example shows how to create a simple timer event source and a log event sink. The timer events emitted are consumed by a simple logging connector which will print out those events.

Additional requirement for running this example

Create events source and sink

Let's start by creating the timer event source and log event sink as kamelets.

$ kubectl apply -f timer-source.kamelet.yaml
$ kubectl apply -f log-sink.kamelet.yaml

You can check the newly created kamelets in the list.

$ kubectl get kamelets timer-source log-sink

NAME           PHASE
timer-source   Ready
log-sink       Ready

Create channel destination

Let's continue by creating a knative destination.

$ kubectl apply -f timer-events.yaml

Binding events

We can now bind the timer event source to produce events on the destination with the timer-source.pipe.yaml configuration.

$ kubectl apply -f timer-source.pipe.yaml

In a similar fashion you can bind to the log sink in order to consume those events with the log-sink.pipe.yaml configuration.

$ kubectl apply -f log-sink.pipe.yaml

You can check the newly created bindings listing the Pipes.

$ kubectl get Pipes

NAME                 PHASE
log-event-sink       Ready
timer-event-source   Ready

Watch the event sink

After a while you will be able to watch the event consumed by the underlying log-event-sink integration:

$ kamel log log-event-sink

[1] Monitoring pod log-event-sink-00001-deployment-7cf6d488c9-2nbx8
...
[1] 2022-08-20 08:56:01,284 INFO  [sink] (executor-thread-0) Exchange[ExchangePattern: InOnly, BodyType: byte[], Body: Hello world!]
[1] 2022-08-20 08:56:02,284 INFO  [sink] (executor-thread-0) Exchange[ExchangePattern: InOnly, BodyType: byte[], Body: Hello world!]
[1] 2022-08-20 08:56:03,285 INFO  [sink] (executor-thread-0) Exchange[ExchangePattern: InOnly, BodyType: byte[], Body: Hello world!]
[1] 2022-08-20 08:56:04,286 INFO  [sink] (executor-thread-0) Exchange[ExchangePattern: InOnly, BodyType: byte[], Body: Hello world!]
[1] 2022-08-20 08:56:05,285 INFO  [sink] (executor-thread-0) Exchange[ExchangePattern: InOnly, BodyType: byte[], Body: Hello world!]