org.springframework.cloud.stream.config.MessageSourceCustomizer Java Examples

The following examples show how to use org.springframework.cloud.stream.config.MessageSourceCustomizer. 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 vote down vote up
@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 vote down vote up
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 #3
Source File: RabbitMessageChannelBinder.java    From spring-cloud-stream-binder-rabbit with Apache License 2.0 5 votes vote down vote up
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 #4
Source File: AbstractMessageChannelBinder.java    From spring-cloud-stream with Apache License 2.0 5 votes vote down vote up
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 #5
Source File: KafkaBinderActuatorTests.java    From spring-cloud-stream-binder-kafka with Apache License 2.0 4 votes vote down vote up
@Bean
public MessageSourceCustomizer<KafkaMessageSource<?, ?>> sourceCustomizer() {
	return (s, q, g) -> s.setBeanName("setByCustomizer:" + q);
}
 
Example #6
Source File: RabbitBinderModuleTests.java    From spring-cloud-stream-binder-rabbit with Apache License 2.0 4 votes vote down vote up
@Bean
public MessageSourceCustomizer<AmqpMessageSource> sourceCustomizer() {
	return (s, q, g) -> s.setBeanName("setByCustomizer:" + g);
}
 
Example #7
Source File: AbstractMessageChannelBinder.java    From spring-cloud-stream with Apache License 2.0 4 votes vote down vote up
@SuppressWarnings("unchecked")
protected <S> MessageSourceCustomizer<S> getMessageSourceCustomizer() {
	return (MessageSourceCustomizer<S>) this.sourceCustomizer;
}