redis事件多分区消费
This commit is contained in:
parent
414ad47e72
commit
7fe6003db8
@ -152,10 +152,11 @@ func (r *RedisEventPubSub) ConsumeEvent(handler abstract.EventHandler, successCa
|
|||||||
if nil == successCallback {
|
if nil == successCallback {
|
||||||
successCallback = define.DefaultSuccessCallbackHandler
|
successCallback = define.DefaultSuccessCallbackHandler
|
||||||
}
|
}
|
||||||
go func() {
|
for partition := 0; partition < r.pubSubConfig.PartitionNum; partition++ {
|
||||||
|
go func(realPartition int) {
|
||||||
defer func() {
|
defer func() {
|
||||||
if panicErr := recover(); nil != panicErr {
|
if panicErr := recover(); nil != panicErr {
|
||||||
fmt.Println(r)
|
r.panicCallback(panicErr, nil, nil)
|
||||||
}
|
}
|
||||||
}()
|
}()
|
||||||
for !r.isStop || (r.isStop && len(messageChan) == 0) {
|
for !r.isStop || (r.isStop && len(messageChan) == 0) {
|
||||||
@ -165,14 +166,14 @@ func (r *RedisEventPubSub) ConsumeEvent(handler abstract.EventHandler, successCa
|
|||||||
if nil != handlerErr {
|
if nil != handlerErr {
|
||||||
// 失败回调
|
// 失败回调
|
||||||
failureCallback(eventData, handlerResult, handlerErr)
|
failureCallback(eventData, handlerResult, handlerErr)
|
||||||
break
|
|
||||||
} else {
|
} else {
|
||||||
// 成功回调
|
// 成功回调
|
||||||
successCallback(eventData, handlerResult)
|
successCallback(eventData, handlerResult)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}()
|
}(partition)
|
||||||
|
}
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user