使用DataWeave的mime类型无效

时间:2015-10-13 17:06:29

标签: xml mule ibm-mq dataweave

我试图在Mule ESB(企业版)中创建一个流,该流从WMQ 7.5(xml有效负载)中的队列接收消息,然后使用DataWeave(为此我的目的,将其转换为新的xml文件)这与旧的相同,然后将其放回另一个队列。我的流程如下:

<?xml version="1.0" encoding="UTF-8"?>

<mule xmlns:mulexml="http://www.mulesoft.org/schema/mule/xml" xmlns:metadata="http://www.mulesoft.org/schema/mule/metadata" xmlns:dw="http://www.mulesoft.org/schema/mule/ee/dw" xmlns:wmq="http://www.mulesoft.org/schema/mule/ee/wmq" xmlns="http://www.mulesoft.org/schema/mule/core" xmlns:doc="http://www.mulesoft.org/schema/mule/documentation"
    xmlns:spring="http://www.springframework.org/schema/beans" 
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-current.xsd
http://www.mulesoft.org/schema/mule/core http://www.mulesoft.org/schema/mule/core/current/mule.xsd
http://www.mulesoft.org/schema/mule/ee/wmq http://www.mulesoft.org/schema/mule/ee/wmq/current/mule-wmq-ee.xsd
http://www.mulesoft.org/schema/mule/ee/dw http://www.mulesoft.org/schema/mule/ee/dw/current/dw.xsd
http://www.mulesoft.org/schema/mule/xml http://www.mulesoft.org/schema/mule/xml/current/mule-xml.xsd">
    <wmq:connector (MQ configuration is here, it is not the problem) />
    <flow name="dataweaveFlow">
        <wmq:inbound-endpoint queue="I0" connector-ref="WMQ" doc:name="WMQ">
            <wmq:transaction action="ALWAYS_BEGIN"/>
        </wmq:inbound-endpoint>
        <set-variable variableName="MULE_REPLYTO_STOP" value="true" doc:name="Variable"/>
        <dw:transform-message doc:name="Transform Message">
            <dw:input-payload doc:sample="empty_1.xml"/>
            <dw:set-payload><![CDATA[%dw 1.0
%input payload application/xml
%output application/xml
---
payload]]></dw:set-payload>
        </dw:transform-message>

        <wmq:outbound-endpoint queue="O0" connector-ref="WMQ" doc:name="WMQ">
            <wmq:transaction action="ALWAYS_JOIN"/>
        </wmq:outbound-endpoint>
    </flow>
</mule>

我的DataWeave配置如下所示: 输入:

<?xml version='1.0' encoding='windows-1252'?>
<empty/>

转型:

  %dw 1.0
%input payload application/xml
%output application/xml
---
payload

现在,当我运行此流程并在队列中放入消息时,Mule无法处理消息并不断抛出异常,并说:&#34;无效的mime类型application / xml&#34;,无效的mime类型application / xml(com.mulesoft.weave.mule.exception.InvalidMimeTypeException)com.mulesoft.weave.mule.WeaveMessageProcessor:165(null)2。无效的mime类型application / xml(com) .mulesoft.weave.mule.exception.InvalidMimeTypeException)。消息有效内容的类型为:String(org.mule.api.MessagingException)org.mule.execution.ExceptionToMessagingExceptionExecutionInterceptor:32(http://www.mulesoft.org/docs/site/current3/apidocs/org/mule/api/MessagingException.html

无论如何,我对Mule(当然还有DataWeave)还是比较陌生的,感谢帮助!如果需要更多细节,请告诉我。

6 个答案:

答案 0 :(得分:1)

经过Mule支持与我之间的长时间对话,这被发现是一个错误。截至我的机票,目前正由工程团队负责。当您的主流处理策略设置为synchronous而不是queued asynchronous时,会发生这种情况。

尝试通过单击主流并将处理策略专门设置为queued asynchronous来对此进行测试。

请注意,您将无法使用queued asynchronous处理策略使用WMQ事务性,因此我对此错误感到沮丧。

答案 1 :(得分:1)

在报告错误后,发现 WMQ DataWeave 同步处理策略的组合正在抛出这个奇怪的异常。补丁已经可用,它将在未来版本的ESB上修复,但现在您可以联系支持部门并询问 SE-3167 。 祝你好运!

答案 2 :(得分:0)

在Dataweave之前将Transformer对象添加到XML,这会将Message转换为正确的格式。

答案 3 :(得分:0)

如果从输入源获取XML,首先要假设WMQ连接器转到并将MIME类型设置为application/xml。 要将MIME类型设置为application/xml,请右键单击WMQ连接器,然后单击“高级”并设置MIME类型:application/xml

您正在返回%output application/xml,因此我建议您在数据编组后使用DOM to XML Transformer。我认为它会起作用。

答案 4 :(得分:0)

这个问题相当模糊,我找到的解决方案更加奇怪。 我只是添加一个&#34; Object to String&#34;我的Data Weaver /转换消息之后,以及我的WMQ outbound-endpoint之前的变换器,它工作正常。问题是Data Weaver提供了&#34; com.mulesoft.weave.mule.WeaveMessageProcessor $ WeaveOutputHandler&#34;的输出。 始终

请尝试此修复程序......我非常确定它能够正常运行。

答案 5 :(得分:0)

如前所述,未使用%input指令。它将从Studio自动完成中删除。

强制DataWeave使用阅读器的方法是使用mimeType属性,或者正如您提到的set-property,因为这将强制Mule消息具有MimeType