首页 文章

Mule ESB IMAP问题

提问于
浏览
1

目前,我们需要使用Mule ESB从IMAP服务器获取邮件 . 一旦提取了邮件,我们只需要附件并将它们保存在硬盘上 . 到现在为止还挺好 . 现在我有几个问题:

  • 如何使用文件保持原始名称的完整性:outbound-endpoint?

  • 如何查看我收到的附件数量?

  • 如何在IMAP和本地驱动器上保存邮件副本?

@ 1:我试过#header:fileName或#originalFileName甚至删除了outputpattern(这导致文件名为“35c7dea0-519a-11e1-b8b2-092b658ae008.dat”)

@ 2:我正试图制作一个流程,在那里检查有多少附件 . 如果少于1,那么我想保存文件,不再进一步处理它们 . 如果它超过1,则保存并处理它 . 我尝试了COUNT但它没有用 .

@ 3:我正在尝试在READ到IMAP服务器上的备份文件夹时传送消息 . 最重要的是,我将在本地服务器上保存一份副本 . 问题是,使用当前代码,消息不会被标记为已读或已移动 . 消息保持未读状态并被复制(一遍又一遍,enldess循环),而不是被移动到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>

1 回答

  • 0

    1)如何使用文件保持原始名称的完整性:outbound-endpoint?

    附件是javax.activation.DataHandler实例,因此您应该能够使用OGNL或Groovy表达式对它们调用getName() . 例如:

    #[groovy:payload.name]
    

    应该给你原始的附件名称 .

    2)我如何查看我收到了多少附件?

    在拆分器之前,使用choice路由器和检查附件列表的size()属性的条件,如:

    #[groovy:payload.size()>1]
    

    3)如何在IMAP和本地驱动器上保存邮件副本?

    我不知道这里的问题是什么 . 也许不支持标记为看到 . 或者,您可能禁用传输变压器会阻止后读取操作 .

    顺便提一下,我建议您保留默认的传输变换器,并在分路器之前的入站 endpoints 之后移动returnAttachments变换器 .

相关问题