org.springframework.integration.channel.AbstractMessageChannel Java Examples

The following examples show how to use org.springframework.integration.channel.AbstractMessageChannel. 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: OpenTracingChannelInterceptor.java    From java-specialagent with Apache License 2.0 6 votes vote down vote up
protected String getChannelName(MessageChannel messageChannel) {
  String name = null;
  if (ClassUtils.isPresent("org.springframework.integration.context.IntegrationObjectSupport", null)) {
    if (messageChannel instanceof IntegrationObjectSupport) {
      name = ((IntegrationObjectSupport) messageChannel).getComponentName();
    }
    if (name == null && messageChannel instanceof AbstractMessageChannel) {
      name = ((AbstractMessageChannel) messageChannel).getFullChannelName();
    }
  }

  if (name == null) {
    return messageChannel.toString();
  }

  return name;
}
 
Example #2
Source File: TestSupportBinder.java    From spring-cloud-stream with Apache License 2.0 5 votes vote down vote up
private BlockingQueue<Message<?>> register(MessageChannel channel,
		boolean useNativeEncoding) {
	// we need to add this interceptor to ensure MessageCollector's compatibility
	// with
	// previous versions of SCSt when native encoding is disabled.
	if (!useNativeEncoding) {
		((AbstractMessageChannel) channel)
				.addInterceptor(new InboundMessageConvertingInterceptor());
	}
	LinkedBlockingDeque<Message<?>> result = new LinkedBlockingDeque<>();
	Assert.isTrue(!this.results.containsKey(channel),
			"Channel [" + channel + "] was already bound");
	this.results.put(channel, result);
	return result;
}
 
Example #3
Source File: TestChannelBinderProvisioner.java    From spring-cloud-stream with Apache License 2.0 5 votes vote down vote up
private SubscribableChannel provisionDestination(String name, boolean pubSub) {
	String destinationName = name + ".destination";
	SubscribableChannel destination = this.provisionedDestinations
			.get(destinationName);
	if (destination == null) {
		destination = pubSub ? new PublishSubscribeChannel() : new DirectChannel();
		((AbstractMessageChannel) destination).setBeanName(destinationName);
		((AbstractMessageChannel) destination).setComponentName(destinationName);
		this.provisionedDestinations.put(destinationName, destination);
	}
	return destination;
}
 
Example #4
Source File: MessageConverterConfigurer.java    From spring-cloud-stream with Apache License 2.0 5 votes vote down vote up
/**
 * Setup data-type and message converters for the given message channel.
 * @param channel message channel to set the data-type and message converters
 * @param channelName the channel name
 * @param inbound inbound (i.e., "input") or outbound channel
 */
private void configureMessageChannel(MessageChannel channel, String channelName,
		boolean inbound) {
	Assert.isAssignable(AbstractMessageChannel.class, channel.getClass());
	AbstractMessageChannel messageChannel = (AbstractMessageChannel) channel;
	BindingProperties bindingProperties = this.bindingServiceProperties
			.getBindingProperties(channelName);
	String contentType = bindingProperties.getContentType();
	ProducerProperties producerProperties = bindingProperties.getProducer();
	boolean partitioned = !inbound && producerProperties != null && producerProperties.isPartitioned();
	boolean functional = streamFunctionProperties != null
			&& (StringUtils.hasText(streamFunctionProperties.getDefinition()) || StringUtils.hasText(bindingServiceProperties.getSource()));

	if (partitioned) {
		if (inbound || !functional) {
			messageChannel.addInterceptor(new PartitioningInterceptor(bindingProperties));
		}
	}

	ConsumerProperties consumerProperties = bindingProperties.getConsumer();
	if (this.isNativeEncodingNotSet(producerProperties, consumerProperties, inbound)) {
		if (inbound) {
			messageChannel.addInterceptor(
					new InboundContentTypeEnhancingInterceptor(contentType));
		}
		else {
			messageChannel.addInterceptor(
					new OutboundContentTypeConvertingInterceptor(contentType,
							this.compositeMessageConverter));
		}
	}
}
 
