关于sap:如何使用-SAP-Kyma-控制台手动发送-SAP-Commerce-Cloud-Mock-应用暴露的事件

4次阅读

共计 1601 个字符,预计需要花费 5 分钟才能阅读完成。

网址:https://developers.sap.com/tu…

本地门路:
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: source
        type: exact
        value: ""
      eventType:
        property: type
        type: exact
        value: sap.kyma.custom.mp-commerce-mock.order.created.v1
  protocol: ""
  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.ky…

抉择 remote API:

抉择 SAP Commerce Cloud – Events:

Event topic 下拉列表里,抉择 order.created.v1, 再点击 Send Event 即可:

更多 Jerry 的原创文章,尽在:” 汪子熙 ”:

正文完
 0