简体   繁体   English

如何配置Spring Integration?

[英]How to configure Spring Integration?

I have spring-integration-config.xml 我有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: Configuation:

@Configuration
@ImportResource("classpath:spring-integration-config.xml")
public class PropertiesConfig {
}

And GmailWorker: 和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;
}
}

Now I don't use InputChannel bean. 现在,我不使用InputChannel bean。 But my application doesn't deployed on tomcat with logs: 但是我的应用程序没有部署到带有日志的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.

How to configure Spring Integration? 如何配置Spring Integration? And how use inputChannel in application? 以及如何在应用程序中使用inputChannel

Your POJO method looks bad for Spring Integration runtime method invocation engine. 您的POJO方法对于Spring Integration运行时方法调用引擎来说看起来很糟糕。

Any Spring Integration component gets deal with Message object, which has headers and payload properties. 任何Spring Integration组件都会处理Message对象,该对象具有headerspayload属性。

When it invokes the POJO method it expects some restricted set of arguments on the method: 当它调用POJO方法时,期望在该方法上使用一些受限制的参数集:

  • Whole Message 整个Message
  • any other type which may be treated as payload , if there is some appropriate converter on the matter. 如果有适当的converter ,则可以将其视为payload任何其他类型。
  • @Header as the request for some header in the MessageHeaders @Header作为对MessageHeaders某些标头的请求
  • Map<String, Object> as whole set of MessageHeaders` Map<String, Object> as whole set of MessageHeaders的Map<String, Object> as whole set of
  • If you want get deal with payload and some headers you can mark params with @Payload , @Headers etc.. 如果要处理payload和某些标头,则可以使用@Payload@Headers等标记参数。

More info is here . 更多信息在这里

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM