Can't query simple Redpanda topic? #9668
-
I am testing materialize and redpanda over docker and am running into some issues. When I try to query from Materialize, I get no rows, whether I produce records before or after creating the source, materialized view, etc. Setup:
And a simple go program writing some messages to a topic: package main
import (
"context"
"encoding/json"
"log"
"math/rand"
"time"
"github.com/segmentio/kafka-go"
)
var (
Writer *kafka.Writer
)
func main() {
rand.Seed(time.Now().UnixNano())
log.Println("Starting Materilize and Redpanda integration test")
topic := "my-topic"
Writer = &kafka.Writer{
Addr: kafka.TCP("localhost:9092"),
Topic: topic,
Balancer: &kafka.LeastBytes{},
BatchTimeout: time.Millisecond * 10,
}
for {
log.Println("Ticking...")
WriteRecord()
time.Sleep(2 * time.Second)
}
}
// Writes a random record to Redpanda
func WriteRecord() {
log.Println("Writing record")
var key string
val := map[string]interface{}{}
r := rand.Intn(2)
switch r == 0 {
case true:
// 1/3 chance
key = "low"
case false:
// 2/3 chance
key = "high"
}
val["num"] = r
// JSON
bytes, err := json.Marshal(&val)
if err != nil {
panic(err)
}
t := time.Now()
err = Writer.WriteMessages(context.Background(), kafka.Message{
Key: []byte(key),
Value: bytes,
})
if err != nil {
log.Fatal(err)
}
log.Println("Wrote message in", time.Since(t)-(time.Millisecond*10))
} I am then creating the following source and views such as:
When every I run |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 3 replies
-
This seems to have been a networking issue. If I use the following version: '3'
services:
redpanda:
image: docker.vectorized.io/vectorized/redpanda:v21.9.5
command:
- redpanda start
- --overprovisioned
- --smp 1
- --memory 1G
- --reserve-memory 0M
- --node-id 0
- --check=false
- --kafka-addr 0.0.0.0:9092
- --advertise-kafka-addr redpanda:9092
- --pandaproxy-addr 0.0.0.0:8082
- --advertise-pandaproxy-addr redpanda:8082
- --set redpanda.enable_transactions=true
- --set redpanda.enable_idempotence=true
ports:
- 9092:9092
- 8081:8081
- 8082:8082
materialized:
image: materialize/materialized:v0.12.0
init: true
command: --workers=1
ports:
- 6875:6875 |
Beta Was this translation helpful? Give feedback.
-
Hey, Dan! Using Docker Compose does make things easier networking-wise, so I'm glad you sorted that out! There are a couple of examples of end-to-end Materialize+Redpanda setups here and here, if it helps. Are you using |
Beta Was this translation helpful? Give feedback.
This seems to have been a networking issue. If I use the following
docker-compose.yml
and referenceredpanda:9092
it seems to work. Will wait for an official answer to confirm. Although now I can't write from my go instance due to the- --advertise-kafka-addr redpanda:9092
line (it creates the topic, but I get a write error still).