Mule 3.3.0 POP3连接器配置不起作用

时间:2013-01-18 10:08:17

标签: mule

我正在尝试一个简单的Mule 3.3.0配置,它将下载每封电子邮件并将其传递给我的自定义处理器类。检索到电子邮件后,应将其从Gmail邮箱中删除。但这似乎并没有奏效。下面是我的mule-config.xml

<spring:beans>
    <spring:import resource="classpath:spring/applicationContextServices-core.xml"/>
    <spring:import resource="classpath:spring/applicationContextServices-configuration.xml"/>
    <spring:bean id="emailSender" name="emailSender" class="com.test.EmailSender"/>
    <spring:bean id="retrieveEmailProcessor" name="retrieveEmailProcessor" class="com.test.RetrieveEmailProcessor"/>
</spring:beans>


<jms:activemq-connector name="Active_MQ" specification="1.1" username="[username]" password="[password]" brokerURL="tcp://localhost:61616" validateConnections="true" doc:name="Active MQ">
    <reconnect/>
</jms:activemq-connector>

<pop3s:connector name="pop3Connector" checkFrequency="45600" deleteReadMessages="true"/>

<flow name="1_SendMessageToOwner" doc:name="1_SendMessageToOwner" doc:description="This is to confirm that your email was received successfully">
    <jms:inbound-endpoint topic="PoolMessage" connector-ref="Active_MQ" doc:name="JMS"/>
    <component doc:name="Build Email Message">
        <spring-object bean="emailSender"/>
    </component>
    <smtps:outbound-endpoint host="smtp.gmail.com" port="465" user="[username]%40gmail.com" password="[password]" from="[username]@gmail.com" responseTimeout="50000" doc:name="SMTP"/>
</flow>

<flow name="2_ReceiveConfirmation" doc:name="2_ReceiveConfirmation" doc:description="Retrieving Email">
    <pop3s:inbound-endpoint connector-ref="pop3Connector" host="pop.gmail.com" port="995" user="[username]%40gmail.com" password="[password]" responseTimeout="10000" doc:name="Pop3"/>
    <component doc:name="Process Transaction - Confirmation Message" doc:description="Recieve confirmation from member.">
        <spring-object bean="retrieveEmailProcessor"/>
    </component>
</flow>

</mule>

<spring:beans> <spring:import resource="classpath:spring/applicationContextServices-core.xml"/> <spring:import resource="classpath:spring/applicationContextServices-configuration.xml"/> <spring:bean id="emailSender" name="emailSender" class="com.test.EmailSender"/> <spring:bean id="retrieveEmailProcessor" name="retrieveEmailProcessor" class="com.test.RetrieveEmailProcessor"/> </spring:beans> <jms:activemq-connector name="Active_MQ" specification="1.1" username="[username]" password="[password]" brokerURL="tcp://localhost:61616" validateConnections="true" doc:name="Active MQ"> <reconnect/> </jms:activemq-connector> <pop3s:connector name="pop3Connector" checkFrequency="45600" deleteReadMessages="true"/> <flow name="1_SendMessageToOwner" doc:name="1_SendMessageToOwner" doc:description="This is to confirm that your email was received successfully"> <jms:inbound-endpoint topic="PoolMessage" connector-ref="Active_MQ" doc:name="JMS"/> <component doc:name="Build Email Message"> <spring-object bean="emailSender"/> </component> <smtps:outbound-endpoint host="smtp.gmail.com" port="465" user="[username]%40gmail.com" password="[password]" from="[username]@gmail.com" responseTimeout="50000" doc:name="SMTP"/> </flow> <flow name="2_ReceiveConfirmation" doc:name="2_ReceiveConfirmation" doc:description="Retrieving Email"> <pop3s:inbound-endpoint connector-ref="pop3Connector" host="pop.gmail.com" port="995" user="[username]%40gmail.com" password="[password]" responseTimeout="10000" doc:name="Pop3"/> <component doc:name="Process Transaction - Confirmation Message" doc:description="Recieve confirmation from member."> <spring-object bean="retrieveEmailProcessor"/> </component> </flow> </mule>

and the RetrieveEmailProcessor class

package com.test;

import java.util.Map;

import org.mule.api.MuleEventContext; import org.mule.api.lifecycle.Callable;

public class RetrieveEmailProcessor implements Callable {

public Object onCall(MuleEventContext eventContext) throws Exception { System.out.println("########## Entering RetrieveEmailProcessor.OnCall ##########"); Map dataMapMessage = (Map)eventContext.getMessage().getPayload(); String subject = (String)dataMapMessage.get("subject"); String toAddressList = (String)dataMapMessage.get("toAddressList"); String fromAddress = (String)dataMapMessage.get("fromAddress"); eventContext.getMessage().setOutboundProperty( "toAddresses", toAddressList); eventContext.getMessage().setOutboundProperty( "subject", subject); eventContext.getMessage().setOutboundProperty( "replyToAddresses", fromAddress); System.out.println("########## Exiting RetrieveEmailProcessor.OnCall ##########"); return dataMapMessage.get("mailBody"); }

public Object onCall(MuleEventContext eventContext) throws Exception { System.out.println("########## Entering RetrieveEmailProcessor.OnCall ##########"); Map dataMapMessage = (Map)eventContext.getMessage().getPayload(); String subject = (String)dataMapMessage.get("subject"); String toAddressList = (String)dataMapMessage.get("toAddressList"); String fromAddress = (String)dataMapMessage.get("fromAddress"); eventContext.getMessage().setOutboundProperty( "toAddresses", toAddressList); eventContext.getMessage().setOutboundProperty( "subject", subject); eventContext.getMessage().setOutboundProperty( "replyToAddresses", fromAddress); System.out.println("########## Exiting RetrieveEmailProcessor.OnCall ##########"); return dataMapMessage.get("mailBody"); }

有什么明显的遗漏吗? 提前致谢

1 个答案:

答案 0 :(得分:1)

你的骡子配置没问题。

您需要检查Gmail的配置:
设置 - &gt;转发和POP / IMAP - &gt;在POP下载中: - &gt; 2.使用POP

访问消息时

如果您希望在POP连接器读取邮件后将其删除或存档,则需要选择“删除Gmail的副本”。