Archive for the ‘Mule File’ Category

Mule3 JMS Outbound



<?xml version=“1.0″ encoding=“UTF-8″?>

<mule xmlns=http://www.mulesoft.org/schema/mule/core&#8221; xmlns:file=http://www.mulesoft.org/schema/mule/file&#8221; xmlns:jms=http://www.mulesoft.org/schema/mule/jms&#8221; xmlns:doc=http://www.mulesoft.org/schema/mule/documentation&#8221; xmlns:spring=http://www.springframework.org/schema/beans&#8221; xmlns:core=http://www.mulesoft.org/schema/mule/core&#8221; xmlns:xsi=http://www.w3.org/2001/XMLSchema-instance&#8221; version=“CE-3.2.1″ xsi:schemaLocation=
http://www.mulesoft.org/schema/mule/file http://www.mulesoft.org/schema/mule/file/current/mule-file.xsd
http://www.mulesoft.org/schema/mule/jms http://www.mulesoft.org/schema/mule/jms/current/mule-jms.xsd
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/current/mule.xsd
http://www.mulesoft.org/schema/mule/core http://www.mulesoft.org/schema/mule/core/current/mule.xsd>
   <jms:activemq-connector name=“Active_MQ” brokerURL=“tcp://localhost:61617″ validateConnections=“true” doc:name=“Active MQ”/>
   <flow name=“CollectionAggregatorMsgPrptyFlow1″ doc:name=“CollectionAggregatorMsgPrptyFlow1″>
       <file:inbound-endpoint path=“D:\test\data” doc:name=“File”/>
       <file:file-to-string-transformer doc:name=“File to String”/>
       <jms:outbound-endpoint queue=“MyQueue” connector-ref=“Active_MQ” doc:name=“JMS”/>
   </flow>
</mule>

Include Active MQ Jar in the class path


Mule3 ESB XSLT transformation

<?xml version=“1.0″ encoding=“UTF-8″?>

<mule xmlns=http://www.mulesoft.org/schema/mule/core&#8221;
    xmlns:mulexml=http://www.mulesoft.org/schema/mule/xml&#8221; xmlns:file=http://www.mulesoft.org/schema/mule/file&#8221;
    xmlns:stdio=http://www.mulesoft.org/schema/mule/stdio&#8221; xmlns:doc=http://www.mulesoft.org/schema/mule/documentation&#8221;
    xmlns:spring=http://www.springframework.org/schema/beans&#8221; xmlns:core=http://www.mulesoft.org/schema/mule/core&#8221;
    xmlns:xsi=http://www.w3.org/2001/XMLSchema-instance&#8221; version=“CE-3.2.1″
    xsi:schemaLocation=
http://www.mulesoft.org/schema/mule/xml http://www.mulesoft.org/schema/mule/xml/current/mule-xml.xsd
http://www.mulesoft.org/schema/mule/file http://www.mulesoft.org/schema/mule/file/current/mule-file.xsd
http://www.mulesoft.org/schema/mule/stdio http://www.mulesoft.org/schema/mule/stdio/current/mule-stdio.xsd
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/current/mule.xsd
http://www.mulesoft.org/schema/mule/core http://www.mulesoft.org/schema/mule/core/current/mule.xsd>
    <stdio:connector name=“stdio1″ messageDelayTime=“1000″
        promptMessage=“Enter Name :” doc:name=“STDIO” />
    <flow name=“file_component” doc:name=“stdio_component”>
        <file:inbound-endpoint path=“D:\myfile\xml”
            mimeType=“text/xml” doc:name=“File” />
        <mulexml:xslt-transformer
            maxIdleTransformers=“2″ maxActiveTransformers=“5″
            xsl-file=“D:\myfile\xsl\employees.xsl” doc:name=“XSLT” />
        <file:outbound-endpoint path=“D:\myfile\out”
            outputPattern=“myfile#[function:datestamp].txt” doc:name=“File” />
    </flow>
</mule>


employees.xml
<employees>
    <employee>
        <name>Subramanian</name>
        <age>32</age>
        <dept>Java</dept>
        <email>subu@xxx.com</email>
    </employee>
    <employee>
        <name>Kalyani</name>
        <age>27</age>
        <dept>Testing</dept>
        <email>kal@xxx.com</email>
    </employee>
</employees>

employees.xsl
<xsl:stylesheet xmlns:xsl=”http://www.w3.org/1999/XSL/Transform&#8221; version=”1.0″>
<xsl:output method=”text”/>
<xsl:template match=”/”>
    <xsl:apply-templates />
</xsl:template>
<xsl:template match=”employees”>
    <xsl:apply-templates />
</xsl:template>
 <xsl:template match=”name”>
    Name: <xsl:apply-templates />
  </xsl:template>
    <xsl:template match=”age”>
    Age: <xsl:apply-templates />
  </xsl:template>
  <xsl:template match=”dept”>
    Dept: <xsl:apply-templates />
  </xsl:template>
  <xsl:template match=”email”>
    Email: <xsl:apply-templates />
  </xsl:template>
