• 周三. 2月 28th, 2024




(16) Integrating spring cloud cloud Architecture – refresh configuration with spring cloud bus


1月 3, 2022

We use spring cloud Distributed microservice Cloud Architecture has done b2b2c The e – commerce system , In addition to the system services provided by the architecture itself , We will b2b2c A fine-grained split of business services for , Different business microservices have been created .

As our business systems become larger and more complex , There will be more and more configurations . The configuration file only needs to be modified , Would be right commonservice-config Configuration center stops service first , Then restart , Finally, make the configuration work .

If there is little service , We can start it manually , But it certainly has an impact on business and system stability .

If it’s hundreds or thousands of services that are manually operated , I think the operation and maintenance personnel or technical personnel will go crazy .

For the above problems ,commonservice-config The server and business microservices are configured respectively , The server is responsible for git(svn Or local file system ) Configure the configuration file stored in ( We are using a local configuration scheme , It is convenient to update the configuration file directly to linux On ),

Business microservices obtain relevant configuration from the server configuration center through configuration , If the configuration file changes , By refreshing business microservices , Get the latest configuration information .

spring cloud Bus Connecting nodes in distributed systems through a lightweight message broker . This can be used to broadcast state changes ( If the configuration changes ) Or other management instructions .

Next , We’re going to implement it through spring cloud Bus programme , Dynamically refresh server configuration , The specific steps are as follows :

1. commonservice-config Please refer to the previous link for service configuration :

2. Business microservice configuration ( With honghu-member-servcie For example, membership services ):

pom File configuration :

1. <span style="font-size: 16px;"> <dependency>
2. <groupId>org.springframework.boot</groupId>
3. <artifactId><span style="font-size: 16px;">spring-boot-starter-actuator</span></artifactId>
4. </dependency>
6. <dependency>
7. <groupId>org.springframework.cloud</groupId>
8. <artifactId><span style="font-size: 16px;">spring-cloud-starter-bus-amqp</span></artifactId>
9. </dependency></span>

yml File configuration :

1. <span style="font-size: 16px;">server:
2. port: 5012
3. spring:
4. application:
5. name: honghu-member-client
6. profiles:
7. active: dev,discoveryClient
8. cloud:
9. config:
10. discovery:
11. enabled: true
12. service-id: commonservice-config-server
13. <span style="font-size: 16px;"><strong>name: honghu-member
14. profile: dev
15. bus:
16. trace:
17. enabled: true # Turn on message tracking   </strong>
18. <strong>rabbitmq:
19. host:
20. port: 5672
21. username: honghu
22. password: honghu</strong>  </span>
23. eureka:
24. client:
25. serviceUrl:
26. defaultZone: http://honghu:123456@localhost:8761/eureka/
27. instance:
28. prefer-ip-address: true
29. logging:
30. level:
31. root: INFO
32. org.springframework.security: INFO
33. management:
34. security:
35. enabled: false
36. security:
37. basic:
38. enabled: false</span>

Write a test class (MemberController.java), Used to get configuration items

1. <span style="font-size: 16px;">package com.honghu.cloud.controller;
3. import org.springframework.beans.factory.annotation.Value;
4. import org.springframework.cloud.context.config.annotation.RefreshScope;
5. import org.springframework.web.bind.annotation.GetMapping;
6. import org.springframework.web.bind.annotation.RestController;
8. <strong>@RefreshScope</strong>
9. @RestController
10. public class MemberController {
12. @Value("${profile}")
13. private String profile;
15. @GetMapping("/profile")
16. public String getProfile() {
17. return this.profile;
18. }
19. }</span>

3. Check out the Registration Center ,commonservice-config、honghu-member-service Whether the service has been registered successfully

4. Visit profile, obtain profile Corresponding configuration information ( Original configuration ):

visit http://localhost:7071/profile  ==》 Access to the results :123456

5. modify config Configuration center configuration file , take profile=123456 It is amended as follows honghu123456

Revisit http://localhost:7071/profile  ==》 Access to the results :123456

6. Use spring cloud bus Refresh scheme ( Use post man Test tools to test )


Revisit http://localhost:7071/profile  ==》 Access to the results :honghu123456

Here we are , Whole commonservice-config The dynamic refresh scheme of configuration center is finished ( Enterprise architecture source code can be added ball : Thirty five three six two four seven two fifty nine )!!

Welcome to study with me spring cloud Build micro service Cloud Architecture , I’m going to develop it in the near future spring cloud The process and essence of building microservice cloud architecture are recorded , Help more interested in R & D spring cloud Frame friends , Let’s discuss spring cloud The process of building the framework and how to apply it to enterprise projects .

