如何使用 SAP Kyma 控制台手动发送 SAP Commerce Cloud Mock 应用暴露的事件
網址:https://developers.sap.com/tutorials/cp-kyma-microservice-trigger.html
本地路徑:
C:\Code\referenceCode\SAP Kyma教程例子\api-mssql-go
(1) This tutorial relies on the Commerce mock application to publish events into the Kyma runtime.
(2) bind the Commerce mock application to the dev Namespace
(3) we will create a service instance of the SAP Commerce Cloud - Events.
(4) The service instance will allow for any microservice or lambda function within the dev Namespace to subscribe to these events by defining an event subscription.
借助這個 mock 應用的 service instance,我們可以讓 dev 命名空間的任何微服務或者Lambda Function,訂閱 service instance 暴露出的事件。
The subscription pairs an event source, the Commerce mock application, and the event type, order.created, to a subscriber.
訂閱實際上是一個抽象,包含了事件源,mock 應用,和訂閱事件類型。
這個訂閱的源代碼,用 yaml 文件定義如下:
apiVersion: eventing.kyma-project.io/v1alpha1 kind: Subscription metadata:name: api-mssql-go-event-sub spec:filter:filters:- eventSource:property: sourcetype: exactvalue: ""eventType:property: typetype: exactvalue: sap.kyma.custom.mp-commerce-mock.order.created.v1protocol: ""protocolsettings: {}sink: http://api-mssql-go.dev.svc.cluster.local:80/orderCodeEvent在cmd/api/main.go 里,為 /orderCodeEvent 這個 endpoint,注冊一個處理函數:ConsumeOrderCode
bind the mock application to the dev Namespace. This process is used to enable the usage of the APIs and events of the mock application to the bounded Namespace.
把 mock 應用綁定到 dev namespace,這樣才能讓該命名空間的應用,消費這個 mock 應用暴露出的事件。
也要為 mock 應用暴露出的 event,創建一個 instance.
點擊 dev namespace,進入 Service Management -> Catalog, 選擇 mp-commerce-mock 應用:
選擇該 mock 應用 service plan 中的 SAP Commerce Cloud - Events:
點 Add 按鈕,創建新的實例:
測試
在 API rules 里,點擊 commerce-mock 的 host 超鏈接:
https://commerce.c-46d70f2.kyma.shoot.live.k8s-hana.ondemand.com/
選擇 remote API:
選擇 SAP Commerce Cloud - Events:
Event topic 下拉列表里,選擇 order.created.v1,再點擊 Send Event 即可:
更多Jerry的原創文章,盡在:“汪子熙”:
總結
以上是生活随笔為你收集整理的如何使用 SAP Kyma 控制台手动发送 SAP Commerce Cloud Mock 应用暴露的事件的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: SAP UI5 应用 index.htm
- 下一篇: 如何自动完成登录 SAP BTP wor