@Bean @ConditionalOnProperty(prefix = "spring.rabbitmq", name = "host") public SimpleMessageListenerContainer messageContainer() { SimpleMessageListenerContainer container = new SimpleMessageListenerContainer(connectionFactory); container.setQueues(queue()); container.setExposeListenerChannel(true); container.setMaxConcurrentConsumers(2); container.setConcurrentConsumers(1); //设置确认模式手工确认 container.setAcknowledgeMode(AcknowledgeMode.MANUAL); container.setMessageListener((ChannelAwareMessageListener) (message, channel) -> { byte[] messageBody = message.getBody(); LOGGER.debug("motan 框架接收到的消息"); //确认消息成功消费 final Boolean success = mythMqReceiveService.processMessage(messageBody); if (success) { channel.basicAck(message.getMessageProperties().getDeliveryTag(), false); } }); return container; }
@Bean @ConditionalOnProperty(value = "spring.cloud.skipper.server.enableLocalPlatform", matchIfMissing = true) public Platform localDeployers(LocalPlatformProperties localPlatformProperties) { List<Deployer> deployers = new ArrayList<>(); Map<String, LocalDeployerProperties> localDeployerPropertiesMap = localPlatformProperties.getAccounts(); if (localDeployerPropertiesMap.isEmpty()) { localDeployerPropertiesMap.put("default", new LocalDeployerProperties()); } for (Map.Entry<String, LocalDeployerProperties> entry : localDeployerPropertiesMap .entrySet()) { LocalAppDeployer localAppDeployer = new LocalAppDeployer(entry.getValue()); Deployer deployer = new Deployer(entry.getKey(), "local", localAppDeployer); deployer.setDescription(prettyPrintLocalDeployerProperties(entry.getValue())); deployers.add(deployer); } return new Platform("Local", deployers); }
@ConditionalOnProperty(prefix = "cas.httpWebRequest.cors", name = "enabled", havingValue = "true") @Bean @RefreshScope public FilterRegistrationBean casCorsFilter() { final HttpWebRequestProperties.Cors cors = casProperties.getHttpWebRequest().getCors(); final UrlBasedCorsConfigurationSource source = new UrlBasedCorsConfigurationSource(); final CorsConfiguration config = new CorsConfiguration(); config.setAllowCredentials(cors.isEnabled()); config.setAllowedOrigins(cors.getAllowOrigins()); config.setAllowedMethods(cors.getAllowMethods()); config.setAllowedHeaders(cors.getAllowHeaders()); config.setMaxAge(cors.getMaxAge()); config.setExposedHeaders(cors.getExposedHeaders()); source.registerCorsConfiguration("/**", config); final FilterRegistrationBean bean = new FilterRegistrationBean(new CorsFilter(source)); bean.setName("casCorsFilter"); bean.setAsyncSupported(true); bean.setOrder(0); return bean; }
@Bean @ConditionalOnClass(DefaultMQProducer.class) @ConditionalOnMissingBean(DefaultMQProducer.class) @ConditionalOnProperty(prefix = "spring.rocketmq", value = {"nameServer", "producer.group"}) public DefaultMQProducer mqProducer(RocketMQProperties rocketMQProperties) { RocketMQProperties.Producer producerConfig = rocketMQProperties.getProducer(); String groupName = producerConfig.getGroup(); Assert.hasText(groupName, "[spring.rocketmq.producer.group] must not be null"); DefaultMQProducer producer = new DefaultMQProducer(producerConfig.getGroup()); producer.setNamesrvAddr(rocketMQProperties.getNameServer()); producer.setSendMsgTimeout(producerConfig.getSendMsgTimeout()); producer.setRetryTimesWhenSendFailed(producerConfig.getRetryTimesWhenSendFailed()); producer.setRetryTimesWhenSendAsyncFailed(producerConfig.getRetryTimesWhenSendAsyncFailed()); producer.setMaxMessageSize(producerConfig.getMaxMessageSize()); producer.setCompressMsgBodyOverHowmuch(producerConfig.getCompressMsgBodyOverHowmuch()); producer.setRetryAnotherBrokerWhenNotStoreOK(producerConfig.isRetryAnotherBrokerWhenNotStoreOk()); return producer; }
/** * If AOP is not enabled, scheduled interception will not work. */ @Bean @ConditionalOnClass(name = "org.aspectj.lang.ProceedingJoinPoint") @ConditionalOnProperty(value = "spring.aop.enabled", havingValue = "true", matchIfMissing = true) public ScheduledMethodMetrics metricsSchedulingAspect(MeterRegistry registry) { return new ScheduledMethodMetrics(registry); }
/** * S3 储存客户端 * * @return 客户端 */ @Bean @ConditionalOnProperty(value = "bigbug.storage.s3.enable", havingValue = "true") AmazonS3Client amazonS3Client() { ClientConfiguration clientConfig = new ClientConfiguration(); clientConfig.setProtocol(Protocol.HTTP); BasicAWSCredentials basicAWSCredentials = new BasicAWSCredentials( storageProperties.getStorage().getS3().getAccessKey(), storageProperties.getStorage().getS3().getSecretKey()); return (AmazonS3Client) AmazonS3ClientBuilder.standard() .withClientConfiguration(clientConfig) .withEndpointConfiguration( new AwsClientBuilder.EndpointConfiguration( storageProperties.getStorage().getS3().getEndpoint(), Regions.DEFAULT_REGION.getName())) .withCredentials(new AWSStaticCredentialsProvider(basicAWSCredentials)) .build(); }
@Bean @ConditionalOnProperty(prefix = "spring.rabbitmq", name = "host") public SimpleMessageListenerContainer messageContainer() { SimpleMessageListenerContainer container = new SimpleMessageListenerContainer(connectionFactory); container.setQueues(queue()); container.setExposeListenerChannel(true); container.setMaxConcurrentConsumers(1); container.setConcurrentConsumers(1); //设置确认模式手工确认 container.setAcknowledgeMode(AcknowledgeMode.MANUAL); container.setMessageListener((ChannelAwareMessageListener) (message, channel) -> { byte[] messageBody = message.getBody(); //确认消息成功消费 final Boolean success = mythMqReceiveService.processMessage(messageBody); if (success) { channel.basicAck(message.getMessageProperties().getDeliveryTag(), false); } }); return container; }
@Bean(name = "queueListenerContainerFactory") @ConditionalOnProperty(prefix = "spring.activemq", name = "broker-url") public JmsListenerContainerFactory<?> jmsListenerContainerQueue(ConnectionFactory activeMQConnectionFactory) { DefaultJmsListenerContainerFactory bean = new DefaultJmsListenerContainerFactory(); bean.setConnectionFactory(activeMQConnectionFactory); bean.setPubSubDomain(Boolean.FALSE); return bean; }
@Bean @ConditionalOnProperty(prefix = "spring.rabbitmq", name = "host") public SimpleMessageListenerContainer messageContainer() { SimpleMessageListenerContainer container = new SimpleMessageListenerContainer(connectionFactory); container.setQueues(queue()); container.setExposeListenerChannel(true); container.setMaxConcurrentConsumers(3); container.setConcurrentConsumers(1); //设置确认模式手工确认 container.setAcknowledgeMode(AcknowledgeMode.MANUAL); container.setMessageListener((ChannelAwareMessageListener) (message, channel) -> { byte[] messageBody = message.getBody(); LogUtil.debug(LOGGER,()->"springcloud account服务 amqp接收消息"); //确认消息成功消费 final Boolean success = mythMqReceiveService.processMessage(messageBody); if (success) { channel.basicAck(message.getMessageProperties().getDeliveryTag(), false); } }); return container; }
@Bean @ConditionalOnProperty("jhipster.logging.spectator-metrics.enabled") @ExportMetricReader public SpectatorMetricReader SpectatorMetricReader(Registry registry) { log.info("Initializing Spectator Metrics Log reporting"); return new SpectatorMetricReader(registry); }
@Bean("blueKitResetPasswordPolicy") @ConditionalOnBean(ResetPasswordPolicy.class) @ConditionalOnProperty(prefix = "blue-kit.b2c.policy.edit-profile", value = {"name", "redirect-url"}) @ConfigurationProperties("blue-kit.b2c.policy.reset-password") public ResetPasswordPolicy blueKitResetPasswordPolicy(){ return new ResetPasswordPolicy(); }
@ConditionalOnMissingBean(name = "ticketRegistryCleanerScheduler") @ConditionalOnProperty(prefix = "cas.ticket.registry.cleaner", name = "enabled", havingValue = "true", matchIfMissing = true) @Bean @Autowired @RefreshScope public TicketRegistryCleanerScheduler ticketRegistryCleanerScheduler(@Qualifier("ticketRegistryCleaner") final TicketRegistryCleaner ticketRegistryCleaner) { return new TicketRegistryCleanerScheduler(ticketRegistryCleaner); }
@Bean @ConditionalOnProperty(name = "spring.datasource4.url") @ConfigurationProperties(prefix = "spring.datasource4") public DataSourceInitializer dataSourceInitializer4(DataSourceProperties properties, ApplicationContext applicationContext) { return new DataSourceInitializer(properties, applicationContext, 4); }
@Bean @ConditionalOnProperty("jhipster.logging.spectator-metrics.enabled") @ExportMetricReader public SpectatorMetricReader spectatorMetricReader(Registry registry) { log.info("Initializing Spectator Metrics Log reporting"); return new SpectatorMetricReader(registry); }
@Bean @ConditionalOnProperty(value = "spring.sleuth.amqp.enabled", matchIfMissing = true) @ConditionalOnMissingBean(AmqpMessagingSpanManager.class) public AmqpMessagingSpanManager amqpMessagingSpanManager( AmqpMessagingSpanInjector amqpMessagingSpanInjector, AmqpMessagingSpanExtractor amqpMessagingSpanExtractor, Tracer tracer) { return new DefaultAmqpMessagingSpanManager( amqpMessagingSpanInjector, amqpMessagingSpanExtractor, tracer); }
@ConditionalOnProperty(value = "saga.runningMode", havingValue = "graph", matchIfMissing = true) @Bean SagaFactory graphBasedSagaFactory( @Value("${saga.thread.count:5}") int numberOfThreads, @Value("${saga.retry.delay:3000}") int retryDelay, PersistentStore persistentStore, FromJsonFormat<Set<String>> childrenExtractor) { return new GraphBasedSagaFactory( retryDelay, persistentStore, childrenExtractor, Executors.newFixedThreadPool(numberOfThreads, sagaThreadFactory())); }
@ConditionalOnProperty(value = "saga.runningMode", havingValue = "actor") @Bean SagaFactory actorBasedSagaFactory( @Value("${saga.retry.delay:3000}") int retryDelay, PersistentStore persistentStore, FromJsonFormat<Set<String>> childrenExtractor) { return new ActorBasedSagaFactory( retryDelay, persistentStore, childrenExtractor); }
@Bean("blueKitChangeEmailPolicy") @ConditionalOnBean(ChangeEmailPolicy.class) @ConditionalOnProperty(prefix = "blue-kit.b2c.policy.change-email", value = {"name", "redirect-url", "template-url"}) @ConfigurationProperties("blue-kit.b2c.policy.change-email") public ChangeEmailPolicy blueKitChangeEmailPolicy(){ throw new NotFoundException("'change-email' is not a valid policy (yet) provided by Microsoft's Azure AD B2C. You must manually change the email using the GraphApi instead."); }
@Bean @ConditionalOnMissingBean(LogbackMetrics.class) @ConditionalOnProperty(value = "management.metrics.binders.logback.enabled", matchIfMissing = true) @ConditionalOnClass(name = "ch.qos.logback.classic.Logger") public LogbackMetrics logbackMetrics() { return new LogbackMetrics(); }
@Bean("blueKitSignUpPolicy") @ConditionalOnBean(SignUpPolicy.class) @ConditionalOnProperty(prefix = "blue-kit.b2c.policy.sign-up", value = {"name", "redirect-url"}) @ConfigurationProperties("blue-kit.b2c.policy.sign-up") public SignUpPolicy blueKitSignUpPolicy(){ return new SignUpPolicy(); }
@Bean(destroyMethod = "stop") @ConditionalOnProperty({ "nakadi-producer.access-token-uri", "nakadi-producer.access-token-scopes" }) @ConditionalOnMissingBean(AccessTokenProvider.class) public StupsTokenComponent accessTokenProvider( @Value("${nakadi-producer.access-token-uri}") URI accessTokenUri, @Value("${nakadi-producer.access-token-scopes}") String[] accessTokenScopes) { return new StupsTokenComponent(accessTokenUri, Arrays.asList(accessTokenScopes)); }
@Bean @ConditionalOnProperty(name = "jhipster.cors.allowed-origins") public CorsFilter corsFilter() { log.debug("Registering CORS filter"); UrlBasedCorsConfigurationSource source = new UrlBasedCorsConfigurationSource(); CorsConfiguration config = jHipsterProperties.getCors(); source.registerCorsConfiguration("/api/**", config); source.registerCorsConfiguration("/v2/api-docs", config); source.registerCorsConfiguration("/oauth/**", config); return new CorsFilter(source); }
@Bean("blueKitSignOutPolicy") @ConditionalOnBean(SignOutPolicy.class) @ConditionalOnProperty(prefix = "blue-kit.b2c.policy.sign-out") @ConfigurationProperties("blue-kit.b2c.policy.sign-out") public SignOutPolicy blueKitSignOutPolicy(){ return new SignOutPolicy(); }
@Bean @ConditionalOnProperty(prefix = DRUID_WALL_FILTER_PREFIX, name = "enabled", havingValue = "true") @ConfigurationProperties(DRUID_WALL_FILTER_PREFIX) public WallFilter wallFilter(WallConfig wallConfig) { log.debug("druid wall-filter init..."); WallFilter filter = new WallFilter(); filter.setConfig(wallConfig); return filter; }
@Bean @ConditionalOnProperty(prefix = DRUID_SLF4J_FILTER_PREFIX, name = "enabled", havingValue = "true") @ConfigurationProperties(DRUID_SLF4J_FILTER_PREFIX) public Slf4jLogFilter slf4jLogFilter() { log.debug("druid slf4j-filter init..."); return new Slf4jLogFilter(); }
@Bean @ConditionalOnProperty(prefix = DRUID_COMMONS_LOG_FILTER_PREFIX, name = "enabled", havingValue = "true") @ConfigurationProperties(DRUID_COMMONS_LOG_FILTER_PREFIX) public CommonsLogFilter commonsLogFilter() { log.debug("druid commons-log-filter init..."); return new CommonsLogFilter(); }
@Bean @ConditionalOnProperty(prefix = "camunda.bpm.job-execution", name = "enabled", havingValue = "true", matchIfMissing = true) public static JobExecutor jobExecutor(@Qualifier(JobConfiguration.CAMUNDA_TASK_EXECUTOR_QUALIFIER) final TaskExecutor taskExecutor) { final SpringJobExecutor springJobExecutor = new SpringJobExecutor(); springJobExecutor.setTaskExecutor(taskExecutor); springJobExecutor.setRejectedJobsHandler(new CallerRunsRejectedJobsHandler()); springJobExecutor.setWaitTimeInMillis(10); // springJobExecutor.setWaitIncreaseFactor(1.0f); springJobExecutor.setMaxWait(20); return springJobExecutor; }
@Bean @ConditionalOnProperty( value = "zipkin.sparkstreaming.adjuster.finagle.adjust-issue343", havingValue = "true" ) Adjuster finagleIssue343Adjuster() { return FinagleIssue343Adjuster.create(); }
@Bean("twitter") @Scope(ConfigurableBeanFactory.SCOPE_SINGLETON) @Lazy @ConditionalOnProperty(prefix = "io.syndesis.connector.twitter.verifier", name = "enabled", matchIfMissing = true) public Verifier twitterVerifier() { return new TwitterVerifier(); }
@Bean @ConditionalOnMissingBean(ServiceProperties.class) @ConditionalOnProperty(value = "security.cas.service.resolution-mode", havingValue = "dynamic") ServiceProperties laxServiceProperties() { LaxServiceProperties serviceProperties = new LaxServiceProperties(); serviceProperties.setAuthenticateAllArtifacts(true); return serviceProperties; }
@Bean(initMethod="init",destroyMethod="destroy") @ConditionalOnProperty(prefix = "elephant",value = {"zk-server"}) public ZkClientRegisterCenter zkClientRegisterCenter(@Value("${elephant.zk-server}")String zkServer){ ZkClientRegisterCenter registerCenter = new ZkClientRegisterCenter(); registerCenter.setZkAddress(zkServer); return registerCenter; }