0

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 Answers 3

1

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
0

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.

2
  • I tried this now. But I am getting the following error. org.mule.module.launcher.DeploymentInitException: MalformedEndpointException: The endpoint "file://#[payload.fileName]" is malformed and cannot be parsed. If this is the name of a global endpoint, check the name is correct, that the endpoint exists, and that you are using the correct configuration (eg the "ref" attribute). Note that names on inbound and outbound endpoints cannot be used to send or receive messages; use a named global endpoint instead.. Only Outbound endpoints can be dynamic Mar 3, 2015 at 18:13
  • Yes, that makes sense. I didn't realize you where using the payload to get the file name dynamically.
    – afelisatti
    Mar 3, 2015 at 18:30
0

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

3
  • If that's the case can you please accept the answer so that the question is resolved. Thanks.
    – danw
    Mar 4, 2015 at 9:33
  • Why is mule requester deleting the file after it is reading the data. How do I avoid this? Mar 4, 2015 at 17:58
  • You need to configure a file connector where the autoDelete property is set to 'false'. You can have your requestor use this by configuring the resource as resource="file://path/to/file?fileConnector". If you still have issues raise a new question and answers can be posted there.
    – danw
    Mar 5, 2015 at 10:00

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.