List of usage examples for org.springframework.integration.config ConsumerEndpointFactoryBean ConsumerEndpointFactoryBean
ConsumerEndpointFactoryBean
From source file:com.apress.prospringintegration.endpoints.consumerendpointfactory.ConsumerEndpointConfiguration.java
@Bean public ConsumerEndpointFactoryBean consumerEndpoint() { ConsumerEndpointFactoryBean factoryBean = new ConsumerEndpointFactoryBean(); factoryBean.setInputChannel(inputChannel); factoryBean.setHandler(handler);//www . j a v a 2 s. c o m // Need to set pollerMetadata for polling consumer //factoryBean.setPollerMetadata(pollerMetadata); return factoryBean; }
From source file:com.apress.prospringintegration.customadapters.inbound.IntegrationTestUtils.java
public AbstractEndpoint createConsumer(MessageChannel messageChannel, MessageHandler messageHandler) throws Throwable { ConsumerEndpointFactoryBean consumerEndpointFactoryBean = new ConsumerEndpointFactoryBean(); consumerEndpointFactoryBean.setInputChannel(messageChannel); consumerEndpointFactoryBean.setBeanName("MessageConsumer"); consumerEndpointFactoryBean.setBeanFactory(beanFactory); consumerEndpointFactoryBean.setHandler(messageHandler); consumerEndpointFactoryBean.setBeanClassLoader(ClassLoader.getSystemClassLoader()); consumerEndpointFactoryBean.afterPropertiesSet(); AbstractEndpoint abstractEndpoint = consumerEndpointFactoryBean.getObject(); abstractEndpoint.start();//ww w .j a v a 2 s .c om return abstractEndpoint; }
From source file:org.springframework.xd.module.CompositeModule.java
@Override public void initialize() { List<AbstractEndpoint> endpoints = new ArrayList<AbstractEndpoint>(); MessageChannel previousOutputChannel = null; for (int i = 0; i < this.modules.size(); i++) { SimpleModule module = this.modules.get(i); module.initialize();/* w w w . jav a 2s . co m*/ MessageChannel inputChannel = module.getComponent("input", MessageChannel.class); MessageChannel outputChannel = module.getComponent("output", MessageChannel.class); if (i == 0 && inputChannel != null) { // this will act as THE input for the composite module // if the first module has no input, the composite is a source this.context.getBeanFactory().registerSingleton("input", inputChannel); } if (i > 0) { // first module MAY have 'input', all others MUST Assert.notNull(inputChannel, "each module after the first must provide 'input'"); } if (previousOutputChannel != null) { BridgeHandler handler = new BridgeHandler(); handler.setOutputChannel(inputChannel); handler.afterPropertiesSet(); ConsumerEndpointFactoryBean bridgeFactoryBean = new ConsumerEndpointFactoryBean(); bridgeFactoryBean.setInputChannel(previousOutputChannel); bridgeFactoryBean.setHandler(handler); try { // TODO: might not be necessary to pass this context, but the FB requires non-null bridgeFactoryBean.setBeanFactory(this.context.getBeanFactory()); bridgeFactoryBean.afterPropertiesSet(); AbstractEndpoint endpoint = bridgeFactoryBean.getObject(); endpoints.add(endpoint); this.context.getBeanFactory().registerSingleton("bridge-" + i, endpoint); } catch (Exception e) { throw new IllegalStateException("failed to start bridge for CompositeModule", e); } } if (i < this.modules.size() - 1) { // last module MAY have 'output', all others MUST Assert.notNull(outputChannel, "each module before the last must provide 'output'"); } previousOutputChannel = outputChannel; if (i == this.modules.size() - 1 && outputChannel != null) { // this will act as THE output for the composite module // if the final module has no outputChannel, the composite is a sink this.context.getBeanFactory().registerSingleton("output", outputChannel); } } for (int i = endpoints.size() - 1; i >= 0; i--) { endpoints.get(i).start(); } initContext(); if (logger.isInfoEnabled()) { logger.info("initialized module: " + this.toString()); } }
From source file:org.springframework.xd.module.core.CompositeModule.java
@Override public void initialize() { List<AbstractEndpoint> endpoints = new ArrayList<AbstractEndpoint>(); MessageChannel previousOutputChannel = null; for (int i = 0; i < this.modules.size(); i++) { Module module = this.modules.get(i); module.initialize();//from w w w . j ava 2s . co m MessageChannel inputChannel = module.getComponent("input", MessageChannel.class); MessageChannel outputChannel = module.getComponent("output", MessageChannel.class); if (i == 0 && inputChannel != null) { // this will act as THE input for the composite module // if the first module has no input, the composite is a source this.context.getBeanFactory().registerSingleton("input", inputChannel); } if (i > 0) { // first module MAY have 'input', all others MUST Assert.notNull(inputChannel, "each module after the first must provide 'input'"); } if (previousOutputChannel != null) { BridgeHandler handler = new BridgeHandler(); handler.setBeanFactory(this.context.getBeanFactory()); handler.setOutputChannel(inputChannel); handler.afterPropertiesSet(); ConsumerEndpointFactoryBean bridgeFactoryBean = new ConsumerEndpointFactoryBean(); bridgeFactoryBean.setInputChannel(previousOutputChannel); bridgeFactoryBean.setHandler(handler); try { // TODO: might not be necessary to pass this context, but the FB requires non-null bridgeFactoryBean.setBeanFactory(this.context.getBeanFactory()); bridgeFactoryBean.afterPropertiesSet(); AbstractEndpoint endpoint = bridgeFactoryBean.getObject(); endpoints.add(endpoint); this.context.getBeanFactory().registerSingleton("bridge-" + i, endpoint); endpoint.setComponentName("bridge-" + i); endpoint.afterPropertiesSet(); } catch (Exception e) { throw new IllegalStateException("failed to start bridge for CompositeModule", e); } } if (i < this.modules.size() - 1) { // last module MAY have 'output', all others MUST Assert.notNull(outputChannel, "each module before the last must provide 'output'"); } previousOutputChannel = outputChannel; if (i == this.modules.size() - 1 && outputChannel != null) { // this will act as THE output for the composite module // if the final module has no outputChannel, the composite is a sink this.context.getBeanFactory().registerSingleton("output", outputChannel); } } for (int i = endpoints.size() - 1; i >= 0; i--) { endpoints.get(i).start(); } initContext(); if (logger.isInfoEnabled()) { logger.info("initialized module: " + this.toString()); } }