ing
This commit is contained in:
parent
a7922fda42
commit
fedd128649
|
@ -4,6 +4,8 @@ import (
|
|||
"fmt"
|
||||
"strings"
|
||||
"sync/atomic"
|
||||
|
||||
"github.com/segmentio/kafka-go"
|
||||
)
|
||||
|
||||
type ConsumerHandler interface {
|
||||
|
@ -17,6 +19,8 @@ type ConsumerHandler interface {
|
|||
OnStop(consumerCtx ConsumerCtx)
|
||||
Destroy(consumerCtx ConsumerCtx)
|
||||
|
||||
OnMessage(msg *kafka.Message)
|
||||
|
||||
Validate() error
|
||||
}
|
||||
|
||||
|
@ -47,6 +51,10 @@ func (ch *ConsumerHandlers) Destroy(consumerCtx ConsumerCtx) {
|
|||
|
||||
}
|
||||
|
||||
func (ch *ConsumerHandlers) OnMessage(msg *kafka.Message) {
|
||||
fmt.Printf("message at topic/partition/offset %v/%v/%v: %s = %s\n", msg.Topic, msg.Partition, msg.Offset, string(msg.Key), string(msg.Value))
|
||||
}
|
||||
|
||||
func (ch *ConsumerHandlers) GetName() string {
|
||||
return ch.Name
|
||||
}
|
||||
|
|
|
@ -140,7 +140,7 @@ func (c *Consumer) handleReceive(stopChan <-chan struct{}, doneChan chan<- error
|
|||
continue
|
||||
}
|
||||
|
||||
fmt.Printf("message at topic/partition/offset %v/%v/%v: %s = %s\n", m.Topic, m.Partition, m.Offset, string(m.Key), string(m.Value))
|
||||
c.ConsumerHandler.OnMessage(&m)
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user