我有spring-integration-config.xml
<?xml version="1.0" encoding="UTF-8"?>
<beans:beans xmlns="http://www.springframework.org/schema/integration" //etc. >
<channel id="inputChannel"/>
<channel id="outputChannel">
<queue capacity="10"/>
</channel>
<service-activator input-channel="inputChannel"
output-channel="outputChannel"
ref="gmailWorker"
method="getGmailMessage"/>
<beans:bean id="gmailWorker" class="GmailWorker"/>
Configuation:
@Configuration
@ImportResource("classpath:spring-integration-config.xml")
public class PropertiesConfig {
}
和GmailWorker:
public class GmailWorker{
public static Message getGmailMessage(Gmail service,String messageId) throws IOException {
Message gmailMessage = service.users().messages().get("me", messageId).execute();
return gmailMessage;
}
}
现在我不使用InputChannel bean。但我的应用程序没有部署在带有日志的tomcat上:
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.springframework.integration.config.ConsumerEndpointFactoryBean#0':
Cannot resolve reference to bean 'org.springframework.integration.config.ServiceActivatorFactoryBean#0' while setting bean property 'handler';
nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.springframework.integration.config.ServiceActivatorFactoryBean#0':
FactoryBean threw exception on object creation; nested exception is java.lang.IllegalArgumentException:
Target object of type [class GmailWorker] has no eligible methods for handling Messages.
如何配置Spring Integration?如何在应用程序中使用inputChannel
?
答案 0 :(得分:1)
对于Spring Integration运行时方法调用引擎,您的POJO方法看起来很糟糕。
任何Spring Integration组件都会处理Message
对象,该对象具有headers
和payload
属性。
当它调用POJO方法时,它需要在方法上设置一些受限制的参数:
Message
payload
的类型,如果此问题有适当的converter
。@Header
作为MessageHeaders
Map<String, Object> as whole set of
MessageHeaders` payload
和某些标题进行交易,可以使用@Payload
,@Headers
等标记参数。更多信息是here。