4

春の統合メールメカニズムを使用しようとしています。このリンクを参照に使用しました: http://blog.solidcraft.eu/2011/04/read-emails-from-imap-with-spring.html

残念ながら、サーバーの起動時にエラーメッセージが表示されます:

Caused by: java.lang.IllegalArgumentException: Target object of type [class src.com.project.myEmailReciever] has no eligible methods for handling Messages.
at org.springframework.util.Assert.notEmpty(Assert.java:294)
at org.springframework.integration.util.MessagingMethodInvokerHelper.findHandlerMethodsForTarget(MessagingMethodInvokerHelper.java:348)
at org.springframework.integration.util.MessagingMethodInvokerHelper.<init>(MessagingMethodInvokerHelper.java:165)
at org.springframework.integration.util.MessagingMethodInvokerHelper.<init>(MessagingMethodInvokerHelper.java:103)
at org.springframework.integration.util.MessagingMethodInvokerHelper.<init>(MessagingMethodInvokerHelper.java:107)
at org.springframework.integration.handler.MethodInvokingMessageProcessor.<init>(MethodInvokingMessageProcessor.java:48)
at org.springframework.integration.handler.ServiceActivatingHandler.<init>(ServiceActivatingHandler.java:42)
at org.springframework.integration.config.ServiceActivatorFactoryBean.createMethodInvokingHandler(ServiceActivatorFactoryBean.java:48)
at org.springframework.integration.config.AbstractStandardMessageHandlerFactoryBean.createHandler(AbstractStandardMessageHandlerFactoryBean.java:72)
at org.springframework.integration.config.AbstractSimpleMessageHandlerFactoryBean.createHandlerInternal(AbstractSimpleMessageHandlerFactoryBean.java:89)
at org.springframework.integration.config.AbstractSimpleMessageHandlerFactoryBean.getObject(AbstractSimpleMessageHandlerFactoryBean.java:68)
at org.springframework.integration.config.AbstractSimpleMessageHandlerFactoryBean.getObject(AbstractSimpleMessageHandlerFactoryBean.java:31)
at org.springframework.beans.factory.support.FactoryBeanRegistrySupport.doGetObjectFromFactoryBean(FactoryBeanRegistrySupport.java:142)
... 30 more

どうやら私の受信クラスの関数:

public void receive(MimeMessage mimeMessage) {

//doSomthing
   }

メールを処理する資格がありません..これを解決する方法を知っている人はいますか?

ここで編集するのは私のclasses\ xmlです:

@Component
@Scope("prototype")
public class MessageFactory {

@Autowired
private ApplicationContext ctx;

private static final Logger logger = LoggerFactory.getLogger(MessageFactory.class);

ObjectMapper mapper = new ObjectMapper();


public boolean receive(MimeMessage mimeMessage) {

    System.out.println("try");
    return true;
   }
}

xml:

  <?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
   xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
   xmlns:mail="http://www.springframework.org/schema/integration/mail"
   xmlns:int="http://www.springframework.org/schema/integration"
   xmlns:util="http://www.springframework.org/schema/util"
   xsi:schemaLocation="http://www.springframework.org/schema/beans
        http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
        http://www.springframework.org/schema/integration/mail
        http://www.springframework.org/schema/integration/mail/spring-integration-mail-2.0.xsd http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util-2.0.xsd">

<util:properties id="javaMailProperties">
    <prop key="mail.imap.socketFactory.class">javax.net.ssl.SSLSocketFactory</prop>
    <prop key="mail.imap.socketFactory.fallback">false</prop>
    <prop key="mail.store.protocol">imaps</prop>
    <prop key="mail.debug">true</prop>
</util:properties>

<mail:inbound-channel-adapter id="imapAdapter"
                                  store-uri="imaps://username:password@imap.googlemail.com:993/INBOX"                                    
                                  channel="recieveEmailChannel"                                         
                                  should-delete-messages="false"
                                  should-mark-messages-as-read="true"                                     
                                  auto-startup="true"

                                  java-mail-properties="javaMailProperties">

    <int:poller fixed-delay="5" time-unit="SECONDS" />
</mail:inbound-channel-adapter>

<int:channel id="recieveEmailChannel">       
    <int:interceptors>
        <int:wire-tap channel="logger"/>
    </int:interceptors>
</int:channel>

<int:logging-channel-adapter id="logger" level="DEBUG"/>

<int:service-activator input-channel="recieveEmailChannel" ref="messageFactory" method="receive"/>

<bean id="messageFactory" class="src.com.project.service.factories.MessageFactory">
</bean>

4

2 に答える 2

9

このエラーは通常、構成の問題です。

それを引き起こす可能性のある条件は次のとおりです...

  • 構成内のスペルミスmethodのある属性<service-activator/>
  • メソッドは公開されていません
  • requires-reply="true"メソッドは void を返します(あなたのように)
于 2013-07-20T13:18:54.873 に答える
0

Spring Integration 2.2.4 を使用していますが、この問題が発生していました。Spring Integration の一部のバージョンでは @Header が機能しないという別の投稿を見ました。残念ながら、現在はアップグレードできません。したがって、選択肢は @Headers を使用するか、式を使用するかでした。私は式を使用しましたが、それは私のために働いています...

<service-activator expression="@myService.serviceMethod(headers.customerKey, payload)"/>
于 2014-08-26T14:05:25.670 に答える