tshepang
tshepang

Reputation: 12459

How to move a file using Mule2

I expected the following Mule (2.1.2) file to move all files in "/path/to/dir1" to "/path/to/dir2", but it doesn't work:

<mule
    xmlns="http://www.mulesource.org/schema/mule/core/2.1"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xmlns:file="http://www.mulesource.org/schema/mule/file/2.1"
    xsi:schemaLocation="
       http://www.mulesource.org/schema/mule/core/2.1 http://www.mulesource.org/schema/mule/core/2.1/mule.xsd
       http://www.mulesource.org/schema/mule/file/2.1 http://www.mulesource.org/schema/mule/file/2.1/mule-file.xsd">

    <file:endpoint name="move"
        path="/path/to/dir1"
        moveToDirectory="/path/to/dir2"/>

    <model>
        <service name="service name: move file">
            <inbound>
                <inbound-endpoint ref="move"/>
            </inbound>
        </service>
    </model>

</mule>

Here's the out of ./mule -config ../conf/test.xml:

Mule home is at /home/wena/work/share/archives/mule-2.1.2
Running in console (foreground) mode by default, use Ctrl-C to exit...
Mule home is at /home/wena/work/share/archives/mule-2.1.2
Running Mule...
--> Wrapper Started as Console
Launching a JVM...
Starting the Mule Server...
Wrapper (Version 3.2.3) http://wrapper.tanukisoftware.org
  Copyright 1999-2006 Tanuki Software, Inc.  All Rights Reserved.

INFO  2011-02-18 12:59:31,853 [WrapperListener_start_runner] org.mule.MuleServer: Mule Server initializing...
INFO  2011-02-18 12:59:32,255 [WrapperListener_start_runner] org.mule.config.spring.MuleApplicationContext: Refreshing org.mule.config.spring.MuleApplicationContext@1e845c2: display name [org.mule.config.spring.MuleApplicationContext@1e845c2]; startup date [Fri Feb 18 12:59:32 SAST 2011]; root of context hierarchy
INFO  2011-02-18 12:59:33,221 [WrapperListener_start_runner] org.mule.config.spring.MuleApplicationContext: Bean factory for application context [org.mule.config.spring.MuleApplicationContext@1e845c2]: org.springframework.beans.factory.support.DefaultListableBeanFactory@bf5555
INFO  2011-02-18 12:59:33,599 [WrapperListener_start_runner] org.mule.transport.file.FileConnector: Initialising: FileConnector{this=b31b77, started=false, initialised=false, name='connector.file.0', disposed=false, numberOfConcurrentTransactedReceivers=4, createMultipleTransactedReceivers=true, connected=false, supportedProtocols=[file], serviceOverrides=null}
INFO  2011-02-18 12:59:33,605 [WrapperListener_start_runner] org.mule.DefaultExceptionStrategy: Initialising exception listener: org.mule.DefaultExceptionStrategy@1b5391b
INFO  2011-02-18 12:59:33,614 [WrapperListener_start_runner] org.mule.component.simple.PassThroughComponent: Initialising: org.mule.component.simple.PassThroughComponent component for: service name: move file
INFO  2011-02-18 12:59:33,620 [WrapperListener_start_runner] org.mule.config.builders.AutoConfigurationBuilder: Configured Mule using "org.mule.config.spring.SpringXmlConfigurationBuilder" with configuration resource(s): "[ConfigResource{resourceName='../conf/test.xml'}]"
INFO  2011-02-18 12:59:33,620 [WrapperListener_start_runner] org.mule.config.builders.AutoConfigurationBuilder: Configured Mule using "org.mule.config.builders.AutoConfigurationBuilder" with configuration resource(s): "[ConfigResource{resourceName='../conf/test.xml'}]"
INFO  2011-02-18 12:59:33,620 [WrapperListener_start_runner] org.mule.MuleServer: Mule Server starting...
INFO  2011-02-18 12:59:33,634 [WrapperListener_start_runner] org.mule.transport.file.FileConnector: Starting: FileConnector{this=b31b77, started=false, initialised=true, name='connector.file.0', disposed=false, numberOfConcurrentTransactedReceivers=4, createMultipleTransactedReceivers=true, connected=true, supportedProtocols=[file], serviceOverrides=null}
INFO  2011-02-18 12:59:33,640 [WrapperListener_start_runner] org.mule.transport.file.FileConnector: Started: FileConnector{this=b31b77, started=true, initialised=true, name='connector.file.0', disposed=false, numberOfConcurrentTransactedReceivers=4, createMultipleTransactedReceivers=true, connected=true, supportedProtocols=[file], serviceOverrides=null}
INFO  2011-02-18 12:59:33,640 [WrapperListener_start_runner] org.mule.component.simple.PassThroughComponent: Starting: org.mule.component.simple.PassThroughComponent component for: service name: move file
INFO  2011-02-18 12:59:33,640 [WrapperListener_start_runner] org.mule.transport.file.FileConnector: Registering listener: service name: move file on endpointUri: file:///home/wena/temp/test1
INFO  2011-02-18 12:59:33,674 [WrapperListener_start_runner] org.mule.model.seda.SedaService: Service service name: move file has been started successfully
INFO  2011-02-18 12:59:33,674 [WrapperListener_start_runner] org.mule.util.queue.TransactionalQueueManager: Starting ResourceManager
INFO  2011-02-18 12:59:33,675 [WrapperListener_start_runner] org.mule.util.queue.TransactionalQueueManager: Started ResourceManager
INFO  2011-02-18 12:59:33,692 [WrapperListener_start_runner] org.mule.DefaultMuleContext: 
**********************************************************************
* Mule ESB and Integration Platform                                  *
* Version: 2.1.2 Build: 13558                                        *
* MuleSource, Inc.                                                   *
* For more information go to http://mule.mulesource.org              *
*                                                                    *
* Server started: 2011/02/18 12:59 PM                                *
* Server ID: 2a03e188-3b4e-11e0-8837-7d3fd629264e                    *
* JDK: 1.6.0_23 (mixed mode)                                         *
* Encoding: OS: UTF-8, Mule: UTF-8                                   *
* OS: Linux (2.6.32-5-686-bigmem, i386)                              *
* Host: debian (127.0.1.1)                                         *
*                                                                    *
* Agents Running: None                                               *
**********************************************************************

[note] I can't afford to upgrade to later Mule versions just yet.

Upvotes: 2

Views: 1172

Answers (2)

David Dossot
David Dossot

Reputation: 33413

The files don't get moved with your configuration because the stream payload that is generated by the inbound file endpoint never gets consumed. It's the payload consumption that triggers the move.

Simply add:

<log-component />

after your inbound router and files should start moving.

Upvotes: 4

Ocaso Protal
Ocaso Protal

Reputation: 20237

You don't get any errors when you copy any file to /path/to/dir1?

Try this configuration:

<model>
  <service name="service name: move file">
    <inbound>
      <file:inbound-endpoint path="/path/to/dir1/"/>
    </inbound>
    <outbound>
      <pass-through-router>
        <file:outbound-endpoint path="/path/to/dir2/" 
            outputPattern="${ORIGINALNAME}"/>
      </pass-through-router>
    </outbound>
  </service>
</model>

BTW: Mule 2.x is still fine, I run this version, too.

Upvotes: 5

Related Questions