@Bean
    public RateLimiterRegistry rateLimiterRegistry(
        RateLimiterConfigurationProperties rateLimiterProperties,
        EventConsumerRegistry<RateLimiterEvent> rateLimiterEventsConsumerRegistry,
        RegistryEventConsumer<RateLimiter> rateLimiterRegistryEventConsumer,
        @Qualifier("compositeRateLimiterCustomizer") CompositeCustomizer<RateLimiterConfigCustomizer> compositeRateLimiterCustomizer) {
        RateLimiterRegistry rateLimiterRegistry = createRateLimiterRegistry(rateLimiterProperties,
            rateLimiterRegistryEventConsumer, compositeRateLimiterCustomizer);
        registerEventConsumer(rateLimiterRegistry, rateLimiterEventsConsumerRegistry,
            rateLimiterProperties);
        initRateLimiterRegistry(rateLimiterProperties, compositeRateLimiterCustomizer, rateLimiterRegistry);
        return rateLimiterRegistry;
    }
@Test
    public void testCreateRateLimiterRegistryWithSharedConfigs() {
        //Given
        io.github.resilience4j.common.ratelimiter.configuration.CommonRateLimiterConfigurationProperties.InstanceProperties defaultProperties = new io.github.resilience4j.common.ratelimiter.configuration.CommonRateLimiterConfigurationProperties.InstanceProperties();
        defaultProperties.setLimitForPeriod(3);
        defaultProperties.setLimitRefreshPeriod(Duration.ofNanos(5000000));
        defaultProperties.setSubscribeForEvents(true);

        io.github.resilience4j.common.ratelimiter.configuration.CommonRateLimiterConfigurationProperties.InstanceProperties sharedProperties = new io.github.resilience4j.common.ratelimiter.configuration.CommonRateLimiterConfigurationProperties.InstanceProperties();
        sharedProperties.setLimitForPeriod(2);
        sharedProperties.setLimitRefreshPeriod(Duration.ofNanos(6000000));
        sharedProperties.setSubscribeForEvents(true);

        io.github.resilience4j.common.ratelimiter.configuration.CommonRateLimiterConfigurationProperties.InstanceProperties backendWithDefaultConfig = new io.github.resilience4j.common.ratelimiter.configuration.CommonRateLimiterConfigurationProperties.InstanceProperties();
        backendWithDefaultConfig.setBaseConfig("default");
        backendWithDefaultConfig.setLimitForPeriod(200);
        backendWithDefaultConfig.setSubscribeForEvents(true);

        io.github.resilience4j.common.ratelimiter.configuration.CommonRateLimiterConfigurationProperties.InstanceProperties backendWithSharedConfig = new io.github.resilience4j.common.ratelimiter.configuration.CommonRateLimiterConfigurationProperties.InstanceProperties();
        backendWithSharedConfig.setBaseConfig("sharedConfig");
        backendWithSharedConfig.setLimitForPeriod(300);
        backendWithSharedConfig.setSubscribeForEvents(true);

        RateLimiterConfigurationProperties rateLimiterConfigurationProperties = new RateLimiterConfigurationProperties();
        rateLimiterConfigurationProperties.getConfigs().put("default", defaultProperties);
        rateLimiterConfigurationProperties.getConfigs().put("sharedConfig", sharedProperties);

        rateLimiterConfigurationProperties.getInstances()
            .put("backendWithDefaultConfig", backendWithDefaultConfig);
        rateLimiterConfigurationProperties.getInstances()
            .put("backendWithSharedConfig", backendWithSharedConfig);

        RateLimiterConfiguration rateLimiterConfiguration = new RateLimiterConfiguration();
        DefaultEventConsumerRegistry<RateLimiterEvent> eventConsumerRegistry = new DefaultEventConsumerRegistry<>();

        //When
        RateLimiterRegistry rateLimiterRegistry = rateLimiterConfiguration
            .rateLimiterRegistry(rateLimiterConfigurationProperties, eventConsumerRegistry,
                new CompositeRegistryEventConsumer<>(emptyList()),
                compositeRateLimiterCustomizerTest());

        //Then
        assertThat(rateLimiterRegistry.getAllRateLimiters().size()).isEqualTo(2);

        // Should get default config and override LimitForPeriod
        RateLimiter rateLimiter1 = rateLimiterRegistry.rateLimiter("backendWithDefaultConfig");
        assertThat(rateLimiter1).isNotNull();
        assertThat(rateLimiter1.getRateLimiterConfig().getLimitForPeriod()).isEqualTo(200);
        assertThat(rateLimiter1.getRateLimiterConfig().getLimitRefreshPeriod())
            .isEqualTo(Duration.ofMillis(5));

        // Should get shared config and override LimitForPeriod
        RateLimiter rateLimiter2 = rateLimiterRegistry.rateLimiter("backendWithSharedConfig");
        assertThat(rateLimiter2).isNotNull();
        assertThat(rateLimiter2.getRateLimiterConfig().getLimitForPeriod()).isEqualTo(300);
        assertThat(rateLimiter2.getRateLimiterConfig().getLimitRefreshPeriod())
            .isEqualTo(Duration.ofMillis(6));

        // Unknown backend should get default config of Registry
        RateLimiter rerateLimiter3 = rateLimiterRegistry.rateLimiter("unknownBackend");
        assertThat(rerateLimiter3).isNotNull();
        assertThat(rerateLimiter3.getRateLimiterConfig().getLimitForPeriod()).isEqualTo(3);

        assertThat(eventConsumerRegistry.getAllEventConsumer()).hasSize(2);
    }