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.

Before you Begin

To write a topic using Access:

  1. In Litmus Edge, navigate to the Flows Manager and create a new flow. See Create a Flow to learn more.
  2. Drag the Access Publish and Inject nodes to the canvas and wire them together.

    Access Publish node
    Access Publish node
    
  3. In Litmus Edge, navigate to System > Tokens.
  4. Click the Action menu for the API account you created previously and select Edit topics.

    System Tokens page
    System Tokens page
    
  5. 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.

      Edit topics dialog box
      Edit topics dialog box
      
  6. 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.

      Edit Access Publish node dialog box
      Edit Access Publish node dialog box
      
  7. 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.

      Access accounts table
      Access accounts table
      
  8. 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.

      Edit Access Connect node dialog box
      Edit Access Connect node dialog box
      
  9. Click Done.

    Edit access-publish node dialog box
    Edit access-publish node dialog box
    
  10. 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.

      Edit inject node dialog box
      Edit inject node dialog box
      
  11. Drag an Access Subscribe node to the canvas and wire it to the Debug node.

    Completed flows canvas
    Completed flows canvas
    
  12. 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.

      Edit access-subscribe node dialog box
      Edit access-subscribe node dialog box
      
  13. Click Deploy.
  14. Expand the message window beneath the flow and click the Debug icon.

    Flows canvas debug section
    Flows canvas debug section
    
  15. Click the Debug node button to view the output in the Debug message window.

    View the flow output
    View the flow output