Conversation
WalkthroughAdds Changes
Sequence Diagram(s)sequenceDiagram
autonumber
participant Client as Client
participant Publisher as Spring Boot Publisher
participant Broker as Knative Broker
participant Trigger as Knative Trigger
participant Consumer as Event Consumer
participant DLQ as Dead-Letter Sink
Note over Client,Consumer: High-level CloudEvents flow from the new documentation
Client->>Publisher: HTTP request → trigger publish
Publisher->>Broker: HTTP POST CloudEvent
Broker-->>Broker: Validate & fan-out
Broker->>Trigger: Evaluate filters
alt Trigger matches
Trigger->>Consumer: Deliver CloudEvent (HTTP POST)
Consumer-->>Broker: 2xx ACK
else No match or delivery failure
Broker->>DLQ: Route to DLQ (if configured)
DLQ-->>Broker: ACK
end
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Suggested reviewers
Pre-merge checks (2 passed, 1 warning)❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
Poem
✨ Finishing Touches🧪 Generate unit tests
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 5
🧹 Nitpick comments (9)
.gitignore (1)
15-16: Be explicit about directory ignore and broaden .DS_Store patternUse a trailing slash to avoid matching files named “dist”, and ignore .DS_Store everywhere.
- dist -.DS_Store + dist/ + **/.DS_Storedocs/en/solutions/Leveraging_Knative_Eventing_for_Cloud_Event_Publishing_and_Consuming.md (8)
128-149: Nit: fix wording and pin imageMinor grammar and supply-chain hygiene.
- # Change to inhouse registry address and image + # Change to your in-house registry address and pin the image by digest - image: gcr.io/knative-releases/knative.dev/eventing/cmd/event_display + image: gcr.io/knative-releases/knative.dev/eventing/cmd/event_display@sha256:<digest>
200-205: Clarify Trigger filters syntax vs. API versionKnative supports both legacy spec.filter.attributes and newer spec.filters forms depending on version. Document the target version and stick to one form throughout to avoid confusion.
363-369: Fix typos and phrasingSmall editorial cleanups.
-For this part we will still build uppon the EventConsumer created on the last part. +For this part, we will build upon the EventConsumer created in the previous section.
559-574: Prefer env var over hard-coded defaultGiven you already set KNATIVE_BROKER_URL in the Deployment, avoid baking a cluster-specific default in code.
- url: http://broker-ingress.knative-operator.svc.cluster.local/my-app-namespace/default + url: ${KNATIVE_BROKER_URL}
695-705: Clarify service address for curlKubernetes Service isn’t externally accessible by default. Suggest using the in-cluster DNS name or port-forwarding for testing.
-Change the address to its full qualified URL and try the API: +From inside the cluster, use: http://springboot-event-app.my-app-namespace.svc.cluster.local/api/users +For local testing, first run: kubectl -n my-app-namespace port-forward svc/springboot-event-app 8080:80 +Then curl: http://localhost:8080/api/users
711-727: Trigger filter form inconsistent with earlier examplesEarlier you used spec.filters; here you switched to spec.filter.attributes. Please standardize to one form for the targeted Knative version.
56-61: Editorial fixes for consistency and typosQuick pass to improve readability and consistency (CloudEvents, Spring Boot, etc.).
- The following steps uses `Alauda DevOps Eventing v3` plugin + The following steps use the `Alauda DevOps Eventing v3` plugin - Lets create a simple HTTP service that receives and output events as logs: + Let's create a simple HTTP service that receives events and outputs them as logs: - ## Chapter 3. Enabling SpringBoot Applications for Cloud Events + ## Chapter 3. Enabling Spring Boot Applications for CloudEvents - com.example: DEBUG + com.example: DEBUG - ### Testing the SpringBoot Application + ### Testing the Spring Boot Application - And our main entrypoint + Main application entry pointAlso, the document jumps from Chapter 3 to Chapter 5; renumber or add the missing Chapter 4.
Also applies to: 128-129, 239-239, 571-574, 695-695, 803-805
207-207: Add link label punctuationGrammar nit.
-For a more detailed reference on Triggers, refer to the [Knative documentation](https://knative.dev/docs/eventing/triggers/). +For a more detailed reference on Triggers, refer to the [Knative documentation](https://knative.dev/docs/eventing/triggers/).
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
⛔ Files ignored due to path filters (3)
docs/public/KB250700002/knative-eventing.pngis excluded by!**/*.pngpackage-lock.jsonis excluded by!**/package-lock.jsonyarn.lockis excluded by!**/yarn.lock,!**/*.lock
📒 Files selected for processing (2)
.gitignore(1 hunks)docs/en/solutions/Leveraging_Knative_Eventing_for_Cloud_Event_Publishing_and_Consuming.md(1 hunks)
🧰 Additional context used
🪛 markdownlint-cli2 (0.17.2)
docs/en/solutions/Leveraging_Knative_Eventing_for_Cloud_Event_Publishing_and_Consuming.md
28-28: Images should have alternate text (alt text)
(MD045, no-alt-text)
750-750: Hard tabs
Column: 1
(MD010, no-hard-tabs)
751-751: Hard tabs
Column: 1
(MD010, no-hard-tabs)
752-752: Hard tabs
Column: 1
(MD010, no-hard-tabs)
753-753: Hard tabs
Column: 1
(MD010, no-hard-tabs)
🔇 Additional comments (2)
docs/en/solutions/Leveraging_Knative_Eventing_for_Cloud_Event_Publishing_and_Consuming.md (2)
809-814: Validate external referencesDouble-check that all referenced docs/URLs are still current and accessible; consider pinning to specific versions if needed.
85-93: Verify broker URL discovery command
Confirm thatkubectl get broker default -n my-app-namespace -o jsonpath='{.status.address.url}'successfully returns the broker URL in your environment (ensurekubectlis installed, your context is set, and the namespace is correct) before replacing hard-coded URLs.
c74d683 to
a2a699b
Compare
There was a problem hiding this comment.
Actionable comments posted: 0
♻️ Duplicate comments (4)
docs/en/solutions/Leveraging_Knative_Eventing_for_Cloud_Event_Publishing_and_Consuming.md (4)
28-28: Add descriptive alt text to the imageImage is missing alt text; keep current path and add a concise description.
- +
281-322: Null-safe data logging, charset, and remove unused importAvoid NPE when data is absent, specify UTF-8, and drop an unused import.
import io.cloudevents.http.HttpMessageFactory; -import io.cloudevents.jackson.JsonFormat; +import java.nio.charset.StandardCharsets; @@ - logger.info(" Data: {}", new String(event.getData().toBytes())); + if (event.getData() != null) { + logger.info(" Data: {}", new String(event.getData().toBytes(), StandardCharsets.UTF_8)); + } else { + logger.info(" Data: <none>"); + }
463-499: Add HTTP timeouts and ensure disconnect/stream cleanupPrevent resource leaks and hanging connections; also guard null error stream.
- private void publishEvent(CloudEvent event) { - try { - URL url = URI.create(brokerUrl).toURL(); - HttpURLConnection httpUrlConnection = (HttpURLConnection) url.openConnection(); + private void publishEvent(CloudEvent event) { + HttpURLConnection httpUrlConnection = null; + try { + URL url = URI.create(brokerUrl).toURL(); + httpUrlConnection = (HttpURLConnection) url.openConnection(); httpUrlConnection.setRequestMethod("POST"); httpUrlConnection.setDoOutput(true); httpUrlConnection.setDoInput(true); + httpUrlConnection.setConnectTimeout(5000); + httpUrlConnection.setReadTimeout(10000); @@ - int responseCode = httpUrlConnection.getResponseCode(); + int responseCode = httpUrlConnection.getResponseCode(); logger.info("Broker response code: {}", responseCode); @@ - String errorResponse = ""; - try { - errorResponse = new String(httpUrlConnection.getErrorStream().readAllBytes()); - } catch (Exception e) { - // Ignore error reading error stream - } + String errorResponse = ""; + try (var es = httpUrlConnection.getErrorStream()) { + if (es != null) { + errorResponse = new String(es.readAllBytes()); + } + } catch (Exception ignore) { + // ignore + } logger.error("Failed to publish event. Response code: {}, Error: {}", responseCode, errorResponse); throw new RuntimeException("Failed to publish event. Response code: " + responseCode); } } catch (Exception e) { logger.error("Error publishing event to broker", e); throw new RuntimeException("Failed to publish event", e); + } finally { + if (httpUrlConnection != null) { + httpUrlConnection.disconnect(); + } } }
767-789: Move delivery block under spec (not subscriber)Current placement is invalid and will be ignored.
spec: broker: default filter: attributes: type: com.example.order.placed subscriber: ref: apiVersion: v1 kind: Service name: order-processor - delivery: - deadLetterSink: - ref: - apiVersion: v1 - kind: Service - name: dead-letter-service - retry: 3 + delivery: + deadLetterSink: + ref: + apiVersion: v1 + kind: Service + name: dead-letter-service + retry: 3
🧹 Nitpick comments (8)
.gitignore (1)
1-17: Optional: Add a few common OS/editor ignores.Consider also ignoring Windows and IDE artifacts to reduce churn:
- Thumbs.db
- .idea/ (JetBrains)
- .vscode/ (workspace settings, only if not intentionally shared)
Proposed patch:
+.idea/ +.vscode/ +Thumbs.dbdocs/en/solutions/Leveraging_Knative_Eventing_for_Cloud_Event_Publishing_and_Consuming.md (7)
128-128: Grammar nit: “Let’s”Use the contraction.
-Lets create a simple HTTP service that receives and output events as logs: +Let's create a simple HTTP service that receives and outputs events as logs:
239-239: Consistent naming: “Spring Boot”Align heading with standard spelling used elsewhere in the doc.
-## Chapter 3. Enabling SpringBoot Applications for Cloud Events +## Chapter 3. Enabling Spring Boot Applications for Cloud Events
294-294: Remove unused importjava.util.Map isn’t used.
-import java.util.Map;
679-679: Unify broker ingress hostname across docsEarlier examples use knative-operator; this env var uses knative-eventing. Pick one to avoid confusion. Below aligns to earlier “kubectl get broker” URL.
- value: "http://broker-ingress.knative-eventing.svc.cluster.local/my-app-namespace/default" + value: "http://broker-ingress.knative-operator.svc.cluster.local/my-app-namespace/default"If your cluster exposes broker-ingress via knative-eventing instead, switch the earlier examples to match. Please confirm which is correct for ACP v3.
695-695: Consistent naming: “Spring Boot”Fix heading.
-### Testing the SpringBoot Application +### Testing the Spring Boot Application
699-705: Make curl test workable from a developer machineAdd port-forward so the service is reachable; then curl localhost.
- curl -X POST http://springboot-event-app/api/users \ + kubectl -n my-app-namespace port-forward svc/springboot-event-app 8080:80 + curl -X POST http://localhost:8080/api/users \ -H "Content-Type: application/json" \ -d '{"email": "user@example.com"}'
401-405: Property vs env var mapping sanity checkYou use @value("knative.broker.url") with a default and also set KNATIVE_BROKER_URL via env. Spring Boot will map KNATIVE_BROKER_URL → knative.broker.url (OK). Ensure the value matches the earlier Broker URL and avoid drift between application.yml and the Deployment env var.
Also applies to: 567-574, 679-679
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
⛔ Files ignored due to path filters (3)
docs/public/KB250700002/knative-eventing.pngis excluded by!**/*.pngpackage-lock.jsonis excluded by!**/package-lock.jsonyarn.lockis excluded by!**/yarn.lock,!**/*.lock
📒 Files selected for processing (2)
.gitignore(1 hunks)docs/en/solutions/Leveraging_Knative_Eventing_for_Cloud_Event_Publishing_and_Consuming.md(1 hunks)
🧰 Additional context used
🪛 markdownlint-cli2 (0.17.2)
docs/en/solutions/Leveraging_Knative_Eventing_for_Cloud_Event_Publishing_and_Consuming.md
28-28: Images should have alternate text (alt text)
(MD045, no-alt-text)
750-750: Hard tabs
Column: 1
(MD010, no-hard-tabs)
751-751: Hard tabs
Column: 1
(MD010, no-hard-tabs)
752-752: Hard tabs
Column: 1
(MD010, no-hard-tabs)
753-753: Hard tabs
Column: 1
(MD010, no-hard-tabs)
🔇 Additional comments (3)
.gitignore (2)
16-16: Good addition: .DS_StoreIgnoring macOS .DS_Store files prevents noisy diffs on mac machines. Looks good.
15-15: Confirmdistgeneration prior to Docker build — Dockerfile copiesdist/(lines 3–5) but.gitignoreexcludes it, so ensure your CI or local workflow runsdoom build(or equivalent) to populatedistbeforedocker build.docs/en/solutions/Leveraging_Knative_Eventing_for_Cloud_Event_Publishing_and_Consuming.md (1)
741-759: Fix YAML formatting, typo, and filter syntax• Replace tabs with spaces
• Fix typoamound→amount
• Indentfilterscorrectly for- all:with nested- exact:and- suffix:spec: broker: default - filters: - - all: - - exact: - type: com.example.order.placed - - suffix: - amount: "1000" # Filter for amound suffixed attributes equals to 1000 + filters: + - all: + - exact: + type: com.example.order.placed + - suffix: + amount: "1000" # Filter for events whose 'amount' extension ends with "1000"Confirm your Knative Eventing version supports
spec.filters(alpha behind thenew-trigger-filtersfeature gate); if not, use the legacyspec.filter.attributessyntax or a CEL filter workaround.
a2a699b to
42d4100
Compare
There was a problem hiding this comment.
Actionable comments posted: 3
♻️ Duplicate comments (5)
docs/en/solutions/Leveraging_Knative_Eventing_for_Cloud_Event_Publishing_and_Consuming.md (5)
28-28: Add descriptive alt text to image (accessibility)
Missing alt text violates MD045 and hurts accessibility.Apply:
- +
281-321: Avoid NPE on event.getData() and drop unused import
Directly dereferencingevent.getData()may NPE;JsonFormatimport is unused.Apply:
-import io.cloudevents.jackson.JsonFormat; @@ - logger.info(" Data: {}", new String(event.getData().toBytes())); + if (event.getData() != null) { + logger.info(" Data: {}", new String(event.getData().toBytes(), java.nio.charset.StandardCharsets.UTF_8)); + } else { + logger.info(" Data: <none>"); + }
463-499: Add HTTP timeouts and always disconnect to avoid resource leaks
No timeouts and missing disconnect can hang or leak connections.Apply:
- private void publishEvent(CloudEvent event) { - try { - URL url = URI.create(brokerUrl).toURL(); - HttpURLConnection httpUrlConnection = (HttpURLConnection) url.openConnection(); + private void publishEvent(CloudEvent event) { + HttpURLConnection httpUrlConnection = null; + try { + URL url = URI.create(brokerUrl).toURL(); + httpUrlConnection = (HttpURLConnection) url.openConnection(); httpUrlConnection.setRequestMethod("POST"); httpUrlConnection.setDoOutput(true); httpUrlConnection.setDoInput(true); + httpUrlConnection.setConnectTimeout(5000); + httpUrlConnection.setReadTimeout(10000); @@ - String errorResponse = ""; - try { - errorResponse = new String(httpUrlConnection.getErrorStream().readAllBytes()); - } catch (Exception e) { - // Ignore error reading error stream - } + String errorResponse = ""; + try (java.io.InputStream es = httpUrlConnection.getErrorStream()) { + if (es != null) { + errorResponse = new String(es.readAllBytes(), java.nio.charset.StandardCharsets.UTF_8); + } + } catch (Exception e) { + // Ignore error reading error stream + } @@ - } catch (Exception e) { + } catch (Exception e) { logger.error("Error publishing event to broker", e); throw new RuntimeException("Failed to publish event", e); + } finally { + if (httpUrlConnection != null) { + httpUrlConnection.disconnect(); + } } }Also applies to the same method’s error-stream handling pattern below.
741-759: Fix YAML: tabs, typo, and suffix filter syntax (and confirm feature gate)
Tabs make YAML invalid;amoundis a typo; ensure suffix value is a quoted string and indentation is valid.Apply:
spec: broker: default - filters: - - all: - - exact: - type: com.example.order.placed - - suffix: - amount: "1000" # Filter for amound suffixed attributes equals to 1000 + filters: + - all: + - exact: + type: com.example.order.placed + - suffix: + amount: "1000" # Filter for events whose string 'amount' extension ends with "1000" subscriber: ref: apiVersion: v1 kind: Service name: high-value-order-processorEnsure
new-trigger-filtersis enabled on your Knative version; otherwise switch tospec.filter.attributesor CEL.
767-789: Place delivery under spec, not subscriber
deliveryundersubscriberis invalid; move it tospec.delivery.Apply:
spec: broker: default filter: attributes: type: com.example.order.placed subscriber: ref: apiVersion: v1 kind: Service name: order-processor - delivery: - deadLetterSink: - ref: - apiVersion: v1 - kind: Service - name: dead-letter-service - retry: 3 + delivery: + deadLetterSink: + ref: + apiVersion: v1 + kind: Service + name: dead-letter-service + retry: 3
🧹 Nitpick comments (2)
docs/en/solutions/Leveraging_Knative_Eventing_for_Cloud_Event_Publishing_and_Consuming.md (2)
401-403: Align broker ingress host consistently
Two different broker ingress hosts are used (knative-operatorvsknative-eventing). Pick one that matches your install to avoid misroutes.Example (adjust to your cluster):
- value: "http://broker-ingress.knative-eventing.svc.cluster.local/my-app-namespace/default" + value: "http://broker-ingress.knative-operator.svc.cluster.local/my-app-namespace/default"Note: Spring Boot will map KNATIVE_BROKER_URL -> knative.broker.url via relaxed binding.
Also applies to: 677-680
128-128: Minor wording/typo fixes in user-facing text
Improves clarity and consistency.Apply:
-Lets create a simple HTTP service that receives and output events as logs: +Let's create a simple HTTP service that receives events and outputs them to logs:- # Change to inhouse registry address and image + # Change to in-house registry address and image-## Chapter 3. Enabling SpringBoot Applications for Cloud Events +## Chapter 3. Enabling Spring Boot Applications for CloudEvents-For this part we will still build uppon the EventConsumer created on the last part. +For this part, we'll build upon the EventConsumer created in the previous section.-### Testing the SpringBoot Application +### Testing the Spring Boot applicationAlso applies to: 147-147, 238-239, 363-365, 695-695
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
⛔ Files ignored due to path filters (1)
docs/public/KB250700002/knative-eventing.pngis excluded by!**/*.png
📒 Files selected for processing (2)
.gitignore(1 hunks)docs/en/solutions/Leveraging_Knative_Eventing_for_Cloud_Event_Publishing_and_Consuming.md(1 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
- .gitignore
🧰 Additional context used
🪛 markdownlint-cli2 (0.17.2)
docs/en/solutions/Leveraging_Knative_Eventing_for_Cloud_Event_Publishing_and_Consuming.md
28-28: Images should have alternate text (alt text)
(MD045, no-alt-text)
750-750: Hard tabs
Column: 1
(MD010, no-hard-tabs)
751-751: Hard tabs
Column: 1
(MD010, no-hard-tabs)
752-752: Hard tabs
Column: 1
(MD010, no-hard-tabs)
753-753: Hard tabs
Column: 1
(MD010, no-hard-tabs)
| ```yaml | ||
| apiVersion: eventing.knative.dev/v1 | ||
| kind: Trigger | ||
| metadata: | ||
| name: ping-trigger | ||
| namespace: my-app-namespace | ||
| spec: | ||
| broker: default | ||
| # empty filters means all events will be sent to the subscriber | ||
| filters: [] | ||
| subscriber: | ||
| ref: | ||
| apiVersion: v1 | ||
| kind: Service | ||
| name: event-display | ||
| ``` |
There was a problem hiding this comment.
💡 Verification agent
❓ Verification inconclusive
Use stable Trigger filter field (avoid alpha-only spec.filters)
spec.filters: [] relies on an alpha feature gate; prefer stable spec.filter (or omit filter) so “match all” works across installs.
Apply:
spec:
broker: default
- # empty filters means all events will be sent to the subscriber
- filters: []
+ # no filter means all events will be sent to the subscriber (stable API)
+ filter: {}
subscriber:
ref:
apiVersion: v1
kind: Service
name: event-displayAnd adjust docs:
-- `spec.filters`: Defines filtering criteria for events
+- `spec.filter`: Defines filtering criteria for eventsIf you do want the new multi-filter syntax, confirm the new-trigger-filters feature gate is enabled in your Knative cluster and version supports it.
Also applies to: 200-205
Use stable Trigger filter (avoid alpha-only spec.filters)
spec.filters requires the new-trigger-filters alpha feature gate (k8s-docs.github.io); switch to the stable spec.filter (or omit it) so match-all works universally (knative.dev).
In docs/en/solutions/Leveraging_Knative_Eventing_for_Cloud_Event_Publishing_and_Consuming.md (177–192, 200–205) apply:
spec:
broker: default
- # empty filters means all events will be sent to the subscriber
- filters: []
+ # no filter means all events will be sent to the subscriber (stable API)
+ filter: {}Update all occurrences of spec.filters to spec.filter.
📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| ```yaml | |
| apiVersion: eventing.knative.dev/v1 | |
| kind: Trigger | |
| metadata: | |
| name: ping-trigger | |
| namespace: my-app-namespace | |
| spec: | |
| broker: default | |
| # empty filters means all events will be sent to the subscriber | |
| filters: [] | |
| subscriber: | |
| ref: | |
| apiVersion: v1 | |
| kind: Service | |
| name: event-display | |
| ``` | |
| apiVersion: eventing.knative.dev/v1 | |
| kind: Trigger | |
| metadata: | |
| name: ping-trigger | |
| namespace: my-app-namespace | |
| spec: | |
| broker: default | |
| # no filter means all events will be sent to the subscriber (stable API) | |
| filter: {} | |
| subscriber: | |
| ref: | |
| apiVersion: v1 | |
| kind: Service | |
| name: event-display |
🤖 Prompt for AI Agents
In
docs/en/solutions/Leveraging_Knative_Eventing_for_Cloud_Event_Publishing_and_Consuming.md
around lines 177–192 (and also check 200–205), update the Trigger examples and
any narrative that use the alpha-only field name `spec.filters` to the stable
field `spec.filter` (or remove the filter stanza entirely to indicate a
match-all behavior); ensure the YAML and text consistently reference
`spec.filter` and, if keeping an explicit match-all, use `spec.filter: []` or
omit the field per Knative docs so it works without the alpha feature gate.
| <dependencies> | ||
| <dependency> | ||
| <groupId>org.springframework.boot</groupId> | ||
| <artifactId>spring-boot-starter-web</artifactId> | ||
| </dependency> | ||
| <dependency> | ||
| <groupId>org.springframework.boot</groupId> | ||
| <artifactId>spring-boot-starter-actuator</artifactId> | ||
| </dependency> | ||
| <dependency> | ||
| <groupId>io.cloudevents</groupId> | ||
| <artifactId>cloudevents-core</artifactId> | ||
| <version>2.5.0</version> | ||
| </dependency> | ||
| <dependency> | ||
| <groupId>io.cloudevents</groupId> | ||
| <artifactId>cloudevents-http-basic</artifactId> | ||
| <version>2.5.0</version> | ||
| </dependency> | ||
| <dependency> | ||
| <groupId>io.cloudevents</groupId> | ||
| <artifactId>cloudevents-json-jackson</artifactId> | ||
| <version>2.5.0</version> | ||
| </dependency> |
There was a problem hiding this comment.
💡 Verification agent
🧩 Analysis chain
Confirm CloudEvents Java SDK versions
Pinned to 2.5.0; verify latest stable to avoid CVEs/bugs.
🌐 Web query:
What is the latest stable version of the CloudEvents Java SDK modules (cloudevents-core, cloudevents-http-basic, cloudevents-json-jackson) as of September 2025?
💡 Result:
Checked Sep 9, 2025 — latest stable versions on Maven Central:
- cloudevents-core: 4.0.1. [1]
- cloudevents-http-basic: 4.0.1. [2]
- cloudevents-json-jackson: 4.0.1. [3]
Sources: Maven Central listings for each artifact. [1] (mvnrepository.com) [2] (mvnrepository.com) [3] (mvnrepository.com)
Citations:
- 1: https://mvnrepository.com/artifact/io.cloudevents/cloudevents-core/4.0.1?utm_source=openai
- 2: https://mvnrepository.com/artifact/io.cloudevents/cloudevents-http-basic/4.0.1?utm_source=openai
- 3: https://mvnrepository.com/artifact/io.cloudevents/cloudevents-json-jackson/4.0.1?utm_source=openai
Upgrade CloudEvents Java SDK dependencies to latest stable (4.0.1)
In docs/en/solutions/Leveraging_Knative_Eventing_for_Cloud_Event_Publishing_and_Consuming.md (lines 245–268), update cloudevents-core, cloudevents-http-basic, and cloudevents-json-jackson from 2.5.0 to 4.0.1 cite123
🤖 Prompt for AI Agents
In
docs/en/solutions/Leveraging_Knative_Eventing_for_Cloud_Event_Publishing_and_Consuming.md
around lines 245 to 268, the CloudEvents Java SDK dependencies
(cloudevents-core, cloudevents-http-basic, cloudevents-json-jackson) are pinned
to 2.5.0; update each of these dependency version tags from 2.5.0 to 4.0.1 in
the dependency block so the docs reflect the latest stable SDK version.
| public void publishOrderPlacedEvent(String orderId, String customerId, double amount) { | ||
| try { | ||
| // Create event data | ||
| OrderPlacedData eventData = new OrderPlacedData(orderId, customerId, amount); | ||
|
|
||
| // Serialize event data to JSON | ||
| String eventDataJson = objectMapper.writeValueAsString(eventData); | ||
| byte[] eventDataBytes = eventDataJson.getBytes(); | ||
|
|
||
| // Build CloudEvent | ||
| CloudEvent event = CloudEventBuilder.v1() | ||
| .withId(UUID.randomUUID().toString()) | ||
| .withType("com.example.order.placed") | ||
| .withSource(URI.create("https://example.com/order-service")) | ||
| .withTime(OffsetDateTime.now()) | ||
| .withData("application/json", eventDataBytes) | ||
| .build(); | ||
|
|
There was a problem hiding this comment.
🛠️ Refactor suggestion
Make suffix-based Trigger example actually match by adding 'amount' extension
Your later Trigger filters on the string extension attribute amount, but the event sets amount only in the data payload. Expose it as an extension for the example to work.
Apply:
CloudEvent event = CloudEventBuilder.v1()
.withId(UUID.randomUUID().toString())
.withType("com.example.order.placed")
.withSource(URI.create("https://example.com/order-service"))
.withTime(OffsetDateTime.now())
+ // expose 'amount' as string extension for Trigger suffix filter
+ .withExtension("amount", String.valueOf(amount))
.withData("application/json", eventDataBytes)
.build();📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| public void publishOrderPlacedEvent(String orderId, String customerId, double amount) { | |
| try { | |
| // Create event data | |
| OrderPlacedData eventData = new OrderPlacedData(orderId, customerId, amount); | |
| // Serialize event data to JSON | |
| String eventDataJson = objectMapper.writeValueAsString(eventData); | |
| byte[] eventDataBytes = eventDataJson.getBytes(); | |
| // Build CloudEvent | |
| CloudEvent event = CloudEventBuilder.v1() | |
| .withId(UUID.randomUUID().toString()) | |
| .withType("com.example.order.placed") | |
| .withSource(URI.create("https://example.com/order-service")) | |
| .withTime(OffsetDateTime.now()) | |
| .withData("application/json", eventDataBytes) | |
| .build(); | |
| public void publishOrderPlacedEvent(String orderId, String customerId, double amount) { | |
| try { | |
| // Create event data | |
| OrderPlacedData eventData = new OrderPlacedData(orderId, customerId, amount); | |
| // Serialize event data to JSON | |
| String eventDataJson = objectMapper.writeValueAsString(eventData); | |
| byte[] eventDataBytes = eventDataJson.getBytes(); | |
| // Build CloudEvent | |
| CloudEvent event = CloudEventBuilder.v1() | |
| .withId(UUID.randomUUID().toString()) | |
| .withType("com.example.order.placed") | |
| .withSource(URI.create("https://example.com/order-service")) | |
| .withTime(OffsetDateTime.now()) | |
| // expose 'amount' as string extension for Trigger suffix filter | |
| .withExtension("amount", String.valueOf(amount)) | |
| .withData("application/json", eventDataBytes) | |
| .build(); |
🤖 Prompt for AI Agents
In
docs/en/solutions/Leveraging_Knative_Eventing_for_Cloud_Event_Publishing_and_Consuming.md
around lines 437 to 454, the CloudEvent is built without exposing the numeric
amount as an extension even though the Trigger later filters on the string
extension attribute "amount"; add an extension to the CloudEvent (e.g., call the
CloudEvent builder's withExtension("amount", String.valueOf(amount)) or
equivalent) before build so the Trigger's suffix-based filter matches the event.
Summary by CodeRabbit
Documentation
Chores