目前我们需要使用Mule ESB从IMAP服务器获取邮件。一旦邮件被提取,我们只需要附件并将它们保存在硬盘上。到现在为止还挺好。现在我遇到了几个问题:Mule ESB IMAP问题
- 如何使用文件保持原始名称不变:outbound-endpoint?
- 如何检查我获得的附件数量?
- 如何将邮件副本保存在IMAP和本地驱动器上?
@ 1:我尝试的#header:文件名或#originalFileName或甚至除去outputpattern(这导致在文件名是 “35c7dea0-519a-11e1的-b8b2-092b658ae008.dat”)
@ 2 :我正在尝试做一个流程,检查有多少附件。如果少于1,那么我想保存这些文件,不再进一步处理它们。如果它超过1,则保存并处理它。我试过COUNT,但没有奏效。
@ 3:正在尝试在读取到IMAP服务器上的备份文件夹时移动消息。最重要的是,我将在本地服务器上保存一份副本。问题是,对于当前的代码,消息不会被标记为已读或移动。消息保持未读状态,并且它们被复制(反复,循环)而不是移动到IMAP备份文件夹。当启用deleteReadMessages时,循环被打破,但消息不会被复制到IMAP上。
这里是我目前使用的代码:
<?xml version="1.0" encoding="UTF-8"?>
<mule xmlns="http://www.mulesoft.org/schema/mule/core"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:spring="http://www.springframework.org/schema/beans"
xmlns:imap="http://www.mulesoft.org/schema/mule/imap"
xmlns:file="http://www.mulesoft.org/schema/mule/file"
xmlns:email="http://www.mulesoft.org/schema/mule/email"
xmlns:vm="http://www.mulesoft.org/schema/mule/vm"
xsi:schemaLocation="
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
http://www.mulesoft.org/schema/mule/core http://www.mulesoft.org/schema/mule/core/3.2/mule.xsd
http://www.mulesoft.org/schema/mule/file http://www.mulesoft.org/schema/mule/file/3.2/mule-file.xsd
http://www.mulesoft.org/schema/mule/imap http://www.mulesoft.org/schema/mule/imap/3.2/mule-imap.xsd
http://www.mulesoft.org/schema/mule/email http://www.mulesoft.org/schema/mule/email/3.2/mule-email.xsd
http://www.mulesoft.org/schema/mule/vm http://www.mulesoft.org/schema/mule/vm/3.2/mule-vm.xsd">
<imap:connector name="imapConnector" checkFrequency="5000"
backupEnabled="true" backupFolder="/home/mark/workspace/Eclipse/RHZ_Project/src/Archive/"
mailboxFolder="INBOX" moveToFolder="INBOX.Backup" deleteReadMessages="false"
defaultProcessMessageAction="SEEN" />
<expression-transformer name="returnAttachments">
<return-argument evaluator="attachments-list" expression="*.txt,*.ozb,*.xml" optional="false"/>
</expression-transformer>
<flow name="Flow1_IMAP_fetch">
<imap:inbound-endpoint user="USER" password="PASS" host="IP"
port="143" transformer-refs="returnAttachments" disableTransportTransformer="true"/>
<collection-splitter/>
<file:outbound-endpoint path="/home/mark/workspace/Eclipse/RHZ_Project/src/Inbox/#[function:datestamp].dat">
<expression-transformer>
<return-argument expression="payload.inputStream" evaluator="groovy" />
</expression-transformer>
</file:outbound-endpoint>
</flow>
</mule>
嗯...... groovy:payload.name在路径中工作,但不在outputPattern中。它将其视为纯文本,因此在使用file:outbound-endpoint时命名文件#[groovy:payload.name]。它在outputPattern之前的记录器1行中工作正常。 – user1132229 2012-02-09 10:52:54
没关系,通过将文件名放入与message-properties-transform的会话中来获得它。这个名字仍然很奇怪。关于IMAP邮件服务器的事情,我对此表示怀疑。我试着改变设置,但没有运气。我们使用的测试服务器是Cyrus IMAP v2.3.13服务器。 – user1132229 2012-02-09 12:44:18
Ow也是一个新问题,我在进站后立即将有效载荷存储在会话中。那么如何从有效载荷中获取消息呢?记录器显示它,但是当它放在一个文件中时,它显示了类型等。这是用于记录原始消息的错误部分。 – user1132229 2012-02-09 14:26:15