How-To Guides
Flows Guides
Use Access to Write to a Topic
2min
You can use an Access Publish node to write to a topic through the local message broker by using flows. This guide uses the string message Hi to write to a topic.
- Make sure you create an Access API account. See Create an API Account and Manage API Accounts for more information.
- Make sure you have created a flow to read from a topic. See Use Access to Read from a Topic for more information.
To write a topic using Access:
- In Litmus Edge, navigate to the Flows Manager and create a new flow. See Create a Flow to learn more.
Drag the Access Publish and Inject nodes to the canvas and wire them together.
- In Litmus Edge, navigate to System > Tokens.
Click the Action menu for the API account you created previously and select Edit topics.
- From the Edit topics dialog box, do the following:
- Enter test-topic in the Write Topics field, and click Add Write Topic. The topic name appears below the Topic Name field. Make sure that there are no spaces in the topic name.
- Enter the same topic name(test-topic) in the Read Topics field, and click Add Read Topic. The topic name appears below the Topic Name field. Make sure that there are no spaces in the topic name.
Click Update.
- Return to the Flows browser tab and double-click the Access Publish node. The Edit Access Publish node dialog box appears.
- Topic Name: Paste the topic name test-topic you added in the Access Topic Name field.
Click the Edit icon next to the Access field.
- Return to the System > Tokens browser tab and do the following:
- Click the Action menu for the API account you created previously and select View API Key.
Click the Copy icon next to the API Key.
- Return to the Edit Access Connect node dialog box in the Flows browser tab and do the following:
- API Key: Paste the API key you copied.
Click Add or Update.
Click Done.
- Double-click the Inject node. The Edit inject node dialog box appears.
- msg.payload: Select the String option from the drop-down list and enter Hi message in the Payload field.
- msg.topic: Enter the name of the write topic (test-topic) you added in the Access Write Topic field.
- Repeat: Select interval from the drop-down list.
- every: Enter a value for how often to add a message.
Click Done.
Drag an Access Subscribe node to the canvas and wire it to the Debug node.
- Double-click the Access Subscribe node. The Edit access-subscribe node dialog box appears.
- Topic Name: Enter the name of the write topic you added in the Access Write Topic field.
- Access: From the drop-down list, select the Access Connect you defined in the Access-Publish node.
Click Done.
- Click Deploy.
Expand the message window beneath the flow and click the Debug icon.
Click the Debug node button to view the output in the Debug message window.