From f0934a46524370de18085cd9fe098960fcf49355 Mon Sep 17 00:00:00 2001 From: Quetzalli Date: Mon, 20 May 2024 19:51:20 -0700 Subject: [PATCH 1/2] update hello world tutorials for send and receive --- ...orld.md => hello-world-receive-message.md} | 4 +- .../hello-world-send-message.md | 120 ++++++++++++++++++ 2 files changed, 122 insertions(+), 2 deletions(-) rename pages/docs/tutorials/getting-started/{hello-world.md => hello-world-receive-message.md} (98%) create mode 100644 pages/docs/tutorials/getting-started/hello-world-send-message.md diff --git a/pages/docs/tutorials/getting-started/hello-world.md b/pages/docs/tutorials/getting-started/hello-world-receive-message.md similarity index 98% rename from pages/docs/tutorials/getting-started/hello-world.md rename to pages/docs/tutorials/getting-started/hello-world-receive-message.md index 654c809011fd..c91398315291 100644 --- a/pages/docs/tutorials/getting-started/hello-world.md +++ b/pages/docs/tutorials/getting-started/hello-world-receive-message.md @@ -1,6 +1,6 @@ --- -title: "Hello world" -weight: 30 +title: "Receive 'Hello world' message" +weight: 35 --- Let's define an application that's capable of receiving a `"hello {name}"` message: diff --git a/pages/docs/tutorials/getting-started/hello-world-send-message.md b/pages/docs/tutorials/getting-started/hello-world-send-message.md new file mode 100644 index 000000000000..6f17827f24ef --- /dev/null +++ b/pages/docs/tutorials/getting-started/hello-world-send-message.md @@ -0,0 +1,120 @@ +--- +title: "Send 'Hello world' message" +weight: 30 +--- + +Let's define an application that's capable of sending a `"hello {name}"` message: + + +{`asyncapi: 3.0.0 +info: + title: Hello world application + version: '0.1.0' +channels: + hello: + address: 'hello' + messages: + sayHelloMessage: + payload: + type: string + pattern: '^hello .+$' +operations: + sendHello: + action: 'send' + channel: + $ref: '#/channels/hello'`} + + +Let's get into the details of this sample AsyncAPI document: + + +{`asyncapi: 3.0.0 +info: + title: Hello world application + version: '0.1.0' +channels: + hello: + address: 'hello' + messages: + sayHelloMessage: + payload: + type: string + pattern: '^hello .+$' +operations: + sendHello: + action: 'send' + channel: + $ref: '#/channels/hello'`} + + +The first line of the specification starts with the document type `asyncapi` and the version (3.0.0). That line doesn't have to be the first one, but it's a best practice. + + +{`asyncapi: 3.0.0 +info: + title: Hello world application + version: '0.1.0' +channels: + hello: + address: 'hello' + messages: + sayHelloMessage: + payload: + type: string + pattern: '^hello .+$' +operations: + sendHello: + action: 'send' + channel: + $ref: '#/channels/hello'`} + + +The `info` object contains the minimum required information about the application. It contains the `title`, which is a memorable name for the API, and the `version`. While it's not mandatory, it's strongly recommended to change the version whenever you make changes to the API. + + +{`asyncapi: 3.0.0 +info: + title: Hello world application + version: '0.1.0' +channels: + hello: + address: 'hello' + messages: + sayHelloMessage: + payload: + type: string + pattern: '^hello .+$' +operations: + sendHello: + action: 'send' + channel: + $ref: '#/channels/hello'`} + + +The `channels` section of the specification houses all of the mediums where messages flow through. For example, some systems use `topic`, `event name` or `routing key`. Different kinds of information flow through each channel similar to the analogy of TV channels. + +You only have one channel called `hello`, and you see what message is available in this channel and how it must be structured. The `payload` object defines that the message must be a string and match the given regular expression in a string format such as `hello {name}`. + + +{`asyncapi: 3.0.0 +info: + title: Hello world application + version: '0.1.0' +channels: + hello: + address: 'hello' + messages: + sayHelloMessage: + payload: + type: string + pattern: '^hello .+$' +operations: + sendHello: + action: 'receive' + channel: + $ref: '#/channels/hello'`} + + +The `operations` section is where you describe what the application is doing. Each operation has a unique identifier for example, `sendHello`. + +In the above example, you see that the `Hello world application` is a producer sending the `sayHelloMessage` message from the `hello` channel. In other words, you can say that the `Hello world application` pubishes to the `hello` topic to `send` the `sayHelloMessage` message. That AsyncAPI document describes what the `Hello world application` is doing, not what others can do with it. From 53cec5c1885452b6a97368a6b72866acb291a5d7 Mon Sep 17 00:00:00 2001 From: Quetzalli Date: Mon, 20 May 2024 19:59:03 -0700 Subject: [PATCH 2/2] typo fix --- .../docs/tutorials/getting-started/hello-world-send-message.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pages/docs/tutorials/getting-started/hello-world-send-message.md b/pages/docs/tutorials/getting-started/hello-world-send-message.md index 6f17827f24ef..0a1d7878e594 100644 --- a/pages/docs/tutorials/getting-started/hello-world-send-message.md +++ b/pages/docs/tutorials/getting-started/hello-world-send-message.md @@ -117,4 +117,4 @@ operations: The `operations` section is where you describe what the application is doing. Each operation has a unique identifier for example, `sendHello`. -In the above example, you see that the `Hello world application` is a producer sending the `sayHelloMessage` message from the `hello` channel. In other words, you can say that the `Hello world application` pubishes to the `hello` topic to `send` the `sayHelloMessage` message. That AsyncAPI document describes what the `Hello world application` is doing, not what others can do with it. +In the above example, you see that the `Hello world application` is a producer sending the `sayHelloMessage` message from the `hello` channel. In other words, you can say that the `Hello world application` publishes the `hello` topic to `send` the `sayHelloMessage` message. That AsyncAPI document describes what the `Hello world application` is doing, not what others can do with it.