You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@camel.apache.org by "Goyal, Arpit" <ar...@sap.com> on 2016/08/31 00:46:40 UTC

First time create SFTP File and then Append to same in loop.

Hi Colleagues,

We have the following route:

from("xxx:inbound").process(new MyProcessor()).choice(when(header("record_count").isGreaterThan(0)).to("sftp://xyx[?options]").to("xxx:inbound").otherwise(new MyEndProcessor())

It is a simple loop condition using choice where one branch process data and send to SFTP server and then loop back where else other branch would end the process.

Question: In FIRST SFTP write we want the FILE to be created. When second call comes, then we want APPEND to happen. How can we achieve this? Was searching for some header where I can toggle the value of 'fileExists'.

Can I change end point configuration using some custom bean? Please help.

Regards,
Arpit.

Re: First time create SFTP File and then Append to same in loop.

Posted by Claus Ibsen <cl...@gmail.com>.
See this FAQ about dynamic to
http://camel.apache.org/how-to-use-a-dynamic-uri-in-to.html

On Wed, Aug 31, 2016 at 7:22 PM, Goyal, Arpit <ar...@sap.com> wrote:
> Hi Clause,
>
> The problem is -- First time execution creates the file and in loop appends the data. Now the process ends and file is available at SFTP folder. Second time execution, it will again append resulting to business logic failure, as file should be created fresh - and user might give FIXED name of the file.
>
> What I want is during execution, first time SFTP Endpoint should have fileExist=Override and when the loop gets triggered, change the SFTP property fileExist to APPEND.
>
> I was looking something like -- during the loop, MyProcessor can either change the configuration of SFTP Endpoint or set a header which SFTP Endpoint honors above the URI options provided.
>
>         Approach 1:  camelContext.getEndpoint("<some-id-of-sftp-endpoint>", SftpEndpoint.class).setFileExists(GenericFileExists.APPEND)
>         Approach 2: in.setHeader("fileExists", GenericFileExists.APPEND);
>
> Regards,
> Arpit.
>
> -----Original Message-----
> From: Claus Ibsen [mailto:claus.ibsen@gmail.com]
> Sent: Wednesday, August 31, 2016 12:35 AM
> To: users@camel.apache.org
> Subject: Re: First time create SFTP File and then Append to same in loop.
>
> Can you not just use fileExists=Append always so the data is always
> appended if the file exists?
>
>
> On Wed, Aug 31, 2016 at 2:46 AM, Goyal, Arpit <ar...@sap.com> wrote:
>> Hi Colleagues,
>>
>> We have the following route:
>>
>> from("xxx:inbound").process(new MyProcessor()).choice(when(header("record_count").isGreaterThan(0)).to("sftp://xyx[?options]").to("xxx:inbound").otherwise(new MyEndProcessor())
>>
>> It is a simple loop condition using choice where one branch process data and send to SFTP server and then loop back where else other branch would end the process.
>>
>> Question: In FIRST SFTP write we want the FILE to be created. When second call comes, then we want APPEND to happen. How can we achieve this? Was searching for some header where I can toggle the value of 'fileExists'.
>>
>> Can I change end point configuration using some custom bean? Please help.
>>
>> Regards,
>> Arpit.
>
>
>
> --
> Claus Ibsen
> -----------------
> http://davsclaus.com @davsclaus
> Camel in Action 2: https://www.manning.com/ibsen2



-- 
Claus Ibsen
-----------------
http://davsclaus.com @davsclaus
Camel in Action 2: https://www.manning.com/ibsen2

RE: First time create SFTP File and then Append to same in loop.

Posted by "Goyal, Arpit" <ar...@sap.com>.
Yes. Deleting the file is one option. Really a hack in my opinion. Also, it is SFTP and lot of customers protect SFTP folders by not allowing Delete of files and only write/override of file data.

Dynamic URI concept was known to me.... I forgot. Thanks Claus. 

Regards,
Arpit.

-----Original Message-----
From: souciance [mailto:souciance.eqdam.rashti@gmail.com] 
Sent: Thursday, September 1, 2016 1:52 AM
To: users@camel.apache.org
Subject: Re: First time create SFTP File and then Append to same in loop.

Why don't you have append as Claus suggested but include a bean at the end
of the route which deletes the file? You don't need to then change the uri
configuration or any looping.

On Wed, Aug 31, 2016 at 7:23 PM, Goyal, Arpit [via Camel] <
ml-node+s465427n5787068h71@n5.nabble.com> wrote:

> Hi Clause,
>
> The problem is -- First time execution creates the file and in loop
> appends the data. Now the process ends and file is available at SFTP
> folder. Second time execution, it will again append resulting to business
> logic failure, as file should be created fresh - and user might give FIXED
> name of the file.
>
> What I want is during execution, first time SFTP Endpoint should have
> fileExist=Override and when the loop gets triggered, change the SFTP
> property fileExist to APPEND.
>
> I was looking something like -- during the loop, MyProcessor can either
> change the configuration of SFTP Endpoint or set a header which SFTP
> Endpoint honors above the URI options provided.
>
>         Approach 1:  camelContext.getEndpoint("<some-id-of-sftp-endpoint>",
> SftpEndpoint.class).setFileExists(GenericFileExists.APPEND)
>         Approach 2: in.setHeader("fileExists", GenericFileExists.APPEND);
>
> Regards,
> Arpit.
>
> -----Original Message-----
> From: Claus Ibsen [mailto:[hidden email]
> <http:///user/SendEmail.jtp?type=node&node=5787068&i=0>]
> Sent: Wednesday, August 31, 2016 12:35 AM
> To: [hidden email] <http:///user/SendEmail.jtp?type=node&node=5787068&i=1>
> Subject: Re: First time create SFTP File and then Append to same in loop.
>
> Can you not just use fileExists=Append always so the data is always
> appended if the file exists?
>
>
> On Wed, Aug 31, 2016 at 2:46 AM, Goyal, Arpit <[hidden email]
> <http:///user/SendEmail.jtp?type=node&node=5787068&i=2>> wrote:
>
> > Hi Colleagues,
> >
> > We have the following route:
> >
> > from("xxx:inbound").process(new MyProcessor()).choice(when(
> header("record_count").isGreaterThan(0)).to("sftp://
> xyx[?options]").to("xxx:inbound").otherwise(new MyEndProcessor())
> >
> > It is a simple loop condition using choice where one branch process data
> and send to SFTP server and then loop back where else other branch would
> end the process.
> >
> > Question: In FIRST SFTP write we want the FILE to be created. When
> second call comes, then we want APPEND to happen. How can we achieve this?
> Was searching for some header where I can toggle the value of 'fileExists'.
> >
> > Can I change end point configuration using some custom bean? Please
> help.
> >
> > Regards,
> > Arpit.
>
>
>
> --
> Claus Ibsen
> -----------------
> http://davsclaus.com @davsclaus
> Camel in Action 2: https://www.manning.com/ibsen2
>
>
> ------------------------------
> If you reply to this email, your message will be added to the discussion
> below:
> http://camel.465427.n5.nabble.com/First-time-create-SFTP-
> File-and-then-Append-to-same-in-loop-tp5787016p5787068.html
> To start a new topic under Camel - Users, email
> ml-node+s465427n465428h31@n5.nabble.com
> To unsubscribe from Camel - Users, click here
> <http://camel.465427.n5.nabble.com/template/NamlServlet.jtp?macro=unsubscribe_by_code&node=465428&code=c291Y2lhbmNlLmVxZGFtLnJhc2h0aUBnbWFpbC5jb218NDY1NDI4fDE1MzI5MTE2NTY=>
> .
> NAML
> <http://camel.465427.n5.nabble.com/template/NamlServlet.jtp?macro=macro_viewer&id=instant_html%21nabble%3Aemail.naml&base=nabble.naml.namespaces.BasicNamespace-nabble.view.web.template.NabbleNamespace-nabble.view.web.template.NodeNamespace&breadcrumbs=notify_subscribers%21nabble%3Aemail.naml-instant_emails%21nabble%3Aemail.naml-send_instant_email%21nabble%3Aemail.naml>
>




--
View this message in context: http://camel.465427.n5.nabble.com/First-time-create-SFTP-File-and-then-Append-to-same-in-loop-tp5787016p5787084.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Re: First time create SFTP File and then Append to same in loop.

Posted by souciance <so...@gmail.com>.
Why don't you have append as Claus suggested but include a bean at the end
of the route which deletes the file? You don't need to then change the uri
configuration or any looping.

On Wed, Aug 31, 2016 at 7:23 PM, Goyal, Arpit [via Camel] <
ml-node+s465427n5787068h71@n5.nabble.com> wrote:

> Hi Clause,
>
> The problem is -- First time execution creates the file and in loop
> appends the data. Now the process ends and file is available at SFTP
> folder. Second time execution, it will again append resulting to business
> logic failure, as file should be created fresh - and user might give FIXED
> name of the file.
>
> What I want is during execution, first time SFTP Endpoint should have
> fileExist=Override and when the loop gets triggered, change the SFTP
> property fileExist to APPEND.
>
> I was looking something like -- during the loop, MyProcessor can either
> change the configuration of SFTP Endpoint or set a header which SFTP
> Endpoint honors above the URI options provided.
>
>         Approach 1:  camelContext.getEndpoint("<some-id-of-sftp-endpoint>",
> SftpEndpoint.class).setFileExists(GenericFileExists.APPEND)
>         Approach 2: in.setHeader("fileExists", GenericFileExists.APPEND);
>
> Regards,
> Arpit.
>
> -----Original Message-----
> From: Claus Ibsen [mailto:[hidden email]
> <http:///user/SendEmail.jtp?type=node&node=5787068&i=0>]
> Sent: Wednesday, August 31, 2016 12:35 AM
> To: [hidden email] <http:///user/SendEmail.jtp?type=node&node=5787068&i=1>
> Subject: Re: First time create SFTP File and then Append to same in loop.
>
> Can you not just use fileExists=Append always so the data is always
> appended if the file exists?
>
>
> On Wed, Aug 31, 2016 at 2:46 AM, Goyal, Arpit <[hidden email]
> <http:///user/SendEmail.jtp?type=node&node=5787068&i=2>> wrote:
>
> > Hi Colleagues,
> >
> > We have the following route:
> >
> > from("xxx:inbound").process(new MyProcessor()).choice(when(
> header("record_count").isGreaterThan(0)).to("sftp://
> xyx[?options]").to("xxx:inbound").otherwise(new MyEndProcessor())
> >
> > It is a simple loop condition using choice where one branch process data
> and send to SFTP server and then loop back where else other branch would
> end the process.
> >
> > Question: In FIRST SFTP write we want the FILE to be created. When
> second call comes, then we want APPEND to happen. How can we achieve this?
> Was searching for some header where I can toggle the value of 'fileExists'.
> >
> > Can I change end point configuration using some custom bean? Please
> help.
> >
> > Regards,
> > Arpit.
>
>
>
> --
> Claus Ibsen
> -----------------
> http://davsclaus.com @davsclaus
> Camel in Action 2: https://www.manning.com/ibsen2
>
>
> ------------------------------
> If you reply to this email, your message will be added to the discussion
> below:
> http://camel.465427.n5.nabble.com/First-time-create-SFTP-
> File-and-then-Append-to-same-in-loop-tp5787016p5787068.html
> To start a new topic under Camel - Users, email
> ml-node+s465427n465428h31@n5.nabble.com
> To unsubscribe from Camel - Users, click here
> <http://camel.465427.n5.nabble.com/template/NamlServlet.jtp?macro=unsubscribe_by_code&node=465428&code=c291Y2lhbmNlLmVxZGFtLnJhc2h0aUBnbWFpbC5jb218NDY1NDI4fDE1MzI5MTE2NTY=>
> .
> NAML
> <http://camel.465427.n5.nabble.com/template/NamlServlet.jtp?macro=macro_viewer&id=instant_html%21nabble%3Aemail.naml&base=nabble.naml.namespaces.BasicNamespace-nabble.view.web.template.NabbleNamespace-nabble.view.web.template.NodeNamespace&breadcrumbs=notify_subscribers%21nabble%3Aemail.naml-instant_emails%21nabble%3Aemail.naml-send_instant_email%21nabble%3Aemail.naml>
>




--
View this message in context: http://camel.465427.n5.nabble.com/First-time-create-SFTP-File-and-then-Append-to-same-in-loop-tp5787016p5787084.html
Sent from the Camel - Users mailing list archive at Nabble.com.

RE: First time create SFTP File and then Append to same in loop.

Posted by "Goyal, Arpit" <ar...@sap.com>.
Hi Clause,

The problem is -- First time execution creates the file and in loop appends the data. Now the process ends and file is available at SFTP folder. Second time execution, it will again append resulting to business logic failure, as file should be created fresh - and user might give FIXED name of the file.  

What I want is during execution, first time SFTP Endpoint should have fileExist=Override and when the loop gets triggered, change the SFTP property fileExist to APPEND. 

I was looking something like -- during the loop, MyProcessor can either change the configuration of SFTP Endpoint or set a header which SFTP Endpoint honors above the URI options provided. 

	Approach 1:  camelContext.getEndpoint("<some-id-of-sftp-endpoint>", SftpEndpoint.class).setFileExists(GenericFileExists.APPEND)
	Approach 2: in.setHeader("fileExists", GenericFileExists.APPEND);

Regards,
Arpit.

-----Original Message-----
From: Claus Ibsen [mailto:claus.ibsen@gmail.com] 
Sent: Wednesday, August 31, 2016 12:35 AM
To: users@camel.apache.org
Subject: Re: First time create SFTP File and then Append to same in loop.

Can you not just use fileExists=Append always so the data is always
appended if the file exists?


On Wed, Aug 31, 2016 at 2:46 AM, Goyal, Arpit <ar...@sap.com> wrote:
> Hi Colleagues,
>
> We have the following route:
>
> from("xxx:inbound").process(new MyProcessor()).choice(when(header("record_count").isGreaterThan(0)).to("sftp://xyx[?options]").to("xxx:inbound").otherwise(new MyEndProcessor())
>
> It is a simple loop condition using choice where one branch process data and send to SFTP server and then loop back where else other branch would end the process.
>
> Question: In FIRST SFTP write we want the FILE to be created. When second call comes, then we want APPEND to happen. How can we achieve this? Was searching for some header where I can toggle the value of 'fileExists'.
>
> Can I change end point configuration using some custom bean? Please help.
>
> Regards,
> Arpit.



-- 
Claus Ibsen
-----------------
http://davsclaus.com @davsclaus
Camel in Action 2: https://www.manning.com/ibsen2

Re: First time create SFTP File and then Append to same in loop.

Posted by Claus Ibsen <cl...@gmail.com>.
Can you not just use fileExists=Append always so the data is always
appended if the file exists?


On Wed, Aug 31, 2016 at 2:46 AM, Goyal, Arpit <ar...@sap.com> wrote:
> Hi Colleagues,
>
> We have the following route:
>
> from("xxx:inbound").process(new MyProcessor()).choice(when(header("record_count").isGreaterThan(0)).to("sftp://xyx[?options]").to("xxx:inbound").otherwise(new MyEndProcessor())
>
> It is a simple loop condition using choice where one branch process data and send to SFTP server and then loop back where else other branch would end the process.
>
> Question: In FIRST SFTP write we want the FILE to be created. When second call comes, then we want APPEND to happen. How can we achieve this? Was searching for some header where I can toggle the value of 'fileExists'.
>
> Can I change end point configuration using some custom bean? Please help.
>
> Regards,
> Arpit.



-- 
Claus Ibsen
-----------------
http://davsclaus.com @davsclaus
Camel in Action 2: https://www.manning.com/ibsen2