Skip to content

Commit

Permalink
fix: clarify publish/subscribe in StreetLights (#455)
Browse files Browse the repository at this point in the history
* Clarify publish/subscribe

Streetlights was incorrect regarding publish/subscribe - and this will likely confuse new users

* Apply suggestions from code review

Co-authored-by: Lukasz Gornicki <lpgornicki@gmail.com>

Co-authored-by: Lukasz Gornicki <lpgornicki@gmail.com>
Co-authored-by: Alejandra Quetzalli <alejandra.quetzalli@postman.com>
  • Loading branch information
3 people authored Dec 1, 2021
1 parent 110e984 commit 168341c
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions pages/docs/tutorials/streetlights.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,10 @@ In this tutorial, you get started with actual code and a sample real-world use c
You want to create a system capable of turning on/off the streetlights depending on the environmental conditions of each of them:

- You're going to implement an event-driven architecture, with a Message Broker in its "center".
- Streetlights will send information about its environmental lighting to the broker.
- None of the services will wait for any kind of response. (Think about it as _fire and forget_.) You'll publish messages to the broker and that's it. Your service doesn't need to know who receives them.
- Streetlights will publish information about their environmental lighting to the broker.
- Your application will connect to the broker and receive a stream of events from all the streetlights that are reporting their conditions.
- Based off the events, your application can make a decision regarding turning the streetlight off.
- Your application is not aware of how many streetlights are publishing events - it just connects to the broker and receives all events

# Technology

Expand Down Expand Up @@ -88,7 +90,7 @@ Now lets move all the way to the `channels` section. This section is used to des
operationId: onLightMeasured`}
</CodeBlock>

In this example, `light/measured` is the channel name your API will `publish` to. The `operationId` property, describes what will be the name of function or method that takes care of this functionality in the generated code. The `payload` property is used to understand how the event should look like when publishing to that channel:
In this example, `light/measured` is the channel name the Streetlight API will `subscribe` to (i.e, to interact with the Streetlight API you `publish` to the broker). The `operationId` property, describes what is the name of function or method that takes care of this functionality in the generated code. The `payload` property is used to understand how the event should look like when publishing to that channel:

<CodeBlock>
{` payload:
Expand Down Expand Up @@ -197,17 +199,17 @@ EOT`}
{`npm install mqtt -g`}
</CodeBlock>

### 4. Send correct message to your application:
### 4. Send a correct message to your application:
<CodeBlock language="bash">
{`mqtt pub -t 'light/measured' -h 'test.mosquitto.org' -m '{"id": 1, "lumens": 3, "sentAt": "2017-06-07T12:34:32.000Z"}'`}
</CodeBlock>

### 5. Send incorrect message to your application:
### 5. Send an incorrect message to your application:
<CodeBlock language="bash">
{`mqtt pub -t 'light/measured' -h 'test.mosquitto.org' -m '{"id": 1, "lumens": "3", "sentAt": "2017-06-07T12:34:32.000Z"}'`}
</CodeBlock>

### 6. Go back to the previous terminal and check if your application logged the message you just sent, with errors related to the invalid message.
### 6. Go back to the previous terminal and check if your application logged the streetlight condition you just sent, with errors related to the invalid message.

# Conclusions

Expand Down

0 comments on commit 168341c

Please sign in to comment.