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

举报
Jerry Wang 发表于 2022/06/11 18:00:20 2022/06/11
【摘要】 网址: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 eve...

网址: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: 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.kyma.shoot.live.k8s-hana.ondemand.com/

选择 remote API:

选择 SAP Commerce Cloud - Events:

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

【版权声明】本文为华为云社区用户原创内容,转载时必须标注文章的来源(华为云社区)、文章链接、文章作者等基本信息, 否则作者和本社区有权追究责任。如果您发现本社区中有涉嫌抄袭的内容,欢迎发送邮件进行举报,并提供相关证据,一经查实,本社区将立刻删除涉嫌侵权内容,举报邮箱: cloudbbs@huaweicloud.com
  • 点赞
  • 收藏
  • 关注作者

评论(0

0/1000
抱歉,系统识别当前为高风险访问,暂不支持该操作

全部回复

上滑加载中

设置昵称

在此一键设置昵称,即可参与社区互动!

*长度不超过10个汉字或20个英文字符,设置后3个月内不可修改。

*长度不超过10个汉字或20个英文字符,设置后3个月内不可修改。