Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Making the Consul Instance ID Unique #4

Open
conanca opened this issue Mar 3, 2017 · 1 comment
Open

Making the Consul Instance ID Unique #4

conanca opened this issue Mar 3, 2017 · 1 comment

Comments

@conanca
Copy link

conanca commented Mar 3, 2017

默认的instanceId是${spring.application.name}-${server.port},则向consul注册服务时的serviceId是service:${spring.application.name}-${server.port}
当 service 部署多个实例在某些容器平台时(port往往一致),会导致serviceId重复而只能注册最后一个服务。

可以通过添加以下配置避免这个问题:

spring.cloud.consul.discovery.instanceId: ${spring.application.name}:${spring.application.instance_id:${random.value}}

@yidongnan
Copy link
Owner

@conanca 感谢。但这个示例中不影响。

docker-compose scale service-a=2 service-b=3  

启动多台 service-a 时,每个服务对应的 ip 是不一样的。
所以你说的问题在这示例中不存在。
这里使用 service:${spring.application.name}-${server.port} 方式只是看起来直观一点。
如有serviceId冲突的情况到是可以改成你写的那种。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants