Provides structures for batching th2-common's entities. Each batch is sent when its size is equal or exceed the size configured by BatchSizeBytes option or flush timeout is over configured by FlushMillis option
MqBatcher[MessageArguments] created by the batcher.NewMessageBatcher method allows to batch and send messages via MQ in th2 transport protocol
The Batcher configuration include the options
- Book (required) - th2 book name.
- Group (required) - th2 session group name.
- Protocol (optional) - default value for protocol. If it isn't specified and you don't specify
batcher.MessageArguments.Protocolpassed into theMqBatcher[MessageArguments].Sendmethod, messages will be send with empty protocol. - BatchSizeBytes (1048576 by default) - max batch size.
- FlushMillis (1000 by default) - max time interval in milliseconds between sending.
import (
"github.com/th2-net/th2-common-mq-batcher-go/pkg/batcher"
)
config := batcher.MqMessageBatcherConfig{
MqBatcherConfig: batcher.MqBatcherConfig{
BatchSizeBytes: 1048576,
FlushMillis: 1000,
Book: "book",
},
Protocol: "protocol",
Group: "group",
}