0
votes

Here's the my mule app xml config

 <mule xmlns="http://www.mulesoft.org/schema/mule/core" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:doc="http://www.mulesoft.org/schema/mule/documentation" 
xmlns:spring="http://www.springframework.org/schema/beans"
xmlns:quartz="http://www.mulesoft.org/schema/mule/quartz" 
 xmlns:http="http://www.mulesoft.org/schema/mule/http"
xmlns:vm="http://www.mulesoft.org/schema/mule/vm"
xmlns:test="http://www.mulesoft.org/schema/mule/test"   
xmlns:file="http://www.mulesoft.org/schema/mule/file"    
xsi:schemaLocation="http://www.mulesoft.org/schema/mule/quartz http://www.mulesoft.org/schema/mule/quartz/current/mule-quartz.xsd
http://www.mulesoft.org/schema/mule/test http://www.mulesoft.org/schema/mule/test/3.6/mule-test.xsd
http://www.mulesoft.org/schema/mule/core http://www.mulesoft.org/schema/mule/core/3.6/mule.xsd
http://www.mulesoft.org/schema/mule/vm http://www.mulesoft.org/schema/mule/vm/3.6/mule-vm.xsd
http://www.mulesoft.org/schema/mule/http http://www.mulesoft.org/schema/mule/http/3.6/mule-http.xsd
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-current.xsd
http://www.mulesoft.org/schema/mule/file http://www.mulesoft.org/schema/mule/file/3.6/mule-file.xsd">

<object-to-string-transformer name="httptoobj" />
<file:connector name="input"/>
<http:http-response-to-object-transformer
    name="httptostring" />
<configuration>
    <expression-language autoResolveVariables="false">
        <import class="com.xyz.alertcampaign.appworkflow.CampaignStatus" />
    </expression-language>
</configuration>
<flow name="polling" doc:name="polling" processingStrategy="synchronous">
    <quartz:inbound-endpoint repeatInterval="3000"
        startDelay="3000" jobName="couchbasePoller" doc:name="Quartz">
        <quartz:event-generator-job stateful="true" />
    </quartz:inbound-endpoint>
    <component doc:name="Java">
        <singleton-object
            class="com.xyz.alertcampaign.appworkflow.CouchbasePoller" />
    </component>

    <vm:outbound-endpoint exchange-pattern="one-way"
        path="oozieQueue" doc:name="Trigger workflow" />

</flow>
<flow name="oozie-workflow-manager" doc:name="oozie-workflow-manager">
    <vm:inbound-endpoint exchange-pattern="one-way"
        path="oozieQueue" doc:name="VM" />

    <foreach collection="#[payload.items()]" counterVariableName="counter">
        <choice doc:name="Choice">
            <when expression="#[payload.status == CampaignStatus.NOT_STARTED]">
                <file:inbound-endpoint address="file://#[payload.fileName]" connector-ref="input"/>             
                <http:outbound-endpoint exchange-pattern="request-response"
                    address="http://localhost:8080/oozie/v1/jobs"
                    responseTransformer-refs="httptoobj" method="POST" doc:name="HTTP"
                    contentType="application/xml;charset=UTF-8" />
                <choice doc:name="Choice">
                    <when expression="#[message.inboundProperties['http.status'] == 201]">
                        <component doc:name="Java">
                            <singleton-object
                                class="com.xyz.alertcampaign.appworkflow.JobUpdater" />
                        </component>
                    </when>
                    <otherwise>
                        <logger level="ERROR" message="Error occurred on creating Job in OOzie " />
                    </otherwise>
                </choice>
            </when>
            <when
                expression="#[payload.status == CampaignStatus.UPDATED || payload.status == CampaignStatus.EXPIRED]">
                <logger level="ERROR" message="#[payload.status]" />
                <http:outbound-endpoint exchange-pattern="request-response"
                    method="PUT"
                    address="http://localhost:8080/oozie/v1/job/#[payload.jobId]?action=kill"
                    responseTransformer-refs="httptoobj" doc:name="HTTP" />
                <choice doc:name="Choice">
                    <when expression="#[message.inboundProperties['http.status'] == 200]">
                        <component doc:name="Java">
                            <singleton-object
                                class="com.xyz.alertcampaign.appworkflow.JobUpdater" />
                        </component>
                    </when>
                    <otherwise>
                        <logger level="ERROR" message="Error occurred on killing Job in OOzie " />
                    </otherwise>
                </choice>
            </when>
        </choice>
    </foreach>
</flow>

</mule> 

Getting following exception (stack):

Exception when loading mule' xml: Caused by: org.xml.sax.SAXParseException: cvc-complex-type.2.4.a: Invalid content was found starting with element 'file:inbound-endpoint'. One of '{"http://www.mulesoft.org/schema/mule/core":abstract-message-processor, "http://www.mulesoft.org/schema/mule/core":abstract-outbound-endpoint, "http://www.mulesoft.org/schema/mule/core":abstract-mixed-content-message-processor}' is expected.

Why am I not allowed to post a file to http inside choice router?

3

3 Answers

1
votes

You can only use a file:inbound-endpoint at the beginning of a flow. If you're trying to retrieve a file mid-flow, then consider using the Mule Requestor module. This allows you to request a resource (i.e. a file) at any point in a flow.

0
votes

The problem is that it's an inbound endpoint so you are adding a message source in the middle of a flow. What you should do is define another flow that starts with that file inbound endpoint (with all that logic) and use a flow reference element in the choice to it. For more details check out the doc.

0
votes

Additionaly I think there is another problem where the inbound endpoint does not allow dynamic inputs. I solved it via MuleRequester