Cloud Events - Java and Vert.x
Vert.x + CloudEvents + Knative
The default mode has the app reply to your input events with the output event, which is simplest for demonstrating things working in isolation, but is also the model for working for the Knative Eventing concept. The input event is modified assigning a new source and type attribute.
K_SINK
mode has the app send events to the destination encoded in$K_SINK
, which is useful to demonstrate how folks can synthesize events to send to a Service or Broker when not initiated by a Broker invocation (e.g. implementing an event source). The input event is modified assigning a new source and type attribute.
The application will use $K_SINK
-mode whenever the environment variable is specified.
- Docker installed and running on your local machine, and a Docker Hub account configured (we’ll use it for a container registry).
To build the image, run:
mvn compile jib:build -Dimage=<image_name>
To deploy the Knative Service, look in the service.yaml
and replace <image>
with the deployed image name. Then run:
Get the URL for your Service with:
NAME URL LATESTCREATED LATESTREADY READY REASON
cloudevents-vertx http://cloudevents-java.xip.io cloudevents-vertx-86h28 cloudevents-vertx-86h28 True
You can also send CloudEvents spawning a temporary curl pod in your cluster with:
$ kubectl run curl \
--image=curlimages/curl --rm=true --restart=Never -ti -- \
-H "content-type: application/json" \
-H "ce-source: http://curl-command" \
-H "ce-type: curl.demo" \
-H "ce-id: 123-abc" \
-d '{"name":"Dave"}' \
http://cloudevents-java.default.svc
You’ll see on the console:
To remove the sample app from your cluster, delete the service record: