org.springframework.cloud.stream.config.ListenerContainerCustomizer Java Examples
The following examples show how to use
org.springframework.cloud.stream.config.ListenerContainerCustomizer.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: RabbitMessageChannelBinderConfiguration.java From spring-cloud-stream-binder-rabbit with Apache License 2.0 | 6 votes |
@Bean RabbitMessageChannelBinder rabbitMessageChannelBinder( @Nullable ListenerContainerCustomizer<AbstractMessageListenerContainer> listenerContainerCustomizer, @Nullable MessageSourceCustomizer<AmqpMessageSource> sourceCustomizer, @Nullable ProducerMessageHandlerCustomizer<AmqpOutboundEndpoint> producerMessageHandlerCustomizer, @Nullable ConsumerEndpointCustomizer<AmqpInboundChannelAdapter> consumerCustomizer, List<DeclarableCustomizer> declarableCustomizers) { RabbitMessageChannelBinder binder = new RabbitMessageChannelBinder( this.rabbitConnectionFactory, this.rabbitProperties, provisioningProvider(declarableCustomizers), listenerContainerCustomizer, sourceCustomizer); binder.setAdminAddresses( this.rabbitBinderConfigurationProperties.getAdminAddresses()); binder.setCompressingPostProcessor(gZipPostProcessor()); binder.setDecompressingPostProcessor(deCompressingPostProcessor()); binder.setNodes(this.rabbitBinderConfigurationProperties.getNodes()); binder.setExtendedBindingProperties(this.rabbitExtendedBindingProperties); binder.setProducerMessageHandlerCustomizer(producerMessageHandlerCustomizer); binder.setConsumerEndpointCustomizer(consumerCustomizer); return binder; }
Example #2
Source File: KafkaMessageChannelBinder.java From spring-cloud-stream-binder-kafka with Apache License 2.0 | 5 votes |
public KafkaMessageChannelBinder( KafkaBinderConfigurationProperties configurationProperties, KafkaTopicProvisioner provisioningProvider, ListenerContainerCustomizer<AbstractMessageListenerContainer<?, ?>> containerCustomizer, KafkaBindingRebalanceListener rebalanceListener) { this(configurationProperties, provisioningProvider, containerCustomizer, null, rebalanceListener, null); }
Example #3
Source File: KafkaMessageChannelBinder.java From spring-cloud-stream-binder-kafka with Apache License 2.0 | 5 votes |
public KafkaMessageChannelBinder( KafkaBinderConfigurationProperties configurationProperties, KafkaTopicProvisioner provisioningProvider, ListenerContainerCustomizer<AbstractMessageListenerContainer<?, ?>> containerCustomizer, MessageSourceCustomizer<KafkaMessageSource<?, ?>> sourceCustomizer, KafkaBindingRebalanceListener rebalanceListener, DlqPartitionFunction dlqPartitionFunction) { super(headersToMap(configurationProperties), provisioningProvider, containerCustomizer, sourceCustomizer); this.configurationProperties = configurationProperties; String txId = configurationProperties.getTransaction().getTransactionIdPrefix(); if (StringUtils.hasText(txId)) { this.transactionManager = new KafkaTransactionManager<>(getProducerFactory( txId, new ExtendedProducerProperties<>(configurationProperties .getTransaction().getProducer().getExtension()), txId + ".producer")); this.transactionTemplate = new TransactionTemplate(this.transactionManager); } else { this.transactionManager = null; this.transactionTemplate = null; } this.rebalanceListener = rebalanceListener; this.dlqPartitionFunction = dlqPartitionFunction != null ? dlqPartitionFunction : null; }
Example #4
Source File: ConsumerProducerTransactionTests.java From spring-cloud-stream-binder-kafka with Apache License 2.0 | 5 votes |
@Bean public ListenerContainerCustomizer<AbstractMessageListenerContainer<?, ?>> customizer() { return (container, dest, group) -> { container.setAfterRollbackProcessor(new DefaultAfterRollbackProcessor<>(new FixedBackOff(0L, 1L))); if ("input2".equals(dest)) { this.input2Container = container; } }; }
Example #5
Source File: ProcessorApplication.java From spring-cloud-stream-samples with Apache License 2.0 | 5 votes |
@Bean public ListenerContainerCustomizer<AbstractMessageListenerContainer<byte[], byte[]>> customizer() { // Disable retry in the AfterRollbackProcessor return (container, destination, group) -> container.setAfterRollbackProcessor( new DefaultAfterRollbackProcessor<byte[], byte[]>( (record, exception) -> System.out.println("Discarding failed record: " + record), new FixedBackOff(0L, 0))); }
Example #6
Source File: RabbitMessageChannelBinder.java From spring-cloud-stream-binder-rabbit with Apache License 2.0 | 5 votes |
public RabbitMessageChannelBinder(ConnectionFactory connectionFactory, RabbitProperties rabbitProperties, RabbitExchangeQueueProvisioner provisioningProvider, ListenerContainerCustomizer<AbstractMessageListenerContainer> containerCustomizer) { this(connectionFactory, rabbitProperties, provisioningProvider, containerCustomizer, null); }
Example #7
Source File: RabbitMessageChannelBinder.java From spring-cloud-stream-binder-rabbit with Apache License 2.0 | 5 votes |
public RabbitMessageChannelBinder(ConnectionFactory connectionFactory, RabbitProperties rabbitProperties, RabbitExchangeQueueProvisioner provisioningProvider, ListenerContainerCustomizer<AbstractMessageListenerContainer> containerCustomizer, MessageSourceCustomizer<AmqpMessageSource> sourceCustomizer) { super(new String[0], provisioningProvider, containerCustomizer, sourceCustomizer); Assert.notNull(connectionFactory, "connectionFactory must not be null"); Assert.notNull(rabbitProperties, "rabbitProperties must not be null"); this.connectionFactory = connectionFactory; this.rabbitProperties = rabbitProperties; }
Example #8
Source File: AbstractMessageChannelBinder.java From spring-cloud-stream with Apache License 2.0 | 5 votes |
public AbstractMessageChannelBinder(String[] headersToEmbed, PP provisioningProvider, @Nullable ListenerContainerCustomizer<?> containerCustomizer, @Nullable MessageSourceCustomizer<?> sourceCustomizer) { SimpleModule module = new SimpleModule(); module.addSerializer(Expression.class, new ExpressionSerializer(Expression.class)); objectMapper.registerModule(module); this.headersToEmbed = headersToEmbed == null ? new String[0] : headersToEmbed; this.provisioningProvider = provisioningProvider; this.containerCustomizer = containerCustomizer == null ? (c, q, g) -> { } : containerCustomizer; this.sourceCustomizer = sourceCustomizer == null ? (s, q, g) -> { } : sourceCustomizer; }
Example #9
Source File: DefaultBinderFactory.java From spring-cloud-stream with Apache License 2.0 | 5 votes |
@SuppressWarnings({ "unchecked", "rawtypes" }) private void customizeParentChildContextRelationship(SpringApplicationBuilder applicationBuilder, ApplicationContext context) { if (context != null) { Map<String, ListenerContainerCustomizer> customizers = context.getBeansOfType(ListenerContainerCustomizer.class); applicationBuilder.initializers(childContext -> { if (!CollectionUtils.isEmpty(customizers)) { for (Entry<String, ListenerContainerCustomizer> customizerEntry : customizers.entrySet()) { ListenerContainerCustomizer customizerWrapper = new ListenerContainerCustomizer() { @Override public void configure(Object container, String destinationName, String group) { try { customizerEntry.getValue().configure(container, destinationName, group); } catch (Exception e) { logger.warn("Failed while applying ListenerContainerCustomizer. In situations when multiple " + "binders are used this is expected, since a particular customizer may not be applicable" + "to a particular binder. Customizer: " + customizerEntry.getValue() + " Binder: " + childContext.getBean(AbstractMessageChannelBinder.class), e); } } }; ((GenericApplicationContext) childContext).registerBean(customizerEntry.getKey(), ListenerContainerCustomizer.class, () -> customizerWrapper); } } GenericConversionService cs = (GenericConversionService) ((GenericApplicationContext) childContext).getBeanFactory().getConversionService(); SpelConverter spelConverter = new SpelConverter(); cs.addConverter(spelConverter); }); } }
Example #10
Source File: KafkaBinderActuatorTests.java From spring-cloud-stream-binder-kafka with Apache License 2.0 | 4 votes |
@Bean public ListenerContainerCustomizer<AbstractMessageListenerContainer<?, ?>> containerCustomizer() { return (c, q, g) -> c.setBeanName("setByCustomizer:" + q); }
Example #11
Source File: RabbitBinderModuleTests.java From spring-cloud-stream-binder-rabbit with Apache License 2.0 | 4 votes |
@Bean public ListenerContainerCustomizer<AbstractMessageListenerContainer> containerCustomizer() { return (c, q, g) -> c.setBeanName( "setByCustomizerForQueue:" + q + (g == null ? "" : ",andGroup:" + g)); }
Example #12
Source File: AbstractMessageChannelBinder.java From spring-cloud-stream with Apache License 2.0 | 4 votes |
@SuppressWarnings("unchecked") protected <L> ListenerContainerCustomizer<L> getContainerCustomizer() { return (ListenerContainerCustomizer<L>) this.containerCustomizer; }