2024 Mar 06 4:36 AM - edited 2024 Mar 25 8:31 AM
Links to March's developer challenge:
- Week 1: https://community.sap.com/t5/application-development-discussions/march-developer-challenge-cloudeven...
- Week 2: https://community.sap.com/t5/application-development-discussions/march-developer-challenge-cloudeven...
- Week 3: https://community.sap.com/t5/application-development-discussions/march-developer-challenge-cloudeven...
- Week 4: https://community.sap.com/t5/application-development-discussions/march-developer-challenge-cloudeven...
Today's system landscapes are very complex and we need to deal with many systems communicating with each other, ideally as close to real-time as possible. Nowadays, a system can publish events to notify other systems of the changes happening within the objects of their system. Given that we are talking of many systems, ideally, there will be a common way of describing the data produced by these systems. The CloudEvents specification can help us with this. We can leverage it to provide a consistent way for how our systems can communicate with others about these events.
As mentioned on the CloudEvents website... CloudEvents is a specification for describing event data in a common way. It's goal is to simplify event declaration and delivery across services, platforms and beyond! The specification is now under the Cloud Native Computing Foundation.
Below is an example of what a CloudEvent message will look like:
{
"specversion": "1.0",
"type": "com.github.pull_request.opened",
"source": "https://github.com/cloudevents/spec/pull",
"subject": "123",
"id": "A234-1234-1234",
"time": "2018-04-05T17:31:00Z",
"comexampleextension1": "value",
"comexampleothervalue": 5,
"datacontenttype": "text/xml",
"data": "<much wow=\"xml\"/>"
}
You'll notice that the example above is composed of many attributes, the event context. The context describes the event and is independent of the event data. Meaning that we can somehow process/inspect the event without needing to process its data. Now, let's dive a bit into the message itself.
For more information on the history, development and design rationale behind the specification, see the CloudEvents Primer document.
A CloudEvent message is mainly composed of context attributes and data.
A number of attributes can be included within the message, these attributes are known as Context Attributes and the idea is that these context attributes can be used to describe the event. We can think of these context attributes as the header information of our event that can be used for filtering and routing. Let's explore some of the attributes available.
Name | Required | Description | Example |
id | ✅ | Identifies the event. Producers MUST ensure that source + id is unique for each distinct event. | 63d6a150-c6a1-4c5b-bcc3-27d90c07941c |
source | ✅ | Identifies the context in which an event happened. | /default/sap.s4.beh/244572008 |
specversion | ✅ | The version of the CloudEvents specification which the event uses. | 1.0 |
type | ✅ | Describes the type of the event | sap.s4.beh.businesspartner.v1.BusinessPartner.Changed.v1 |
datacontenttype | Content type of the value in data. | application/json |
A CloudEvent message may also include additional context attributes, which are not defined as part of the specification. These additional attributes are known as "extension attributes" and can be used by the producer systems or intermediaries to include additional metadata to an event, similar to how we can use HTTP custom headers.
For example, in the SAP Digital Vehicle Hub Business Events package, we can see that the event raised when a vehicle changes - sap.dmo.dvh.Vehicle.Changed.v1, contains the extension context attribute sappassport, which is an SAP specific tracing identifier.
{
"specversion": "1.0",
"type": "sap.dmo.dvh.Vehicle.Changed.v1",
"source": "/eu10/sap.dmo.dvh",
"subject": "808E6E30B65149978A443429B29FB300",
"id": "a823e884-5edc-4194-a81a-f3a3632417ee",
"time": "2018-04-08 08:31:00",
"datacontenttype": "application/json",
"sappassport": "string",
....
}
A CloudEvent message may include a payload but this is not required. If included it will be in the format specified in the datacontenttype context attribute. Although it is not required, we will generally have a payload in messages. Below we can see an example of an event message that contains a payload. In this case, a Business Partner changed event generated by an SAP S/4HANA Cloud Public Edition.
{
"type": "sap.s4.beh.businesspartner.v1.BusinessPartner.Changed.v1",
"specversion": "1.0",
"source": "/default/sap.s4.beh/244572008",
"id": "63d6a150-c6a1-4c5b-bcc3-27d90c07941c",
"time": "2024-02-26T10:53:06Z",
"datacontenttype": "application/json",
"data": {
"BusinessPartner": "1000667"
}
}
Check out the Business Partner changed event in the SAP Business Accelerator Hub - https://hub.sap.com/event/CE_BUSINESSPARTNEREVENTS/resource.
SAP is an active contributor to the CloudEvents specification and one of its many adopters. Evidence of that is the different products (event packages) that we can find documented in the SAP Business Accelerator Hub > Events category.
The products listed below document their events in the form of event packages in the SAP Business Accelerator Hub. All their events follow the CloudEvents specification:
SAP's flagship ERP products, SAP S/4HANA Cloud Public edition and SAP S/4HANA, expose more than 600+ events combined. As you might have noticed from the events that we use as examples above, these events follow the CloudEvents specification. Below we can see the BusinessPartner Created event generated by an SAP S/4HANA Cloud Public Edition and we can see how it follows the CloudEvents specification.
{
"type": "sap.s4.beh.businesspartner.v1.BusinessPartner.Created.v1",
"specversion": "1.0",
"source": "/default/sap.s4.beh/244572008",
"id": "194780e0-b5db-1ede-b58a-4550178dff9e",
"time": "2024-02-26T09:50:00Z",
"datacontenttype": "application/json",
"data": {
"BusinessPartner": "1000667"
}
}
📢 Check out this blog post, https://community.sap.com/t5/application-development-blog-posts/cloudevents-at-sap/ba-p/13620137, if you want to learn more about CloudEvents at SAP 🌁.
👉 Your task for this week is: Create a CloudEvent message and share it as a comment in the comments section below. Note: The CloudEvent message that you submit in the comments section needs to be valid, as it will be checked against a JSON schema.
Let's proceed to create our first CloudEvent message. For this, let's use as an example an existing system in your organisation. You can use as a reference a system that you are familiar with. For example, a system that you know that it interacts/notifies other systems in your landscape about a particular change occurring within it.
The event that we create doesn't need to be of a real system/scenario. The goal of this exercise is for you to get familiar with the message format and create a sample event message that we can use in the future.
In my case, I will use as a reference a ticket managing system and create a CloudEvent message that will be produced whenever a new ticket is created.
{
"specversion": "1.0",
"type": "com.ajmaradiaga.tms.Ticket.Created.v1",
"source": "https://tms-prod.ajmaradiaga.com/tickets",
"subject": "IT00010232",
"id": "d121e256-2afd-1724-c80b-b5l3645357fa",
"time": "2024-02-22 14:10:00",
"datacontenttype": "application/json",
"data": {
"id": "IT00010232",
"description": "Install ColdTurkey to block distracting websites.",
"urgency": {
"id": 1,
"description": "High"
}
}
}
The above payload is what I would submit as an answer for this week's challenge. Now, go ahead, create a CloudEvent message and share it as a comment in the comments section.
2024 Mar 06 4:38 AM - edited 2024 Mar 06 6:32 AM
Example submission for this week. Ideally use a code block to nicely format your CloudEvent message :-).
{
"specversion": "1.0",
"type": "com.ajmaradiaga.tms.Ticket.Created.v1",
"source": "https://tms-prod.ajmaradiaga.com/tickets",
"subject": "IT00010232",
"id": "d121e256-2afd-1724-c80b-b5l3645357fa",
"time": "2024-02-22 14:10:00",
"datacontenttype": "application/json",
"data": {
"id": "IT00010232",
"description": "Install ColdTurkey to block distracting websites.",
"urgency": {
"id": 1,
"description": "High"
}
}
}
2024 Mar 06 7:34 AM
Here is my submission ✌️
{
"specversion": "1.0",
"type": "com.example.iot.device.event.v1",
"source": "https://iot-prod.example.com/devices",
"subject": "device12345-temperature-alert",
"id": "e241f360-4b3f-4c9b-a5e4-d35456b27f62",
"time": "2024-03-06 08:34:00",
"datacontenttype": "application/json",
"data": {
"device_id": "Device12345",
"event_type": "temperature-alert",
"description": "Temperature threshold exceeded.",
"data": {
"temperature": 75,
"threshold": 70,
"units": "Celsius"
}
}
}
2024 Mar 06 9:08 AM
{
"id": "3a4fe220-4d46-4321-b32d-e40f9a882b1c",
"source": "/build/events/launch",
"specversion": "1.0",
"type": "com.sap.build.app.Launched.v1",
"datacontenttype": "application/json",
"subject": ".gpg",
"time": "2024-03-06 14:10:00",
"data": {
"name": "My Build App",
"description": "An app that runs a car wash from anywhere.",
"tenant": "mycompany-5de8ecni"
}
}
2024 Mar 06 9:20 AM - edited 2024 Mar 06 9:25 AM
Here you go:
{
"specversion" : "1.0",
"type" : "com.exercise1.developerchallenge",
"source" : "https://s4hana/prod/",
"id" : "BAGXoM7Yw4S2iYHlcoaPd29t7YlFT",
"time" : "2023-03-06T10:13:00Z",
"datacontenttype" : "application/json",
"data" : {
"id": "00000000001",
"calendarweek": "10",
"month": "March",
"exercise": {
"task": "Design Cloud Event"
}
}
}
2024 Mar 06 10:09 AM - edited 2024 Mar 06 10:12 AM
{
"type": "sap.s4.beh.purchaserequisition.v1.PurchaseRequisition.Changed.v1",
"specversion": "1.0",
"source": "nedgia/eventmeshdev/dev",
"id": "AA06tkhWHt6FoCOmSZ/6+Q==",
"time": "2023-06-27T15:40:17Z",
"datacontenttype": "application/json",
"data": {
"PurchaseRequisition": "60004767"
}
}
What a interesting challenge Antonio! Looking forward to next weeks!!
2024 Mar 06 12:01 PM - edited 2024 Mar 06 3:13 PM
{
"specversion": "1.0",
"type": "com.awesome_company.sales_order.Updated.v1",
"source": "https://prod.illidian.awesome_company.com/sales_orders",
"subject": "AWO0190240000132024",
"id": "f8e9d7c6-5b4a-3c2d-1e0f-9a8b7c6d5e4f",
"time": "2024-03-06 13:00:00",
"datacontenttype": "application/json",
"data": {
"salesOrder": "9024000013",
"company": "AWO01",
"year": "2024",
"status": "Shipped"
}
}
2024 Mar 06 2:57 PM - edited 2024 Mar 06 2:57 PM
2024 Mar 06 3:14 PM
Forgot to copy the last line 🤣
2024 Mar 06 12:37 PM
Here is my submission:
{
"specversion": "1.0",
"type": "com.sonal.plm.NPDI.Created.v1",
"source": "https://plm-prod.sonal.com/npdis",
"subject": "NPDI000000001",
"id": "196179a2-6cf1-4166-9975-51f9afdb3a0d",
"time": "2024-03-06 12:00:00",
"datacontenttype": "application/json",
"data": {
"id": "NPDI000000001",
"description": "New Product Development and Introduction Created"
}
}
2024 Mar 06 1:51 PM
Here you go:
{
"type": "sap.s4.beh.product.v1.Product.Changed.v1",
"specversion": "1.0",
"source": "/default/sap.s4.beh/test",
"id": "6145bd0e-9b19-1edd-a18c-2966eaf68c13",
"time": "2024-03-06T16:35:49Z",
"datacontenttype": "application/json",
"data": {
"Product": "TEST MATERIALS"
}
}
2024 Mar 06 2:51 PM
Here you go:
{
"specversion": "1.0",
"type": "com.example.sales.Order.Updated.v1",
"source": "https://sales.example.com/orders",
"subject": "OR10001001",
"id": "fc04acbf-9112-4b5f-8898-ad01f2a18b34",
"time": "2024-03-06 15:45:00",
"datacontenttype": "application/json",
"data": {
"id": "OR10001001",
"changedBy": "TechnicalUser01",
"dataUrl": "https://sales.example.com/api/orders('OR10001001')"
}
}
2024 Mar 06 10:03 PM
{
"specversion": "1.0",
"type": "com.example.myapp.resource.created",
"source": "/myapp/resources/1234567890",
"id": "A234-1234-1234",
"time": "2023-03-05T18:00:00Z",
"datacontenttype": "application/json",
"data": {
"resourceId": "1234567890",
"resourceName": "My Resource",
"resourceType": "myapp.com/resources"
}
}
2024 Mar 07 11:17 AM
{
"specversion": "1.0",
"type": "com.servicechannel.WorkOrder.Created.v1",
"source": "https://test.servicechannel.com/workorders",
"id": "cca04a57-9d63-40ee-b39b-89cfc523e19d",
"time": "2024-03-07T17:31:00Z",
"datacontenttype": "application/json",
"data": {
"purchasenumber": "84409626",
"status": {
"primary": "open"
}
}
}
2024 Mar 07 12:03 PM - edited 2024 Mar 07 12:08 PM
{
"type": "sap.s4.beh.product.v1.Product.Created.v1",
"specversion": "1.0",
"source": "/default/sap.s4.beh/T49CLNT110",
"id": "000d3aa9-b9cf-1eee-81be-b537844fe89c",
"time": "2023-06-08T12:11:57Z",
"datacontenttype": "application/json",
"data": {
"Product": "6000002678"
}
}
2024 Mar 07 3:39 PM
2024 Mar 07 4:23 PM
{
"type": "sap.s4.beh.maintenanceorder.v1.MaintenanceOrder.SetToTechCompleted.v1",
"datacontenttype": "application/json",
"specversion": "1.0",
"source": "https://my400000.s4hana.cloud.sap/",
"subject":"OR000004000020",
"id": "QgEK7wzuHtqdhJwqCS+VOA==",
"time": "2024-03-07T11:00:00Z",
"data": {
"MaintenanceOrder": "4000020",
"MaintenanceOrderType":"YA01"
}
}
2024 Mar 08 8:37 AM
Hello,
{
"type": "sap.s4.beh.product.v1.Product.Changed.v1",
"datacontenttype": "application/json",
"specversion": "1.0",
"source": "../dictionary",
"subject": "productId:123",
"id": "QgEK7wzuHtqdhJwqCS+VOA==",
"time": "2024-03-05T17:31:00Z",
"data": {
"Product": "123",
"ProductCategory": "TELE",
"ProductType": "LCD"
}
}
2024 Mar 08 9:22 AM
Here is my try to create a "Production order created" event.
{
"type": "sap.s4.beh.productionorder.v1.ProductionOrder.Created.v1",
"datacontenttype": "application/json",
"specversion": "1.0",
"source": "m32z",
"subject": "Production Order 1000206 created",
"id": "QgEK7wzuHtqdhJwqCS+VOA==",
"time": "2024-02-08T12:00:00Z",
"data": {
"ProductionOrder": "1000206",
"ProductionOrderType": "PP01",
"ProductionPlant": "HD00"
}
}
2024 Mar 08 3:41 PM - edited 2024 Mar 08 3:42 PM
{
"type": "sap.s4.tinhtd.info.v1.SaleOrder.Created.v1",
"datacontenttype": "application/json",
"specversion": "1.0",
"source": "https://cloudevent.tinhtd.info/saleorders",
"subject": "Sales Order 10608090 created",
"id": "aHR0cHM6Ly9jb21tdW5pdHkuc2FwLmNvbS90N",
"time": "2024-03-08T13:00:00Z",
"data": {
"SaleOrder": "10608090",
"OrderType": "ZASO",
"OrdetItems": [
{
"ProductId":"P001",
"Price":200,
"Quantity":1
}
]
}
}
2024 Mar 08 10:02 PM
{
"type": "sap.s4.deliveryPGI.Created.v1",
"specversion": "1.0",
"source": "/default/sap.s4.beh/244572008",
"id": "194780e0-b5db-1ede-b58a-4550178dff9e",
"time": "2024-02-26T09:50:00Z",
"datacontenttype": "application/json",
"data": {
"DeliveryNo": "1000667",
"DeliveryType: "ZDRV"
}
2024 Mar 10 9:31 AM
@ajos, similar to @xavisanse before you are missing to close the payload but the essence is there.
2024 Mar 08 11:38 PM
{
id: v1(),
specversion: "1.0",
source: "week1testprog",
type: "week1testprog.demoevent",
datacontenttype: "application/json",
data: {
salutation: "hello"
}
}
2024 Mar 10 9:32 AM
@MarcelloUrbanithis is not a valid JSON... what's v1()?
2024 Mar 10 12:12 AM
2024 Mar 10 8:03 PM
Hi Antonio,
in my trial-Account i can´t find anything about the Event-Mesh.
Also after Activation the IntegrationSuite i can´t find Event-Mesh-Topics.
On reading the blogposts and discussions i thougt, that the Event-Mesh-Functions
will be available after activating the Integration-Suite.
What am i doing wrong?
kind Regards
Matthias
2024 Mar 11 8:08 AM - edited 2024 Mar 11 12:23 PM
@MatLakaemper, SAP Event Mesh is no longer available in the trial account - https://community.sap.com/t5/technology-blogs-by-sap/sap-event-mesh-trial-to-be-retired/ba-p/1355897.... At the moment SAP Event Mesh is a standalone service in a paid account, not available on trial. Related to SAP Integration Suite, there will be soon an event-capability part of SAP Integration Suite and you can find more information in https://roadmaps.sap.com. That said, SAP Event Mesh is not needed to complete the developer challenge 😉
2024 Mar 11 11:15 AM
Hello , Could you please elaborate what will happen to the scenarios that are developed using SAP Event Mesh standalone service ( Not Advanced Event Mesh ) ? When you say "SAP Event Mesh is a standalone service but will be soon a capability of SAP Integration Suite" , does this mean we need to subscribe to SAP Integration Suite to avail SAP Event Mesh Standalone Service ? Also could you please elaborate on difference between Event Mesh Standalone , Advanced Event Mesh and SAP Event Broker for SAP cloud applications ?
2024 Mar 11 12:21 PM - edited 2024 Mar 11 12:23 PM
> Event-capability part of SAP Integration Suite
My wording in the response might not be the best. I apologise for that and I've fixed it. You can find some information regarding the event-capability part of SAP Integration Suite at https://roadmaps.sap.com
> Elaborate on the difference between the event offering
You can find more info here: https://community.sap.com/t5/application-development-blog-posts/cloudevents-at-sap/ba-p/13620137
2024 Mar 11 10:54 AM - edited 2024 Mar 11 10:55 AM
2024 Mar 11 1:50 PM - edited 2024 Mar 11 1:50 PM
Here is my week 1 submission.
{ "specversion": "1.0", "type": "com.nithesh.app.resource.created", "source": "/app/resources/2124587451", "id": "N214-5234-9856", "time": "2024-03-02T18:00:00Z", "datacontenttype": "application/json", "data": { "resourceId": "M93157232", "resourceName": "Nithesh Resource", "resourceType": "nithesh.com/resources" } }
2024 Mar 11 1:51 PM
{
"type": "sap.s4.beh.purchaseorder.v1.PurchaseOrder.Created.v1",
"datacontenttype": "application/json",
"specversion": "1.0",
"source": "https://s4.cloud/",
"subject": "OR1234567890",
"id": "QgEK7wzuHtqdhJwqCS+VOA==",
"time": "2024-03-11T12:31:05Z",
"data": {
"PurchaseOrder": "1234567890"
}
}
2024 Mar 11 2:06 PM
{
"type": "sap.s4.beh.centralrequestforquotation.v1.CentralRequestForQuotation.SuccssrDocCrted.v1",
"specversion": "1.0",
"source": "/default/sap.s4.beh/s4hc",
"id": "QgEK7wzuHtqdeJwqCS+VOA==",
"time": "2024-03-11T13:00:00Z",
"datacontenttype": "application/json",
"data": {
"CentralRequestForQuotation": "7500000012"
}
}
2024 Mar 11 7:27 PM
2024 Mar 12 10:23 AM
@MatLakaemper, there is no code block in the response but I can see that the payload in the screenshot is valid.
{
"type": "sap-business-One-fake",
"specversion": "1.0",
"source": "/default/sap.s4.beh/244572008",
"id": "63d6a150-c6a1-4c5b-bcc3-27d90c07941c",
"time": "2024-02-26T10:53:062",
"datacontenttype": "application/json",
"data": {
"BusinessPartner": "Rübennase",
"Theme": "Life of Brian"
}
}
2024 Mar 12 6:43 PM
{
"specversion": "1.0",
"type": "com.example.iot.power.consumption",
"source": "https://example.talmeida.com/devices",
"subject": "power-measurement",
"id": "bafa9642-563b-4ff5-b697-58d91a77b988",
"time": "2024-03-10 10:00:00",
"datacontenttype": "application/json",
"data": {
"id": "power-measurement-bafa9642-563b-4ff5-b697-58d91a77b988",
"description": "Power measurement",
"measure": "10",
"unit": "Wh"
}
}
My submission. Thanks in advance!
2024 Mar 13 3:00 PM
My submission. Thanks!
2024 Mar 14 6:12 AM - edited 2024 Mar 14 6:12 AM
ICYMI... Week 2 challenge is now available! https://community.sap.com/t5/application-development-discussions/march-developer-challenge-cloudeven.... In Week 2, we expand on what we learnt in week 1 and we will create our first CloudEvent programmatically.
2024 Mar 15 3:29 AM
Interesting challenge, I hope I'm not too late.
{
"id": "1fc7fc18-0a82-4f92-a18c-877d336b9be0",
"source": "https://cloud.dagoca.com/events/spec/pull",
"specversion": "1.0",
"type": "com.sap.build.app.Launched.v1",
"datacontenttype": "application/json",
"subject": "create users",
"time": "2024-03-06T14:10:00",
"data": {
"users": [
{
"name": "David",
"lastName": "González",
"password": "MTIzNA==",
"country": "CL"
}
]
}
}
2024 Mar 15 11:28 AM
Not at all... the challenge is "active" the entire month of March. Now go ahead and check out the challenge for week 2 🙂