In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-03-31 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)06/02 Report--
I. Common configuration of dubbo
Service configuration, which is used to expose a service and define the meta-information of a service, a service can be exposed with multiple protocols, and a service can be registered with multiple registries.
Eg 、
Reference service configuration, which is used to create a remote service proxy, and a reference can point to multiple registries.
Eg 、
Protocol configuration, which is used to configure the protocol information for providing services. The protocol is specified by the provider and passively accepted by the consumer.
Eg 、
Application configuration, which is used to configure the current application information, whether the application is a provider or a consumer.
Eg 、
Module configuration, used to configure the current module information, optional.
Registry configuration, which is used to configure information about the connection registry.
Eg 、
Monitoring center configuration, used to configure connection monitoring center related information, optional.
Default value of the provider, which is optional when a property of ProtocolConfig and ServiceConfig is not configured.
The default configuration of the consumer, which is optional when an attribute of ReferenceConfig is not configured.
Method configuration for ServiceConfig and ReferenceConfig to specify method-level configuration information.
Used to specify the method parameter configuration.
Second, service invocation timeout setting
The figure above takes timeout as an example, which shows the search order of the configuration, as do other retries, loadbalance, and actives.
The method level takes priority, the interface level takes the second place, and the global configuration comes again.
If the level is the same, the consumer takes priority and the provider takes second place.
Wherein, the configuration of the service provider is transmitted to the consumer through the URL through the registry.
It is recommended that the service provider set the timeout, because how long a method needs to execute, the service provider is more aware that if a consumer references multiple services at the same time, you do not need to care about the timeout setting for each service.
Theoretically, the non-service identity configuration of ReferenceConfig can be configured by default in both ConsumerConfig,ServiceConfig and ProviderConfig.
Third, check at startup
By default, Dubbo checks whether the dependent service is available at startup, and throws an exception when it is not available to prevent Spring initialization from being completed, so that problems can be found as early as possible when you go online. Default is check=true.
If your Spring container is lazily loaded, or if you delay referencing the service through API programming, please close check, otherwise, if the service is temporarily unavailable, it will throw an exception and get a null reference. If check=false, it will always return a reference, and when the service is restored, it can be connected automatically.
You can turn off checking through the check= "false". For example, when testing, some services do not care, or circular dependencies occur, and one party must start first.
1. Turn off the startup check of a service: (no provider Times error)
2. Turn off the startup check of all services: (no provider Times error) written on the side of defining service consumers
3. Check when closing the registry and starting: (failed to register subscription, Times error)
References are delayed initialization by default and will only be initialized if the reference is injected into another Bean or obtained by getBean ().
If hungry loading is needed, that is, dynamic proxies are generated immediately without being referenced, you can configure:
IV. Subscription
1. Question
In order to facilitate development and testing, it is often offline to share a registry where all services are available. At this time, if a service provider under development registers, consumers may not be able to function properly.
2. Solution
You can let the service provider developer subscribe to only the service (the developed service may depend on other services) without registering the service under development and test the service under development through a direct connection.
Disable the registration configuration:
Or:
5. Echo testing (testing whether the service is available)
The echo test is used to check whether the service is available. The echo test is performed according to the normal request flow, which can test whether the whole call is smooth and can be used for monitoring.
All services automatically implement the EchoService interface, as long as any service reference is forcibly transformed into EchoService, and it can be used.
Eg, MemberService memberService = ctx.getBean ("memberService"); / / remote service reference EchoService echoService = (EchoService) memberService; / / forced transformation to EchoServiceString status = echoService.$echo ("OK"); / / Echo test availability assert (status.equals ("OK"))
VI. Delayed connection
Deferred connection, which is used to reduce the number of persistent connections and create persistent connections when a call is initiated.
It only works for dubbo protocols that use persistent connections.
7. Token verification
Prevent consumers from bypassing the registry to access the provider and control permissions in the registry to decide whether or not to issue tokens to consumers. The registry has the flexibility to change the mode of authorization without modifying or upgrading the provider.
1. Global settings enable token verification: 2. Service level settings enable token verification: 3. Protocol level settings enable token verification:
8. Log adaptation
Default automatic lookup: log4j, slf4j, jcl, jdk
You can configure the log output policy in the following ways: dubbo:application logger= "log4j" / >
Access Log:
If you want to record each request, you can open the access log, which is similar to apache's access log. This log volume is relatively large, please pay attention to the disk capacity.
Output the access log to the currently applied log4j log:
Output the access log to the specified file:
9. Configure Dubbo cache files
The configuration method is as follows:
Note:
The path of the file, the application can be adjusted as needed to ensure that the file will not be erased during the release process. If there are multiple application processes, be careful not to use the same file to avoid overwriting the content.
This file is cached:
List of registry service providers list
With this configuration, when the Dubbo registry is not available during the application restart, the application will read the list of service providers from the cache file to further ensure the reliability of the application.
The above is the whole content of this article, I hope it will be helpful to your study, and I also hope that you will support it.
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.