[Mule FTPconnector] Properties from a remote file

View: New views
5 Messages — Rating Filter:   Alert me  

[Mule FTPconnector] Properties from a remote file

by Richard Swart :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hello all,

I'm getting, through the FTP connector from Mule, files from a remote location.
I can get the original filename and such but what i do need is the timestamp from te remote file, as to determine the time between the polling and the placing of the file.

Is this possible in plain Mule, or do i need some extra component ?

Gerwin Postma
Netherlands

---------------------------------------------------------------------
To unsubscribe from this list, please visit:

    http://xircles.codehaus.org/manage_email



Parent Message unknown Re: [Mule FTPconnector] Properties from a remote file

by Andrew Perepelytsya :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Just extend ftp message receiver, fetch this property from ftp file object and set it as a property on the message. If there's a way to get the timestamp (haven't checked yet), then it's trivial.

I recommend you also file an enhancement jira request for this, preferrably with your modifications.

HTH,
Andrew

On Jun 29, 2009 8:37 AM, "Gerwin Postma" <mule.user.relay@...> wrote:

Hello all,

I'm getting, through the FTP connector from Mule, files from a remote location.
I can get the original filename and such but what i do need is the timestamp from te remote file, as to determine the time between the polling and the placing of the file.

Is this possible in plain Mule, or do i need some extra component ?

Gerwin Postma
Netherlands

---------------------------------------------------------------------
To unsubscribe from this list, please visit:

   http://xircles.codehaus.org/manage_email



Parent Message unknown Re: [Mule FTPconnector] Properties from a remote file

by Richard Swart :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hello Andrew,

Thanks for the reply. But, being a Microsoft developer, is am a litle 'challenged' when it comes to your suggestion.
Are you willing to help me out a little ?

An example of how to make the class accept and handle the file (basicly a crude sample) would be greatly appreciated.

Gerwin

---------------------------------------------------------------------
To unsubscribe from this list, please visit:

    http://xircles.codehaus.org/manage_email



Re: [Mule FTPconnector] Properties from a remote file

by Dirk Olmes-5 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Gerwin Postma wrote:
> Hello Andrew,
>
> Thanks for the reply. But, being a Microsoft developer, is am a litle
> 'challenged' when it comes to your suggestion. Are you willing to
> help me out a little ?

In your ftp connector declaration, use a service-override to supply the
class name of your custom message receiver subclass
(http://www.mulesource.org/display/MULE2USER/Configuring+a+Transport#ConfiguringaTransport-serviceoverrides)

Create a subclass of FtpMessageReceiver, copy the current implementation
of the processFile method into it and add the code to retrieve the
timestamp from the FTPFile. (Agreed, this is not ideal but obviously,
the FtpMessageReceiver does not provide an extension point to put
additional message properties into the message that's being created)

HTH,

-dirk

---------------------------------------------------------------------
To unsubscribe from this list, please visit:

    http://xircles.codehaus.org/manage_email



Re: [Mule FTPconnector] Properties from a remote file

by Richard Swart :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Thx Dirk,

The solution i came up with:
- Extend the FtpMessageReceiver
- replace the implementations of procesFile and createFtpClient (something to do with unexposed methods)
Implemented the following code ;

            message.setProperty(FileConnector.PROPERTY_ORIGINAL_FILENAME, file.getName());
            message.setProperty(FileConnector.PROPERTY_FILE_SIZE, file.getSize());
            // New Custom Property
            Map<String,String> map = new HashMap<String, String>(1);
            SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd@HH:mm:ss.SSS");
            map.put("FtpserverTimestamp", sdf.format(file.getTimestamp().getTime()).replace('@', 'T'));
            // end new Custom Property

And added in config :

        <ftp:connector name="ftpConnector" validateConnections="true"
                streaming="false" passive="true">
                        <service-overrides messageReceiver="org.mule.rws.lbs.FtpMessageReceiverWithProps"/>
                        <file:expression-filename-parser />
        </ftp:connector>

---------------------------------------------------------------------
To unsubscribe from this list, please visit:

    http://xircles.codehaus.org/manage_email