</xsl:stylesheet>

myfile15-10-12_11-32-20.072.txt
    Name: Subramanian
    Age: 32
    Dept: Java
    Email: subu@xxx.com

    Name: Kalyani
    Age: 27
    Dept: Testing
    Email: kal@xxx.com

INFO  2012-10-15 11:32:19,021 [main] org.mule.DefaultMuleContext:
**********************************************************************
* Application: hello_world                                           *
* OS encoding: Cp1252, Mule encoding: UTF-8                          *
*                                                                    *
* Agents Running:                                                    *
*   JMX Agent                                                        *
**********************************************************************
INFO  2012-10-15 11:32:19,021 [main] org.mule.module.launcher.DeploymentService:
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+ Started app ‘hello_world’                                +
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

Enter Name :INFO  2012-10-15 11:32:19,982 [[hello_world].connector.file.mule.default.receiver.01] org.mule.transport.file.FileMessageReceiver: Lock obtained on file: D:\myfile\xml\employees.xml
INFO  2012-10-15 11:32:20,062 [[hello_world].connector.file.mule.default.dispatcher.01] org.mule.lifecycle.AbstractLifecycleManager: Initialising: ‘connector.file.mule.default.dispatcher.1855725970′. Object is: FileMessageDispatcher
INFO  2012-10-15 11:32:20,062 [[hello_world].connector.file.mule.default.dispatcher.01] org.mule.lifecycle.AbstractLifecycleManager: Starting: ‘connector.file.mule.default.dispatcher.1855725970′. Object is: FileMessageDispatcher
INFO  2012-10-15 11:32:20,072 [[hello_world].connector.file.mule.default.dispatcher.01] org.mule.transport.file.FileConnector: Writing file to: D:\myfile\out\myfile15-10-12_11-32-20.072.txt
——————————————————————————–

Using File and VM Endpoints 

<?xml version=“1.0″ encoding=“UTF-8″?>

<mule xmlns=http://www.mulesoft.org/schema/mule/core&#8221; xmlns:vm=http://www.mulesoft.org/schema/mule/vm&#8221;
    xmlns:mulexml=http://www.mulesoft.org/schema/mule/xml&#8221; xmlns:file=http://www.mulesoft.org/schema/mule/file&#8221;
    xmlns:stdio=http://www.mulesoft.org/schema/mule/stdio&#8221; xmlns:doc=http://www.mulesoft.org/schema/mule/documentation&#8221;
    xmlns:spring=http://www.springframework.org/schema/beans&#8221; xmlns:core=http://www.mulesoft.org/schema/mule/core&#8221;
    xmlns:xsi=http://www.w3.org/2001/XMLSchema-instance&#8221; version=“CE-3.2.1″
    xsi:schemaLocation=
http://www.mulesoft.org/schema/mule/vm http://www.mulesoft.org/schema/mule/vm/current/mule-vm.xsd
http://www.mulesoft.org/schema/mule/xml http://www.mulesoft.org/schema/mule/xml/current/mule-xml.xsd
http://www.mulesoft.org/schema/mule/file http://www.mulesoft.org/schema/mule/file/current/mule-file.xsd
http://www.mulesoft.org/schema/mule/stdio http://www.mulesoft.org/schema/mule/stdio/current/mule-stdio.xsd
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/current/mule.xsd
http://www.mulesoft.org/schema/mule/core http://www.mulesoft.org/schema/mule/core/current/mule.xsd>
    <stdio:connector name=“stdio1″ messageDelayTime=“1000″
        promptMessage=“Enter Name :” doc:name=“STDIO” />
    <flow name=“file_component” doc:name=“file_component”>
        <file:inbound-endpoint path=“D:\myfile\xml”
            mimeType=“text/xml” doc:name=“File” />
        <mulexml:xslt-transformer
            maxIdleTransformers=“2″ maxActiveTransformers=“5″
            xsl-file=“D:\myfile\xsl\employees.xsl” doc:name=“XSLT” />
        <vm:outbound-endpoint exchange-pattern=“one-way”
            path=“xsl.mesg” responseTimeout=“10000″ mimeType=“text/plain”
            doc:name=“VM” />
    </flow>
    <flow name=“vm_flow” doc:name=“vm_flow”>
        <vm:inbound-endpoint exchange-pattern=“one-way”
            path=“xsl.mesg” responseTimeout=“10000″ mimeType=“text/plain”
            doc:name=“VM” />
        <file:outbound-endpoint path=“D:\myfile\out”
            outputPattern=“myfile#[function:datestamp].txt” doc:name=“File” />
    </flow>
</mule>


Follow

Get every new post delivered to your Inbox.