<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>CloudEvents Archives - Blog IT</title>
	<atom:link href="https://blogit.create.pt/tag/cloudevents/feed/" rel="self" type="application/rss+xml" />
	<link>https://blogit.create.pt/tag/cloudevents/</link>
	<description>Create IT blogger community</description>
	<lastBuildDate>Thu, 16 Sep 2021 18:10:26 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	<generator>https://wordpress.org/?v=6.9.1</generator>
	<item>
		<title>Getting Started with CloudEvents and AsyncAPI</title>
		<link>https://blogit.create.pt/davidpereira/2021/09/16/getting-started-with-cloudevents-and-asyncapi/</link>
					<comments>https://blogit.create.pt/davidpereira/2021/09/16/getting-started-with-cloudevents-and-asyncapi/#respond</comments>
		
		<dc:creator><![CDATA[David Pereira]]></dc:creator>
		<pubDate>Thu, 16 Sep 2021 12:26:26 +0000</pubDate>
				<category><![CDATA[Architecture]]></category>
		<category><![CDATA[AsyncAPI]]></category>
		<category><![CDATA[CloudEvents]]></category>
		<category><![CDATA[EDA]]></category>
		<category><![CDATA[event-driven architecture]]></category>
		<guid isPermaLink="false">https://blogit.create.pt/?p=12557</guid>

					<description><![CDATA[<p>In the previous blog post we went over a case study for Azure Service Bus. In this article we&#8217;ll look at two specs, CloudEvents and AsyncAPI, that you can use to solve some problems of your event-driven architectures. Introduction At the moment, there are quite a few tools and products that have adopted CloudEvents or [&#8230;]</p>
<p>The post <a href="https://blogit.create.pt/davidpereira/2021/09/16/getting-started-with-cloudevents-and-asyncapi/">Getting Started with CloudEvents and AsyncAPI</a> appeared first on <a href="https://blogit.create.pt">Blog IT</a>.</p>
]]></description>
										<content:encoded><![CDATA[
<p>In the previous blog post we went over a <a href="https://blogit.create.pt/davidpereira/2021/06/02/case-study-azure-service-bus-and-event-driven-architectures/" target="_blank" rel="noreferrer noopener">case study for Azure Service Bus</a>. In this article we&#8217;ll look at two specs, CloudEvents and AsyncAPI, that you can use to solve some problems of your event-driven architectures.</p>



<h2 class="wp-block-heading">Introduction</h2>



<p>At the moment, there are quite a few tools and products that have adopted CloudEvents or AsyncAPI. <a href="https://knative.dev/docs/eventing/accessing-traces/#" target="_blank" rel="noreferrer noopener">Knative Eventing</a> is a tool that helps developers in a serverless context, Azure Event Grid <a href="https://docs.microsoft.com/en-us/azure/event-grid/cloud-event-schema" target="_blank" rel="noreferrer noopener">natively supports CloudEvents</a>. More recently, Jenkins added <a href="https://cd.foundation/blog/2021/09/02/jenkins-interoperability-with-cloudevents" target="_blank" rel="noreferrer noopener">integration with CloudEvents</a> with a new plugin. It allows users to configure Jenkins as a source and a sink for CloudEvents. There is also interesting integrations between Kubernetes and Azure Event Grid that are compliant with the CloudEvents v1.0 spec. Checkout the <a href="https://github.com/tomkerkhove/k8s-event-grid-bridge" target="_blank" rel="noreferrer noopener">GitHub repository</a> or this <a href="https://blog.tomkerkhove.be/2021/01/19/introducing-kubernetes-event-grid-bridge/" target="_blank" rel="noreferrer noopener">blog post</a> and learn more about it.</p>



<p>Postman has <a href="https://blog.postman.com/asyncapi-joins-forces-with-postman-future-of-apis/" target="_blank" rel="noreferrer noopener">joined forces with AsyncAPI</a> along with organizations such as Salesforce, Slack and Solace. Postman in particular is publishing <a href="https://www.postman.com/postman/workspace/postman-open-technologies-asyncapi/example/12959542-7624bf1e-2e63-4e1f-a573-45598722af74" target="_blank" rel="noreferrer noopener">public collections</a> related to AsyncAPI. For example a list of companies adopting AsyncAPI, with links to those resources (GitHub repositories, websites, etc).</p>



<p style="margin-bottom:40px">I hope these projects have got you excited to learn more about these specs. Let&#8217;s dive into some of their details!</p>



<h2 class="wp-block-heading">CloudEvents</h2>



<p>The CloudEvents specification is under the <a href="https://github.com/cncf/wg-serverless" target="_blank" rel="noreferrer noopener">CNCF Serverless working group</a> since 2018. The spec&#8217;s purpose is describing event data in a common way. This is useful in many scenarios, for example, routing events to the appropriate subscribers depending on the&nbsp;<em>type</em>&nbsp;of the event. Since applications can use a lot of different transports to send and receive events, the CloudEvents spec is protocol-agnostic so it defines&nbsp;<strong>protocol bindings</strong>&nbsp;in order for the metadata to be correctly mapped for HTTP, AMQP, Kafka, etc.</p>



<p>There are many use cases in using the CloudEvents spec, but perhaps the main one would be&nbsp;<strong>interoperability</strong>. Imagine applications across clouds, being able to communicate in an event-driven architecture. Where there are producers of all sources, and consumers using all kinds of protocols (e.g. HTTP, AMQP, WebSockets). We can have middleware that connects these applications, adds E2E tracing and more with the use of CloudEvents. Of course we could connect the same applications without a common format, but it requires mapping between event formats (cloud providers use different schemas). Middleware would also need to parse the event data to get specific information.</p>



<p style="margin-bottom:30px">Another use case is SaaS (Software-as-a-service) that publishes events that clients are interested in to integrate with their own systems. For example, hooking into the checkout flow in a Shopify storefront to add extra checks. By leveraging CloudEvents these events can be&nbsp;<strong>consistent</strong>, opening the door for numerous integrations between 3rd party software.</p>



<h3 class="wp-block-heading">Extensions</h3>



<p style="margin-bottom:30px">There are a few extensions worth mentioning, one of them is for&nbsp;<a href="https://github.com/cloudevents/spec/blob/v1.0/extensions/distributed-tracing.md" target="_blank" rel="noreferrer noopener">distributed tracing</a>. However, it seems there is some discussion around removing this extension from the spec (check this&nbsp;<a href="https://github.com/cloudevents/spec/pull/751" target="_blank" rel="noreferrer noopener">PR on GitHub</a>). There are open issues on some SDKs to support it, and others have already made changes to remove it. The future isn&#8217;t clear, but I&#8217;d argue it&#8217;s interesting to follow this closely for any updates, since tracing events is very important in an event-driven architecture.</p>



<p style="margin-bottom:30px">The <a href="https://github.com/cloudevents/spec/blob/v1.0.1/extensions/partitioning.md" target="_blank" rel="noreferrer noopener">Partioning extension</a> is another interesting extension,&nbsp;it defines a field to be handled by message brokers that can separate load via a partition key. This is used for example in the Kafka protocol binding that requires implementations to map the  <code>partitionKey</code> attribute to the&nbsp;<code>key</code>&nbsp;of the Kafka message. In Kafka the concept of a partition is well known, so this maps out really well.</p>



<h3 class="wp-block-heading">Relation with Serverless computing</h3>



<p style="margin-bottom:40px">Serverless computing has increased in popularity and use in the industry, especially for it&#8217;s cost model. But many FaaS (Functions-as-a-service) providers have their own function interface. Which means developers can&#8217;t write a function in JavaScript, and deploy them in two cloud providers without making changes. This specification improves <strong>portability </strong>between FaaS platforms, so that developers receive an event in the same format and can reuse libraries for handling the event.</p>



<h2 class="wp-block-heading">AsyncAPI</h2>



<p>I’ll start with a description of what AsyncAPI is: <strong>a specification that describes and documents event-driven APIs in a machine-readable format</strong>. It&#8217;s protocol-agnostic like CloudEvents, so it can be used for APIs that work over many protocols, including MQTT, WebSockets, and Kafka.</p>



<p>The following is AsyncAPI&#8217;s vision stated on their&nbsp;<a href="https://www.asyncapi.com/roadmap" target="_blank" rel="noreferrer noopener">website</a>:</p>



<div class="wp-block-image"><figure class="aligncenter size-full is-resized"><img fetchpriority="high" decoding="async" src="https://blogit.create.pt/wp-content/uploads/2021/09/133161353-a0a65fde-d3fc-4984-9ba7-6eb855bd9590.png" alt="asyncapi description - AsyncAPI becomes the #1 API specification for defining and developing APIs. Any kind of APIs." class="wp-image-12559" width="969" height="674" srcset="https://blogit.create.pt/wp-content/uploads/2021/09/133161353-a0a65fde-d3fc-4984-9ba7-6eb855bd9590.png 886w, https://blogit.create.pt/wp-content/uploads/2021/09/133161353-a0a65fde-d3fc-4984-9ba7-6eb855bd9590-300x209.png 300w, https://blogit.create.pt/wp-content/uploads/2021/09/133161353-a0a65fde-d3fc-4984-9ba7-6eb855bd9590-768x534.png 768w, https://blogit.create.pt/wp-content/uploads/2021/09/133161353-a0a65fde-d3fc-4984-9ba7-6eb855bd9590-696x484.png 696w, https://blogit.create.pt/wp-content/uploads/2021/09/133161353-a0a65fde-d3fc-4984-9ba7-6eb855bd9590-604x420.png 604w, https://blogit.create.pt/wp-content/uploads/2021/09/133161353-a0a65fde-d3fc-4984-9ba7-6eb855bd9590-100x70.png 100w" sizes="(max-width: 969px) 100vw, 969px" /><figcaption>Photo taken from AsyncAPI website&#8217;s roadmap</figcaption></figure></div>



<p>I find this vision to be very interesting, mainly because of the part:&nbsp;<strong>Any kind of APIs</strong>. At first, you might wonder if this means the AsyncAPI spec will define rules and more concepts for other types of APIs like GraphQL or OpenAPI. But this is not at all the case, the goal is to&nbsp;<strong>integrate with existing tools and specs</strong>! This is valuable for developers because usually enterprise architectures consist of a mix of technologies, each for it&#8217;s appropriate use case. Developers nowadays don&#8217;t just interact with RESTful APIs in a request/response model. There are different demands and considerations for the ever increasing devices users can use, the software we build needs to match these demands and still maintain manageable. Where we can evolve and create new applications that leverage the numerous APIs that exist internally or from a 3rd party.</p>



<h3 class="wp-block-heading">Concepts</h3>



<p>The spec version 2.1.0 defines a few concepts apart from the common Producer, Consumer and Message. A&nbsp;<strong>Channel</strong>&nbsp;can be seen as a topic/exchange or queue, an application can send messages to a channel and consumers can subscribe to it to receive them. The&nbsp;<strong>Operation</strong>&nbsp;object indicates if it&#8217;s a publish or a subscribe operation and how an application can send or receive messages. A&nbsp;<strong>Binding</strong>&nbsp;(or &#8220;protocol binding&#8221;) is a mechanism to define protocol-specific information or query parameters for the channel bindings. For example, for the AMQP protocol we can specify the channel is an exclusive queue like this:</p>


<div class="wp-block-syntaxhighlighter-code "><pre class="brush: jscript; title: ; notranslate">
&quot;bindings&quot;: {
    &quot;amqp&quot;: {
      &quot;is&quot;: &quot;queue&quot;,
      &quot;queue&quot;: {
        &quot;exclusive&quot;: true
      }
    }
}
</pre></div>


<p style="margin-bottom:30px">Each protocol has it&#8217;s own JSON schema and we can have bindings for Messages, Servers, Channels, Operations and others.</p>



<h3 class="wp-block-heading">Components</h3>



<p>You can define&nbsp;<strong>components</strong>&nbsp;to re-use in multiple AsyncAPI documents and we can&nbsp;<strong>reference</strong>&nbsp;other AsncAPI documents. Let&#8217;s say you have two publishers who publish the same message, but with different values in one of the message properties. We&#8217;d have two AsyncAPI documents specifying the publishers, referencing a 3rd document specifying the common message with it&#8217;s properties. The&nbsp;<code>$ref</code>&nbsp;field is a string that can be the path to the other file, or a URL for an external file where the schema we want is defined. This reference object uses the same rules and format of JSON Reference, which opens the door for many possibilites (<a href="https://www.asyncapi.com/docs/specifications/v2.1.0#referenceObject" target="_blank" rel="noreferrer noopener">check the docs</a>&nbsp;to know more).</p>



<p style="margin-bottom:30px">When we start to have a lot of apps that depend on each other&#8217;s schemas, we can take a look at some solutions to scale out AsyncAPI documents. Perhaps we use&nbsp;<a href="https://docs.confluent.io/platform/current/schema-registry/index.html">Confluent&#8217;s Sche</a><a href="https://docs.confluent.io/platform/current/schema-registry/index.html" target="_blank" rel="noreferrer noopener">ma Registry</a>&nbsp;for our JSON schemas and setup a&nbsp;<strong>catalog of events</strong>&nbsp;in our organization. This empowers new developers seeking for ways to integrate with existing systems and event producers. We can also just store these components in a GitHub repository, and reference them in our AsyncAPI documents.</p>



<h3 class="wp-block-heading">Tooling</h3>



<p style="margin-bottom:30px">There is already quite a few tools and the&nbsp;<a href="https://www.asyncapi.com/docs/community/tooling" target="_blank" rel="noreferrer noopener">tooling ecosystem</a>&nbsp;is increasing! I&#8217;ve recently seen a&nbsp;<a href="https://github.com/fmvilas/asyncapi-to-postman" target="_blank" rel="noreferrer noopener">repository</a>&nbsp;that enables the creation of Postman collections from an AsyncAPI spec. I&#8217;ve also seen&nbsp;<a href="https://github.com/asyncapi/cupid" target="_blank" rel="noreferrer noopener">architecture documents being generated</a>&nbsp;from multiple AsyncAPI specs too, having a tool that can understand relations between applications and then output a diagram is pretty cool.</p>



<h3 class="wp-block-heading">Generators for AsyncAPI</h3>



<p>One piece of tooling that is often used are generators that produce documentation and code. For example gRPC tools have this capability using the protocol buffer compiler. AsyncAPI generators can take an AsyncAPI document and generate client/server code or documentation in HTML and markdown. Currently, it depends on the template we use to generate server-side code, for example the&nbsp;<a href="https://github.com/asyncapi/nodejs-ws-template" target="_blank" rel="noreferrer noopener">Node.js WebSocket template</a>&nbsp;generates both server and client code. This can be improved and extended overtime, especially because of the way the&nbsp;<a href="https://github.com/asyncapi/generator" target="_blank" rel="noreferrer noopener">generator</a>&nbsp;is designed, enabling&nbsp;<strong>extensibility</strong>&nbsp;so we can have templates for many other languages that support more protocols, etc. For example, there is only a&nbsp;<a href="https://github.com/asyncapi/dotnet-nats-template" target="_blank" rel="noreferrer noopener">NATS generator for .NET Core</a>&#8230; but perhaps in the future there could be more protocols supported for .NET Core and examples built for Azure&nbsp;😃.</p>



<h2 class="wp-block-heading">Conclusion</h2>



<p>There is a lot of exciting stuff happening in the event-driven architectures world&nbsp;😄. We have only touched the surface in this post. In the CloudEvents space there are new specs being designed and worked on: Discovery; Subscription and Schema Registry APIs. Since AsyncAPI defines a document that you can use to describe your API, it&#8217;d be interesting to see how these correlate to each other, and using them together. </p>



<p>I encourage you to join these communities and contribute to their open source projects, CloudEvents&nbsp;and&nbsp;AsyncAPI, both specs are very community-driven. Collaboration between everyone is the way forward, with  <a href="https://hacktoberfest.digitalocean.com/" target="_blank" rel="noreferrer noopener">Hacktoberfest</a> and <a href="https://www.asyncapi.com/blog/events2021" target="_blank" rel="noreferrer noopener">AsyncAPI&#8217;s Hackathon</a>&nbsp;coming up, searching good first issues is a great way to start and to contribute&nbsp;👍!</p>



<p>Let us know in the comments if you&#8217;re using these specs and what are your thoughts on them. The next blog post will be about a practical example for .NET Core, Azure and AMQP messaging using CloudEvents and AsyncAPI, so stay tuned!</p>



<p></p>



<h2 class="wp-block-heading">Additional Links</h2>



<p>Here are some links to talks, docs and blog posts that you may find useful if you&#8217;re interested to know more about CloudEvents and AsyncAPI:</p>



<ul class="wp-block-list" style="max-width:1015px"><li><a href="https://www.youtube.com/watch?v=TZPPjAv12KU" target="_blank" rel="noreferrer noopener">The Serverless and Event-Driven Future &#8211; Austen Collins, Serverless (Intermediate Skill Level)</a></li><li><a href="https://docs.openfaas.com/reference/triggers/#cloudevents" target="_blank" rel="noreferrer noopener">OpenFaaS supports CloudEvents</a></li><li><a href="https://www.postman.com/postman-galaxy/the-future-of-api-specifications/" target="_blank" rel="noreferrer noopener">The Future of API Specifications talk by Fran Méndez</a></li><li><a href="https://tech.ebayinc.com/engineering/asyncapi-2-0-enabling-the-event-driven-world/" target="_blank" rel="noreferrer noopener">AsyncAPI 2.0: Enabling the Event-Driven World</a></li></ul>
<p>The post <a href="https://blogit.create.pt/davidpereira/2021/09/16/getting-started-with-cloudevents-and-asyncapi/">Getting Started with CloudEvents and AsyncAPI</a> appeared first on <a href="https://blogit.create.pt">Blog IT</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://blogit.create.pt/davidpereira/2021/09/16/getting-started-with-cloudevents-and-asyncapi/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
	</channel>
</rss>