Example #5
Source File: TracingChannelInterceptor.java    From spring-cloud-sleuth with Apache License 2.0 5 votes vote down vote up
private String channelName(MessageChannel channel) {
	String name = null;
	if (this.integrationObjectSupportPresent) {
		if (channel instanceof IntegrationObjectSupport) {
			name = ((IntegrationObjectSupport) channel).getComponentName();
		}
		if (name == null && channel instanceof AbstractMessageChannel) {
			name = ((AbstractMessageChannel) channel).getFullChannelName();
		}
	}
	if (name == null) {
		name = channel.toString();
	}
	return name;
}
 
Example #6
Source File: RabbitMessageChannelBinder.java    From spring-cloud-stream-binder-rabbit with Apache License 2.0 5 votes vote down vote up
@Override
protected void postProcessOutputChannel(MessageChannel outputChannel,
		ExtendedProducerProperties<RabbitProducerProperties> producerProperties) {
	RabbitProducerProperties extendedProperties = producerProperties.getExtension();
	if (expressionInterceptorNeeded(extendedProperties)) {
		((AbstractMessageChannel) outputChannel).addInterceptor(0,
				new RabbitExpressionEvaluatingInterceptor(
						extendedProperties.getRoutingKeyExpression(),
						extendedProperties.getDelayExpression(),
						getEvaluationContext()));
	}
}
 
Example #7
Source File: KafkaMessageChannelBinder.java    From spring-cloud-stream-binder-kafka with Apache License 2.0 5 votes vote down vote up
@Override
protected void postProcessOutputChannel(MessageChannel outputChannel,
		ExtendedProducerProperties<KafkaProducerProperties> producerProperties) {

	if (expressionInterceptorNeeded(producerProperties)) {
		((AbstractMessageChannel) outputChannel).addInterceptor(0, new KafkaExpressionEvaluatingInterceptor(
				producerProperties.getExtension().getMessageKeyExpression(), getEvaluationContext()));
	}
}
 
Example #8
Source File: ProductServiceApplicationTests.java    From Hands-On-Microservices-with-Spring-Boot-and-Spring-Cloud with MIT License 4 votes vote down vote up
@Before
public void setupDb() {
	input = (AbstractMessageChannel) channels.input();
	repository.deleteAll().block();
}
 
Example #9
Source File: RecommendationServiceApplicationTests.java    From Hands-On-Microservices-with-Spring-Boot-and-Spring-Cloud with MIT License 4 votes vote down vote up
@Before
public void setupDb() {
	input = (AbstractMessageChannel) channels.input();
	repository.deleteAll().block();
}
 
Example #10
Source File: ReviewServiceApplicationTests.java    From Hands-On-Microservices-with-Spring-Boot-and-Spring-Cloud with MIT License 4 votes vote down vote up
@Before
public void setupDb() {
	input = (AbstractMessageChannel) channels.input();
	repository.deleteAll();
}
 
Example #11
Source File: RecommendationServiceApplicationTests.java    From Hands-On-Microservices-with-Spring-Boot-and-Spring-Cloud with MIT License 4 votes vote down vote up
@Before
public void setupDb() {
	input = (AbstractMessageChannel) channels.input();
	repository.deleteAll().block();
}
 
Example #12
Source File: ProductServiceApplicationTests.java    From Hands-On-Microservices-with-Spring-Boot-and-Spring-Cloud with MIT License 4 votes vote down vote up
@Before
public void setupDb() {
	input = (AbstractMessageChannel) channels.input();
	repository.deleteAll().block();
}
 
Example #13
Source File: ReviewServiceApplicationTests.java    From Hands-On-Microservices-with-Spring-Boot-and-Spring-Cloud with MIT License 4 votes vote down vote up
@Before
public void setupDb() {
	input = (AbstractMessageChannel) channels.input();
	repository.deleteAll();
}
 
