Mule ESB IMAP问题 [英] Mule ESB IMAP questions

查看:58
本文介绍了Mule ESB IMAP问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当前,我们需要使用Mule ESB从IMAP服务器获取邮件.提取邮件后,我们仅需要附件并将其保存在硬盘驱动器上.到目前为止,一切都很好.现在我有几个问题:

Currently we need fetch mails from an IMAP server using Mule ESB. Once the mails have been fetched, we only need the attachments and save them on the harddrive. So far so good. Now I got a couple of questions:

  1. 如何使用file:outbound-endpoint保持原始名称完整?
  2. 如何检查我收到了多少个附件?
  3. 如何在IMAP和本地驱动器上保存邮件副本?

@ 1:我尝试使用#header:fileName或#originalFileName甚至删除了输出模式(这导致文件名为"35c7dea0-519a-11e1-b8b2-092b658ae008.dat")

@1: I tried #header:fileName or #originalFileName or even removing the outputpattern (this results in the filename being "35c7dea0-519a-11e1-b8b2-092b658ae008.dat")

@ 2:我正在尝试进行检查其中有多少个附件的流程.如果少于1,则我要保存文件,不再对其进行进一步处理.如果大于1,则保存并处理.我尝试了COUNT,但没有成功.

@2: I am trying to make a flow where I check how many attachments there are. If there are less then 1 then I want to save the files and no further process them. If it's more then 1, then save it and process it. I tried COUNT but it didn't work.

@ 3:在读取到IMAP服务器上的备份文件夹时,正在尝试移动消息.最重要的是,我会将副本保存在本地服务器上.问题在于,使用当前代码,消息不会被标记为已读或已移动.邮件保持未读状态,并且被复制(一遍又一遍,enldess循环),而不是移到IMAP备份文件夹中.启用deleteReadMessages时,循环会中断,但消息不会在IMAP上复制.

@3: am trying to MOVE a message when READ to a back-up folder on the IMAP-server. On top of that I'll save a copy on the local server. Problem is that with the current code, the message does not get marked as read nor moved. The messages stay unread and they get copied (over and over, enldess loop) instead of getting moved to the IMAP back-up folder. When enabling the deleteReadMessages then the loop is broken but the message does not get copied on the IMAP.

这是我当前正在使用的代码:

Here's the code I am currently using:

<?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)如何使用file:outbound-endpoint保留原始名称?

1) How do I keep the original name intact using a file:outbound-endpoint?

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

Attachments are javax.activation.DataHandler instances so you should be able to call getName() on them, with an OGNL or Groovy expression. For example:

#[groovy:payload.name]

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

Should give you the original attachment name.

2)如何检查我有多少个附件?

2) How can I check how many attachments I got?

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

Before the splitter, use a choice router and an condition that checks the size() attribute of the attachment list, like:

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

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

3) How do save a copy of the mail on the IMAP and local drive?

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

I do not know what the issue is here. Maybe marking as seen is not supported. Or maybe the fact that you disable the transport transformer prevents a post-read action to kick in.

顺便说一句,我建议您保持默认的传输转换器不变,并将returnAttachments转换器移动到入站端点之后,拆分器之前.

By the way, I suggest you leave the default transport transformer as-is and move the returnAttachments transformer after the inbound endpoint, before the splitter.

这篇关于Mule ESB IMAP问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