FAQ
I have a requirement to perform FTP operations on behalf of 100's of parties, all of which have their own FTP credentials.  Obviously, it would not be practical to configure 100's of instances of the FTP component with different user's login/password hardcoded in the URI.  I am wondering if there's a way for the FTP component to pull the user/password from the message payload or headers?

Thanks

Search Discussions

  • Graham Little at Aug 24, 2012 at 9:38 pm
    Hi Charles,

    Yes this is possible, you can get the value from either the header or the body content as you prefer and then you can use the recipientlist to create the dynamic endpoint. You could use something a little like this:

    Processor ftpProcesor = new Processor () {
    public void process(Exchange exchange) throws Exception {
    Message in = exchange.getIn();

    String username = in.getHeader("FTP_USR_NM", String.class);
    String password = in.getHeader("FTP_PASSWORD", String.class);

    ftpEndpointURL = "ftp://" + username + "@ftpserver.ftp.com:22/Test?password="+password;
    }
    }

    from("activemq:queue:ftp.OUTGOING)
    .process(ftpProcesor)
    .recipientList(ftpEndpointURL)

    You could also pass all of the username/password values in at once in a comma separated list, or xml file or some other format and then loop through each pair and then perform the FTP operations as you go.

    Hope this helps.

    Thanks

    Graham
    Date: Fri, 24 Aug 2012 08:29:10 -0700
    From: cw94114@yahoo.com
    Subject: Dynamically configuring FTP component from Exchange input msg?
    To: users@camel.apache.org

    I have a requirement to perform FTP operations on behalf of 100's of parties, all of which have their own FTP credentials. Obviously, it would not be practical to configure 100's of instances of the FTP component with different user's login/password hardcoded in the URI. I am wondering if there's a way for the FTP component to pull the user/password from the message payload or headers?

    Thanks
  • Charles at Aug 27, 2012 at 6:19 pm
    Graham,

    Thanks a lot for the suggestion.  If I wanted to express this flow in Spring DSL, I assume I would need to create a custom producer template ans refer to that via a <template/> tag, yes?

    Thanks again,

    Charles


    ----- Original Message -----
    From: Graham Little <graham.little@outlook.com>
    To: "users@camel.apache.org" <users@camel.apache.org>
    Cc:
    Sent: Friday, August 24, 2012 5:37 PM
    Subject: RE: Dynamically configuring FTP component from Exchange input msg?

    Hi Charles,

    Yes this is possible, you can get the value from either the header or the body content as you prefer and then you can use the recipientlist to create the dynamic endpoint. You could use something a little like this:

    Processor ftpProcesor = new Processor () {
    public void process(Exchange exchange) throws Exception {
    Message in = exchange.getIn();

    String username = in.getHeader("FTP_USR_NM", String.class);
    String password = in.getHeader("FTP_PASSWORD", String.class);

    ftpEndpointURL = "ftp://" + username + "@ftpserver.ftp.com:22/Test?password="+password;
    }
    }

    from("activemq:queue:ftp.OUTGOING)
    .process(ftpProcesor)
    .recipientList(ftpEndpointURL)

    You could also pass all of the username/password values in at once in a comma separated list, or xml file or some other format and then loop through each pair and then perform the FTP operations as you go.

    Hope this helps.

    Thanks

    Graham
    Date: Fri, 24 Aug 2012 08:29:10 -0700
    From: cw94114@yahoo.com
    Subject: Dynamically configuring FTP component from Exchange input msg?
    To: users@camel.apache.org

    I have a requirement to perform FTP operations on behalf of 100's of parties, all of which have their own FTP credentials.  Obviously, it would not be practical to configure 100's of instances of the FTP component with different user's login/password hardcoded in the URI.  I am wondering if there's a way for the FTP component to pull the user/password from the message payload or headers?

    Thanks
  • Graham Little at Aug 27, 2012 at 7:24 pm
    Hi Charles,

    yes exactly in spring dsl you can refer to producer templates as follows:<camelContext xmlns="http://camel.apache.org/schema/spring">

    <template id="producer"/>

    <route>
    <from uri="activemq:queue:Endpoint.OUTGOING"/>
    <recipientList>
    <header>myHeader</header>
    </recipientList>
    </route>
    </camelContext>

    Consumer Templates just incase:

    <consumerTemplate id="consumer"/>


    There is some useful documentation here, especially for implementing strategies to deal with common issues like stopOnException:

    http://camel.apache.org/recipient-list.html

    Thanks

    Graham
    Date: Mon, 27 Aug 2012 11:18:43 -0700
    From: cw94114@yahoo.com
    Subject: Re: Dynamically configuring FTP component from Exchange input msg?
    To: users@camel.apache.org

    Graham,

    Thanks a lot for the suggestion. If I wanted to express this flow in Spring DSL, I assume I would need to create a custom producer template ans refer to that via a <template/> tag, yes?

    Thanks again,

    Charles


    ----- Original Message -----
    From: Graham Little <graham.little@outlook.com>
    To: "users@camel.apache.org" <users@camel.apache.org>
    Cc:
    Sent: Friday, August 24, 2012 5:37 PM
    Subject: RE: Dynamically configuring FTP component from Exchange input msg?

    Hi Charles,

    Yes this is possible, you can get the value from either the header or the body content as you prefer and then you can use the recipientlist to create the dynamic endpoint. You could use something a little like this:

    Processor ftpProcesor = new Processor () {
    public void process(Exchange exchange) throws Exception {
    Message in = exchange.getIn();

    String username = in.getHeader("FTP_USR_NM", String.class);
    String password = in.getHeader("FTP_PASSWORD", String.class);

    ftpEndpointURL = "ftp://" + username + "@ftpserver.ftp.com:22/Test?password="+password;
    }
    }

    from("activemq:queue:ftp.OUTGOING)
    .process(ftpProcesor)
    .recipientList(ftpEndpointURL)

    You could also pass all of the username/password values in at once in a comma separated list, or xml file or some other format and then loop through each pair and then perform the FTP operations as you go.

    Hope this helps.

    Thanks

    Graham
    Date: Fri, 24 Aug 2012 08:29:10 -0700
    From: cw94114@yahoo.com
    Subject: Dynamically configuring FTP component from Exchange input msg?
    To: users@camel.apache.org

    I have a requirement to perform FTP operations on behalf of 100's of parties, all of which have their own FTP credentials. Obviously, it would not be practical to configure 100's of instances of the FTP component with different user's login/password hardcoded in the URI. I am wondering if there's a way for the FTP component to pull the user/password from the message payload or headers?

    Thanks

Related Discussions

Discussion Navigation
viewthread | post
Discussion Overview
groupusers @
categoriescamel
postedAug 24, '12 at 3:29p
activeAug 27, '12 at 7:24p
posts4
users2
websitecamel.apache.org

2 users in discussion

Graham Little: 2 posts Charles: 2 posts

People

Translate

site design / logo © 2022 Grokbase