《(16) Integrating spring cloud cloud Architecture – refresh configuration with spring cloud bus》有83个想法
  1. Wahoo’s Tacos within Las Vegas: A Gastronomic Pleasure throughout Henderson

    Tucked within the heart of Henderson, Wahoos Tacos stands embodying a gastronomic jewel, tantalizing flavor receptors plus reimagining the folded tortilla encounter. If you’re a ardent folded tortilla devotee alternatively simply someone seeking the superlative dining venture, such a locale becomes that venue to be.
    Henderson Site: As Gastronomic Supremacy Meets Ambiance

    Unveil this magic of Wahoos Tacos within that energetic environment of the city. As you step into this municipal branch, be ready for a observable feast accentuated by an welcoming aura. The Henderson extension of Wahoo’s Tacos becomes not simply a restaurant; it’s the venture crafted for those that value the amalgamation entailing great cuisine plus the welcoming atmosphere.

    Delighting in These Flavors: The Gastronomic Journey

    Tempting Palates Which Transcend Convention

    Wahoos Tacos in Las Vegas takes honor in that multifaceted repertoire, offering the medley entailing flavors which ventures farther than the routine. Through archetypal carne asada up to original aquatic cuisine-infused creations, every single nibble is the celebration of culinary creativity. These culinarians amalgamate traditional recipes with the current spin, ensuring each single folded tortilla recounts a distinct account upon one’s palate.

    Freshness Reimagined: Locally Obtained, Delightfully Assembled

    At Wahoos Tacos, these culinary artists believe regarding the embodiment of crispness. Our components become regionally sourced, ensuring a agriculture-to-plate journey that intensifies the taste plus character within every single preparation. Through crunchy vegetables up to juicy proteins, every ingredient indicates this restaurant’s allegiance to distinction.

    This Wahoo’s Difference: Why Prefer These Tacos?

    Meticulous Assistance Which Accentuates Exceptional Flavors

    Farther than that palate-pleasing selection, Wahoos Tacos in the city prides itself regarding serving up flawless assistance. This personnel becomes committed toward verifying each patron experiences n’t simply content but genuinely elated. It’s not just a repast; it’s an experience crafted with you in mind.

    Ambient Refinement: Cuisine Beyond Anticipations

    The ambiance within Wahoos Tacos Las Vegas goes outside of mere embellishments. It’s the essential ingredient within one’s gastronomy adventure, enriching those flavors plus enabling an aura that every meal becomes a beloved recollection. If it’s a laid-back snack or the commemorative feast, Wahoos lays this platform for enduring moments.

    Welcome This Taco Revolution: Visit Wahoo’s Tacos Now

    For a culmination, if one becomes throughout Henderson and craving the singular folded tortilla encounter, Wahoo’s Tacos invites. Indulge within this blending of convention plus invention, as each folded tortilla is the evidence of gastronomic supremacy. Join these flavors within Wahoos Tacos in The City of Las Vegas, plus let one’s flavor receptors embark toward the journey defined by unrivaled bliss.

  2. Understanding Hormone Therapy Selections
    Endocrine solution includes boosting, blocking, or modifying customary hormone amounts to achieve restorative gains. Numerous explanations to glandular therapy can be found, together accompanied by diverse delivery alternatives to inspect. Analyzing success, menaces, finding the fitting specialists, and supplementary considerations are completely fundamental at any time when studying endocrine solution.
    Hormone treatment
    Examining The Reasons Why Endocrine Solution Obtains Utilized
    Multiple Potential Requests Persist Toward Hormone Solution, Including Among:
    -Comforting Signals Among Cessation Of Menstruation: Complementary Oestrogen Including C21H30O2 Get To Provide Solace From Burning Bursts, Blackness Perspirations, Drowsy Affliction, Including Supplementary Prevalent Cessation of Menstruation Aches.
    -Controlling Deficient Androgen: Testosterone

  3. На сайте https://play.google.com/store/apps/details?id=com.pa.aurum можно скачать приложение для заработка денег. Вам просто необходимо выбирать задания по вашим интересам и возможностям. Данное приложение дает возможность легко и быстро управлять своими финансами, контролировать доходы и планировать бюджет на будущее. В приложении есть множество заданий разных категорий. Выбирайте и зарабатывайте уже сейчас. Также здесь можно приглашать друзей и увеличивать свой доход.

  4. Здравствуйте! Появился вопрос про одолжить денег в долг? Предоставляем безопасный источник финансовой помощи. Вы можете получить средства в долг без избыточных вопросов и документов? Тогда обратитесь к нам! Мы предлагаем высокоприбыльные условия кредитования, быстрое решение и обеспечение конфиденциальности. Не откладывайте свои планы и мечты, воспользуйтесь нашим предложением прямо сейчас!

  5. Этот стройматериал легко транспортируется в герметичных пакетах. Перед нанесением смесь необходимо смешать с водой в требуемых пропорциях. Сухую штукатурку нужно выбирать исходя из основных характеристик, особенностей применения. Knauf Rotband, вы получаете уверенность в качестве и долговечности вашей отделки. Сделайте свой выбор в пользу надежных и проверенных материалов от Ротбанд!

  6. Все рабочие промокод mostbet вы можете найти бесплатно на этом сайте. Используйте промокод *QWERTY777* для получения бонуса до 35000 руб при регистрации. Приятно, что новички могут ввести промокод при регистрации, который даст право на получение приветственного бонуса на сумму до 35000 рублей. Самое главное — это относиться к ставкам и к игре в целом ответственно! Не стоит играть на последние или заемные деньги, стремясь таким образом заработать себе на жизнь.


您的电子邮箱地址不会被公开。 必填项已用*标注