Table of contents
Book a Maia Demo
Enjoy the freedom to do more with Maia on your side.
Dark green abstract background with subtle gradient shapes and rounded corners.

How to start a pipeline run for every Kafka message on Amazon MSK

December 2, 2026
Streaming
4 mins
300 of 300
burst messages that started a run, none twice
Summarise with AI
Article details
AuthorBen Bajek, Principal Forward Deployed Engineer
Published / updated30 November 2026
CustomerInsurance, under 1,000 employees, United States
Platform and toolsAmazon MSK, AWS Lambda, and Snowflake; MSK pipeline trigger adapter
Reading time4 min

Starting one Maia pipeline run per Kafka message on Amazon MSK was solved by extending Maia's queue trigger adapter, an AWS Lambda function, to read MSK topics. In our load test, 300 messages sent in 2 seconds all started a pipeline run, with none lost and none started twice. The guide was published 11 days after approval.

Why couldn't Maia start a pipeline for each Kafka message?

A US insurance company moving off an older ETL tool had Amazon Managed Streaming for Apache Kafka (Amazon MSK) topics carrying a few thousand event messages a day. It needed a pipeline run as each one landed, not on a schedule. Maia's Kafka component reads topics in batches and isn't a streaming loader.

Maia's queue trigger adapter already started one run per message for Amazon SQS, Azure Service Bus, and Azure Queue Storage, but not for Kafka.

Why did it matter?

Without a Kafka trigger, the insurer's event pipelines couldn't run once per message. A lost or doubled message would mean a missing or repeated run.

What did we build?

  1. Added an MSK path to the adapter's AWS Lambda function, fed by one SASL/SCRAM-authenticated event source mapping per topic.
  2. Added topic routes that map each topic to a Maia project, environment, pipeline, and the variable that receives the message.
  3. Passed the raw message base64-encoded, with kafkaTopic, kafkaPartition, and kafkaOffset, so the pipeline can skip a message delivered twice.
  4. Added a failure topic on the same cluster for any message that can't start a run.
  5. Packaged the setup as a Terraform module.

We chose a trigger over ingestion because this customer needed a run per message.

Batch size defaults to 1, because Lambda redelivers a failed batch from its lowest failed offset. A message that can never succeed (malformed JSON, oversized, or unrouted without the expected envelope) is retried, then sent to the failure topic. One that might succeed later (a 429, a 5xx, or an authentication error) holds its partition while it's retried, so runs stay in offset order, and goes to the failure topic if retries run out.

What was the result?

MeasureBeforeAfterTimeframe
Burst of 300 messages in 2 secondsNot possible300 runs, 0 lost, 0 twice; median 8.0 s, 95th percentile 13.9 s16 November 2026
53 messages over 13.5 minutesNot possible53 runs, 0 lost, 0 twice; median 2.1 s, 95th percentile 32.1 s16 November 2026
Malformed message on a partition in useNot possibleTried 3 times, then failure topic; the valid message behind it ran onceOn our test cluster

We load tested on our own SCRAM-authenticated MSK test cluster (2 brokers, Kafka 3.9) with the build before topic routing, a print-only pipeline, 3 partitions per topic (we assumed the partition count), batch size 1, and 3 retries. Latency runs from the message being produced to the Maia public API accepting the run. Maia showed exactly 353 runs, each matching a logged run ID.

The steady phase's slow tail was 2 HTTP timeouts and 2 cold starts, each run once on retry. Topic routing, tested later against a real MSK cluster and Snowflake, loaded 5 of 5 sample payloads and skipped a replayed message.

When does this apply to you?

This applies to teams replacing a custom Kafka consumer or a cron job that polls a topic. The guide covers setup with the Terraform module and the 1.3.0-arm64 or later image. The adapter signs in with SASL/SCRAM, which we also added to the Kafka component in an earlier Field Note.

The adapter is the wrong choice when you need data in the warehouse within seconds: at our burst's 95th percentile, the trigger alone took 13.9 seconds. Each message is also a pipeline run that uses credits: 10,000 messages a day is 10,000 runs.

  • Partitions set concurrency: at most one Lambda invocation per partition.
  • Topic routes need 1.3.0 or later: 1.2.0 sends every routed record to the failure topic.
  • Payloads are capped at about 7,500 bytes, base64-encoded in a 10,000-character variable.
  • Alarms cover the failure topic. A run that starts and then fails isn't retried and raises no alarm.

Frequently Asked Questions

Can Maia start a pipeline when a message arrives on a Kafka topic?

Yes, on Amazon MSK: the MSK pipeline trigger adapter runs as an AWS Lambda function in your account and starts one pipeline run per message through the Maia public API.

Is this the same as streaming Kafka data into Snowflake?

No, the adapter triggers a pipeline and doesn't ingest the topic. For event data in your warehouse within seconds, use Snowflake's Kafka connector with Snowpipe Streaming.

What happens to a Kafka message that can't start a pipeline?

The Lambda event source mapping retries the message, then writes it with its original content to a failure topic on the same cluster. Later messages on that partition keep running.

Which Amazon MSK authentication does the adapter support?

SASL/SCRAM, with the credentials in AWS Secrets Manager. MSK IAM authentication isn't supported.

Last updated
December 2, 2026

Featuring

Ben Bajek
Principal Forward Deployed Engineer, Matillion
We go after the problems that stop customers from getting value from their data, and we solve them so they stay solved: in the product, in shared tooling, or as context Maia and our teams can build on. My favourite engagements are the ones where fixing it for one customer quietly unlocks it for the next ten.

Data management
made effortless

Enjoy the freedom to do more with Maia on your side.
Abstract dark teal geometric shapes background with diagonal lines and subtle gradients.