{"revision":"c10276e953456835cdbb1f3a60d58ae1980be353","document":{"id":4057,"path":"build-workflows/workflow-studio/create-flow-kafka.md","title":"Create a flow with a Kafka Message trigger","bundle":null,"doc_type":null,"release":"australia","body":"\n# Create a flow with a Kafka Message trigger\n\nBuild a flow that processes events from a Kafka stream. Start the flow when an event is available in the specified topic.\n\n## Before you begin\n\nRole required: flow\\_designer or admin\n\nThis trigger requires a Stream Connect subscription. For more information, see [https://www.servicenow.com/now-platform/workflow-data-fabric.html](https://www.servicenow.com/now-platform/workflow-data-fabric.html).\n\nThis trigger requires the ServiceNow Stream Connect Installer \\[com.glide.hub.stream\\_connect.installer\\] plugin.\n\n## Procedure\n\n1.  Navigate to **All** &gt; **Process Automation** &gt; **Flow Designer**.\n\n2.  Click **New** &gt; **Flow**.\n\n3.  Define the flow properties.\n\n    For more information, see [Create a flow in Workflow Studio](https://raw.githubusercontent.com/ServiceNow/ServiceNowDocs/australia/markdown/australia/build-workflows/workflow-studio/create-flow.md).\n\n4.  In the Trigger section, click **Add a trigger** and select **Application** &gt; **Kafka Message**.\n\n5.  On the Kafka Message form, fill in the fields.\n\n<table id=\"table_ipn_5qw_frb\"><thead><tr><th>\n\nField\n\n</th><th>\n\nDescription\n\n</th></tr></thead><tbody><tr><td>\n\nTopic Alias\n\n</td><td>\n\nReference to the topic alias for the topic to monitor for messages.A topic alias is a unique topic name that can be connected to any underlying Hermes or Direct Kafka topic.\n\n</td></tr><tr><td>\n\nSerialization format\n\n</td><td>\n\nThe serialization format for the message. Select one of the following. -   **Plain Text**: Select this option for any plain-text messages. This is the default format.\n-   **Encoded**: Select this option for messages in an Apache Avro format. Converting plain-text messages to an Avro format requires a schema. Select the schema registry in the **Schema registry** field. For information on schemas, see [Schema management in Stream Connect](https://raw.githubusercontent.com/ServiceNow/ServiceNowDocs/australia/markdown/integrate-applications/schema-management.md).\n\n\n</td></tr><tr><td>\n\nSchema registry\n\n</td><td>\n\nRegistry for the selected schema. Select one of the following.\n\n-   **Standalone Schema Registry**\n-   **Confluent Schema Registry**\n This field appears only when the **Serialization format** is set to **Encoded**.\n\n For the Confluent Schema Registry, if the received message's schema ID isn't in the schema table, the system imports the schema dynamically, using the configured REST connection.\n\n</td></tr><tr><td class=\"sub-head\" colspan=\"2\">\n\nAdvanced Options\n\n</td></tr><tr><td>\n\nStart processing from\n\n</td><td>\n\nOption to begin processing messages from the beginning or end of the queue, organized by date. Select one of the following. -   **The earliest message in the queue**: Begin processing from the oldest messages in the queue.\n-   **The end of the queue**: Begin processing from the newest messages in the queue.\n\n\n</td></tr><tr><td>\n\nNumber of messages to process per run\n\n</td><td>\n\nOption to specify the number of messages processed per run or let the system decide on the number of messages. Select one of the following. -   **Automatically optimize**: The system determines the number of messages to process per run.\n-   **Manually override \\(advanced\\)**: You specify the number of messages to process per run.\n\n\n</td></tr><tr><td>\n\nEnter the number of messages \\(ignored if system-generated value is lower\\)\n\n</td><td>\n\nNumber of messages to process each run. This field appears only when **Number of messages to process per run** is set to **Manually override \\(advanced\\)**. -   Type: integer\n-   Default value: 100\n-   Minimum value: 1\n-   Maximum value: 100,000\n If the selected number is greater than the number calculated by the system, the flow runs with the system-calculated number.\n\n Depending on the size of the messages, the number of messages processed per run might be lower than the number specified.\n\n</td></tr></tbody>\n</table>6.  Click **Done**.\n\n7.  Set the **Max concurrency** and **Relative weight** fields.\n\n    The **Max concurrency** field determines the number of partition groups to create and the number of parallel processors to use. The **Relative weight** field enables you to allocate more processing time to the consumer relative to other consumers.\n\n    1.  Navigate to **All** &gt; **Process Automation** &gt; **Flow Administration** &gt; **Settings**.\n\n    2.  In the **Flow/SubFlow/Action** field, select the info icon \\(\\[Omitted image \"info-icon.png\"\\] Alt text: info icon\\) for the flow, then select **Open Record**.\n\n    3.  Select the Additional actions icon \\(\\[Omitted image \"context-menu-icon.png\"\\] Alt text: additional actions icon\\) and select **View** &gt; **Kafka**.\n\n        The **Max concurrency** field appears on the form.\n\n    4.  To view the **Relative weight** field, select **Advanced**.\n\n    5.  Set the values for **Max concurrency** and **Relative weight**.\n\n<table id=\"table_bly_1lh_2xb\"><thead><tr><th>\n\nField\n\n</th><th>\n\nDescription\n\n</th></tr></thead><tbody><tr><td>\n\nMax concurrency\n\n</td><td>\n\nMaximum number of parallel processors to use to consume messages, and the number of partition groups to create.\n\n Default value: 1\n\n</td></tr><tr><td>\n\nRelative weight\n\n</td><td>\n\nFor each cycle, the maximum amount of time allocated to the consumer for processing messages, relative to other consumers. For example, a consumer with a relative weight that's twice as high as another consumer's gets twice as much time. Consumers that have the same relative weight get the same amount of time.\n\nThe minimum value is 5. The maximum value is 2000. The default value is equal to the max concurrency multiplied by the value of the **glide.ih.kafka.consumer.max\\_seconds\\_per\\_partition\\_group** property. The **glide.ih.kafka.consumer.max\\_seconds\\_per\\_partition\\_group** property specifies the maximum time, in seconds, allocated to each partition group. Its default value is 10.\n\nThe system uses the relative weight to calculate the partition group timeout for the subscription. The partition group timeout specifies the maximum time, in milliseconds, allocated to each partition group in a specific subscription.\n\nThis field appears only when **Advanced** is selected.\n\n</td></tr></tbody>\n</table>    6.  Select **Update**.\n\n    7.  Navigate back to your flow in Workflow Studio.\n\n8.  Add actions, subflows, and flow logic to the flow.\n\n9.  To test the flow, click the **Test** button.\n\n    The **Test** button opens the Test flow dialog, where you can create a message to send to the flow. The system tests the flow with this newly created message, not with messages from the Kafka topic. The flow doesn't start receiving messages from the topic until the flow is activated. For more information, see [Test a flow](https://raw.githubusercontent.com/ServiceNow/ServiceNowDocs/australia/markdown/australia/build-workflows/workflow-studio/flow-test.md).\n\n10. To activate the flow, click the **Activate** button.\n\n    When you activate the flow, the system begins looking for messages in the topic. You must activate the flow to receive messages. For more information, see [Activate a flow](https://raw.githubusercontent.com/ServiceNow/ServiceNowDocs/australia/markdown/australia/build-workflows/workflow-studio/flow-activate.md).\n\n\n## Result\n\nWhen there's a message in the Kafka topic, the flow triggers and runs the actions.\n\n**Parent Topic:**[Create a flow in Workflow Studio](https://raw.githubusercontent.com/ServiceNow/ServiceNowDocs/australia/markdown/australia/build-workflows/workflow-studio/create-flow.md)\n\n"}}