Example #14
Source File: RecommendationServiceApplicationTests.java    From Hands-On-Microservices-with-Spring-Boot-and-Spring-Cloud with MIT License 4 votes vote down vote up
@Before
public void setupDb() {
	input = (AbstractMessageChannel) channels.input();
	repository.deleteAll().block();
}
 
Example #15
Source File: ProductServiceApplicationTests.java    From Hands-On-Microservices-with-Spring-Boot-and-Spring-Cloud with MIT License 4 votes vote down vote up
@Before
public void setupDb() {
	input = (AbstractMessageChannel) channels.input();
	repository.deleteAll().block();
}
 
Example #16
Source File: ReviewServiceApplicationTests.java    From Hands-On-Microservices-with-Spring-Boot-and-Spring-Cloud with MIT License 4 votes vote down vote up
@Before
public void setupDb() {
	input = (AbstractMessageChannel) channels.input();
	repository.deleteAll();
}
 
Example #17
Source File: ReviewServiceApplicationTests.java    From Hands-On-Microservices-with-Spring-Boot-and-Spring-Cloud with MIT License 4 votes vote down vote up
@Before
public void setupDb() {
	input = (AbstractMessageChannel) channels.input();
	repository.deleteAll();
}
 
Example #18
Source File: RecommendationServiceApplicationTests.java    From Hands-On-Microservices-with-Spring-Boot-and-Spring-Cloud with MIT License 4 votes vote down vote up
@Before
public void setupDb() {
	input = (AbstractMessageChannel) channels.input();
	repository.deleteAll().block();
}
 
Example #19
Source File: ReviewServiceApplicationTests.java    From Hands-On-Microservices-with-Spring-Boot-and-Spring-Cloud with MIT License 4 votes vote down vote up
@Before
public void setupDb() {
	input = (AbstractMessageChannel) channels.input();
	repository.deleteAll();
}
 
Example #20
Source File: ProductServiceApplicationTests.java    From Hands-On-Microservices-with-Spring-Boot-and-Spring-Cloud with MIT License 4 votes vote down vote up
@Before
public void setupDb() {
	input = (AbstractMessageChannel) channels.input();
	repository.deleteAll().block();
}
 
Example #21
Source File: RecommendationServiceApplicationTests.java    From Hands-On-Microservices-with-Spring-Boot-and-Spring-Cloud with MIT License 4 votes vote down vote up
@Before
public void setupDb() {
	input = (AbstractMessageChannel) channels.input();
	repository.deleteAll().block();
}
 
Example #22
Source File: AbstractMessageChannelBinder.java    From spring-cloud-stream with Apache License 2.0 4 votes vote down vote up
private void enhanceMessageChannel(MessageChannel inputChannel) {
	((AbstractMessageChannel) inputChannel).addInterceptor(0,
			this.embeddedHeadersChannelInterceptor);
}
 
Example #23
Source File: SqsInboundChannelAdapterParserTests.java    From spring-integration-aws with MIT License 4 votes vote down vote up
@Test
public void testSqsInboundChannelAdapterParser() throws Exception {

	setUp("SqsInboundChannelAdapterParserTests.xml", getClass(),
			"sqsInboundChannelAdapter");

	final AbstractMessageChannel outputChannel = TestUtils
			.getPropertyValue(this.consumer, "outputChannel",
					AbstractMessageChannel.class);

	assertEquals("out", outputChannel.getComponentName());

	final SqsExecutor sqsExecutor = TestUtils.getPropertyValue(
			this.consumer, "sqsExecutor", SqsExecutor.class);

	assertNotNull(sqsExecutor);

	final String queueNameProperty = TestUtils.getPropertyValue(
			sqsExecutor, "queueName", String.class);

	assertEquals("testQueue", queueNameProperty);

}
 
