|
|
@ -55,15 +55,11 @@ func (b *MessageQueueBroker) PublishMessage(stream mq_pb.SeaweedMessaging_Publis |
|
|
|
var p topic.Partition |
|
|
|
if initMessage != nil { |
|
|
|
t, p = topic.FromPbTopic(initMessage.Topic), topic.FromPbPartition(initMessage.Partition) |
|
|
|
localTopicPartition = b.localTopicManager.GetTopicPartition(t, p) |
|
|
|
if localTopicPartition == nil { |
|
|
|
localTopicPartition, err = b.loadLocalTopicPartitionFromFiler(t, p) |
|
|
|
// if not created, return error
|
|
|
|
if err != nil { |
|
|
|
response.Error = fmt.Sprintf("topic %v partition %v not setup: %v", initMessage.Topic, initMessage.Partition, err) |
|
|
|
glog.Errorf("topic %v partition %v not setup: %v", initMessage.Topic, initMessage.Partition, err) |
|
|
|
return stream.Send(response) |
|
|
|
} |
|
|
|
localTopicPartition, err = b.loadLocalTopicPartition(t, p) |
|
|
|
if err != nil { |
|
|
|
response.Error = fmt.Sprintf("topic %v partition %v not setup: %v", initMessage.Topic, initMessage.Partition, err) |
|
|
|
glog.Errorf("topic %v partition %v not setup: %v", initMessage.Topic, initMessage.Partition, err) |
|
|
|
return stream.Send(response) |
|
|
|
} |
|
|
|
ackInterval = int(initMessage.AckInterval) |
|
|
|
stream.Send(response) |
|
|
@ -148,6 +144,14 @@ func (b *MessageQueueBroker) PublishMessage(stream mq_pb.SeaweedMessaging_Publis |
|
|
|
return nil |
|
|
|
} |
|
|
|
|
|
|
|
func (b *MessageQueueBroker) loadLocalTopicPartition(t topic.Topic, p topic.Partition) (localTopicPartition *topic.LocalPartition, err error) { |
|
|
|
localTopicPartition = b.localTopicManager.GetTopicPartition(t, p) |
|
|
|
if localTopicPartition == nil { |
|
|
|
localTopicPartition, err = b.loadLocalTopicPartitionFromFiler(t, p) |
|
|
|
} |
|
|
|
return localTopicPartition, err |
|
|
|
} |
|
|
|
|
|
|
|
func (b *MessageQueueBroker) loadLocalTopicPartitionFromFiler(t topic.Topic, p topic.Partition) (localTopicPartition *topic.LocalPartition, err error) { |
|
|
|
self := b.option.BrokerAddress() |
|
|
|
|
|
|
|