-
Notifications
You must be signed in to change notification settings - Fork 967
Closed
Description
Environment
- Server: dubbo java 3.2.9
- Client: dubbo go v3.1.0
- Protocol: dubbo
- Registry: Nacos 2.2.3
Issue description
使用nacos作为注册中心,java写的dubbo provider注册到nacos,go写的client调用provider,提示没有No provider available of the service xxxx,经过调试,发现可以通过接口信息查到应用信息,在通过应用的Revision获取应用的元数据时,获取不到,原因时java注册服务时,注册元数据的dataid和group,与dubbo go不一致。
java注册元数据:
@Override
public void publishAppMetadata(SubscriberMetadataIdentifier identifier, MetadataInfo metadataInfo) {
try {
if (metadataInfo.getContent() != null) {
configService.publishConfig(
identifier.getApplication(), identifier.getRevision(), metadataInfo.getContent());
}
} catch (NacosException e) {
throw new IllegalStateException(e.getMessage(), e);
}
}
public boolean publishConfig(String dataId, String group, String content) throws NacosException {
return configService.publishConfig(handleInnerSymbol(dataId), handleInnerSymbol(group), content);
}
go 获取应用元数据的方式
func (n *nacosMetadataReport) GetAppMetadata(metadataIdentifier *identifier.SubscriberMetadataIdentifier) (*common.MetadataInfo, error) {
data, err := n.getConfig(vo.ConfigParam{
DataId: metadataIdentifier.GetIdentifierKey(),
Group: metadataIdentifier.Group,
})
if err != nil {
return nil, err
}
var metadataInfo common.MetadataInfo
err = json.Unmarshal([]byte(data), &metadataInfo)
if err != nil {
return nil, err
}
return &metadataInfo, nil
}
func NewSubscriberMetadataIdentifier(application string, revision string) *SubscriberMetadataIdentifier {
return &SubscriberMetadataIdentifier{
Revision: revision,
BaseApplicationMetadataIdentifier: BaseApplicationMetadataIdentifier{
Application: application,
Group: constant.Dubbo,
},
}
}
// GetIdentifierKey returns string that format is service:Version:Group:Side:Revision
func (mdi *SubscriberMetadataIdentifier) GetIdentifierKey() string {
return mdi.BaseApplicationMetadataIdentifier.getIdentifierKey(mdi.Revision)
}
从代码可以看出,java推送应用元数据信息时,使用应用名称作为dataId,使用Revision作为group,而go在获取应用元数据时,使用
应用名称:Revision 作为dataid,使用常量 dubbo作为group,所以获取不到对应的应用元数据信息
Metadata
Metadata
Assignees
Labels
No labels