Example #24
Source File: SqsMessageHandlerParserTests.java    From spring-integration-aws with MIT License 4 votes vote down vote up
@Test
public void testSqsMessageHandlerParser() throws Exception {
	setUp("SqsMessageHandlerParserTests.xml", getClass());

	final AbstractMessageChannel inputChannel = TestUtils.getPropertyValue(
			this.consumer, "inputChannel", AbstractMessageChannel.class);

	assertEquals("target", inputChannel.getComponentName());

	final SqsExecutor sqsExecutor = TestUtils.getPropertyValue(
			this.consumer, "handler.sqsExecutor", SqsExecutor.class);

	assertNotNull(sqsExecutor);

	final String queueNameProperty = TestUtils.getPropertyValue(
			sqsExecutor, "queueName", String.class);

	assertEquals("testQueue", queueNameProperty);

}
 
Example #25
Source File: SnsMessageHandlerParserTests.java    From spring-integration-aws with MIT License 4 votes vote down vote up
@Test
public void testSnsMessageHandlerParser() throws Exception {
	context = new ClassPathXmlApplicationContext(
			"SnsMessageHandlerParserTests.xml", getClass());

	EventDrivenConsumer consumer = context.getBean(
			"snsOutboundChannelAdapter", EventDrivenConsumer.class);

	final AbstractMessageChannel inputChannel = TestUtils.getPropertyValue(
			consumer, "inputChannel", AbstractMessageChannel.class);

	assertEquals("target", inputChannel.getComponentName());

	final SnsExecutor snsExecutor = TestUtils.getPropertyValue(consumer,
			"handler.snsExecutor", SnsExecutor.class);

	assertNotNull(snsExecutor);

	final String topicNameProperty = TestUtils.getPropertyValue(
			snsExecutor, "topicName", String.class);

	assertEquals("testTopic", topicNameProperty);

}
 
Example #26
Source File: SnsInboundChannelAdapterParserTests.java    From spring-integration-aws with MIT License 4 votes vote down vote up
@Test
public void testSnsInboundChannelAdapterParser() throws Exception {

	setUp("SnsInboundChannelAdapterParserTests.xml", getClass(),
			"snsInboundChannelAdapter");

	final AbstractMessageChannel outputChannel = TestUtils
			.getPropertyValue(this.producer, "outputChannel",
					AbstractMessageChannel.class);

	assertEquals("out", outputChannel.getComponentName());

	final SnsExecutor snsExecutor = TestUtils.getPropertyValue(
			this.producer, "snsExecutor", SnsExecutor.class);

	assertNotNull(snsExecutor);

	final String topicNameProperty = TestUtils.getPropertyValue(
			snsExecutor, "topicName", String.class);

	assertEquals("testTopic", topicNameProperty);

}
 
Example #27
Source File: ReviewServiceApplicationTests.java    From Hands-On-Microservices-with-Spring-Boot-and-Spring-Cloud with MIT License 4 votes vote down vote up
@Before
public void setupDb() {
	input = (AbstractMessageChannel) channels.input();
	repository.deleteAll();
}
 
Example #28
Source File: ProductServiceApplicationTests.java    From Hands-On-Microservices-with-Spring-Boot-and-Spring-Cloud with MIT License 4 votes vote down vote up
@Before
public void setupDb() {
	input = (AbstractMessageChannel) channels.input();
	repository.deleteAll().block();
}
 
Example #29
Source File: RecommendationServiceApplicationTests.java    From Hands-On-Microservices-with-Spring-Boot-and-Spring-Cloud with MIT License 4 votes vote down vote up
@Before
public void setupDb() {
	input = (AbstractMessageChannel) channels.input();
	repository.deleteAll().block();
}
 
Example #30
Source File: ReviewServiceApplicationTests.java    From Hands-On-Microservices-with-Spring-Boot-and-Spring-Cloud with MIT License 4 votes vote down vote up
@Before
public void setupDb() {
	input = (AbstractMessageChannel) channels.input();
	repository.deleteAll();
}