org.springframework.integration.endpoint.EventDrivenConsumer Java Examples

The following examples show how to use org.springframework.integration.endpoint.EventDrivenConsumer. 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: ConsulBinder.java    From spring-cloud-consul with Apache License 2.0 6 votes vote down vote up
@Override
protected Binding<MessageChannel> doBindProducer(String name, MessageChannel channel,
		ProducerProperties properties) {
	Assert.isInstanceOf(SubscribableChannel.class, channel);

	this.logger.debug("Binding Consul client to eventName " + name);
	ConsulSendingHandler sendingHandler = new ConsulSendingHandler(
			this.eventService.getConsulClient(), name);

	EventDrivenConsumer consumer = new EventDrivenConsumer(
			(SubscribableChannel) channel, sendingHandler);
	consumer.setBeanFactory(getBeanFactory());
	consumer.setBeanName(String.format(BEAN_NAME_TEMPLATE, name));
	consumer.afterPropertiesSet();
	consumer.start();

	return new DefaultBinding<>(name, null, channel, consumer);
}
 
Example #2
Source File: SqsPermissionsParserTests.java    From spring-integration-aws with MIT License 6 votes vote down vote up
@Test
public void outboundPermissions() {
	EventDrivenConsumer consumer = context.getBean("sqs-outbound",
			EventDrivenConsumer.class);
	assertThat(consumer, is(notNullValue()));

	final SqsExecutor executor = TestUtils.getPropertyValue(consumer,
			"handler.sqsExecutor", SqsExecutor.class);
	assertThat(executor, is(notNullValue()));

	@SuppressWarnings("unchecked")
	Set<Permission> permissions = (Set<Permission>) TestUtils
			.getPropertyValue(executor, "permissions");
	assertThat("permissions is not null", permissions, is(notNullValue()));
	assertThat("all permissions loaded", permissions.size(), is(equalTo(1)));
}
 
Example #3
Source File: SqsPermissionsParserTests.java    From spring-integration-aws with MIT License 6 votes vote down vote up
@Test
public void outboundGatewayPermissions() {
	EventDrivenConsumer consumer = context.getBean("sqs-gateway",
			EventDrivenConsumer.class);
	assertThat(consumer, is(notNullValue()));

	final SqsExecutor executor = TestUtils.getPropertyValue(consumer,
			"handler.sqsExecutor", SqsExecutor.class);
	assertThat(executor, is(notNullValue()));

	@SuppressWarnings("unchecked")
	Set<Permission> permissions = (Set<Permission>) TestUtils
			.getPropertyValue(executor, "permissions");
	assertThat("permissions is not null", permissions, is(notNullValue()));
	assertThat("all permissions loaded", permissions.size(), is(equalTo(1)));
}
 
Example #4
Source File: SnsPermissionsParserTests.java    From spring-integration-aws with MIT License 6 votes vote down vote up
@Test
public void outboundPermissions() {
	EventDrivenConsumer consumer = context.getBean("sns-outbound",
			EventDrivenConsumer.class);
	assertThat(consumer, is(notNullValue()));

	final SnsExecutor executor = TestUtils.getPropertyValue(consumer,
			"handler.snsExecutor", SnsExecutor.class);
	assertThat("snsExecutor is not null", executor, is(notNullValue()));

	@SuppressWarnings("unchecked")
	Set<Permission> permissions = (Set<Permission>) TestUtils
			.getPropertyValue(executor, "permissions");
	assertThat("permissions is not null", permissions, is(notNullValue()));
	assertThat("all permissions loaded", permissions.size(), is(equalTo(1)));
}
 
Example #5
Source File: SnsPermissionsParserTests.java    From spring-integration-aws with MIT License 6 votes vote down vote up
@Test
public void outboundGatewayPermissions() {
	EventDrivenConsumer consumer = context.getBean("sns-gateway",
			EventDrivenConsumer.class);
	assertThat(consumer, is(notNullValue()));

	final SnsExecutor executor = TestUtils.getPropertyValue(consumer,
			"handler.snsExecutor", SnsExecutor.class);
	assertThat("snsExecutor is not null", executor, is(notNullValue()));

	@SuppressWarnings("unchecked")
	Set<Permission> permissions = (Set<Permission>) TestUtils
			.getPropertyValue(executor, "permissions");
	assertThat("permissions is not null", permissions, is(notNullValue()));
	assertThat("all permissions loaded", permissions.size(), is(equalTo(1)));
}
 
Example #6
Source File: SpringIntegrationConfig.java    From bearchoke with Apache License 2.0 5 votes vote down vote up
/**
 * Default endpoint
 * @return
 */
@Bean(destroyMethod = "stop")
public EventDrivenConsumer eventDrivenConsumer() {
    EventDrivenConsumer consumer = new EventDrivenConsumer(defaultInputChannel(), loggingHandler());
    consumer.setAutoStartup(true);

    return consumer;
}
 
Example #7
Source File: SqsMessageMarshallerTests.java    From spring-integration-aws with MIT License 5 votes vote down vote up
@Test
public void outboundAdapterConfig() {

	final EventDrivenConsumer consumer = context.getBean("sqsOutbound",
			EventDrivenConsumer.class);
	checkMessageMarshallerRef(getSqsExecutor(consumer,
			"handler.sqsExecutor"));
}
 
Example #8
Source File: SqsMessageMarshallerTests.java    From spring-integration-aws with MIT License 5 votes vote down vote up
@Test
public void outboundGatewayConfig() {

	final EventDrivenConsumer consumer = context.getBean("sqsGateway",
			EventDrivenConsumer.class);
	checkMessageMarshallerRef(getSqsExecutor(consumer,
			"handler.sqsExecutor"));
}
 
Example #9
Source File: SnsMessageMarshallerTests.java    From spring-integration-aws with MIT License 5 votes vote down vote up
@Test
public void outboundAdapterConfig() {

	final EventDrivenConsumer consumer = context.getBean("snsOutbound",
			EventDrivenConsumer.class);
	checkMessageMarshallerRef(getSnsExecutor(consumer,
			"handler.snsExecutor"));
}
 
Example #10
Source File: SnsMessageMarshallerTests.java    From spring-integration-aws with MIT License 5 votes vote down vote up
@Test
public void outboundGatewayConfig() {

	final EventDrivenConsumer consumer = context.getBean("snsGateway",
			EventDrivenConsumer.class);
	checkMessageMarshallerRef(getSnsExecutor(consumer,
			"handler.snsExecutor"));
}
 
Example #11
Source File: SqsMessageHandlerParserTests.java    From spring-integration-aws with MIT License 4 votes vote down vote up
public void setUp(String name, Class<?> cls) {
	context = new ClassPathXmlApplicationContext(name, cls);
	consumer = this.context.getBean("sqsOutboundChannelAdapter",
			EventDrivenConsumer.class);
	messageMarshaller = new JsonMessageMarshaller();
}
 
Example #12
Source File: SqsOutboundGatewayParserTests.java    From spring-integration-aws with MIT License 4 votes vote down vote up
public void setUp(String name, Class<?> cls, String gatewayId) {
	context = new ClassPathXmlApplicationContext(name, cls);
	consumer = this.context.getBean(gatewayId, EventDrivenConsumer.class);
}
 
Example #13
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 #14
Source File: SnsOutboundGatewayParserTests.java    From spring-integration-aws with MIT License 4 votes vote down vote up
public void setUp(String name, Class<?> cls, String gatewayId) {
	context = new ClassPathXmlApplicationContext(name, cls);
	consumer = this.context.getBean(gatewayId, EventDrivenConsumer.class);
}