Re: Send file via POST request

2013-03-08 Thread Sergey Beryozkin

Hi,

Sorry for a delay; you've mentioned at CXF users that this all actually 
works except that you have to use some hard-coded values.


Can you explain what exactly is hard-coded, are you not able to get the 
parameters passed to cxfrs uploadFile method ? I think with cxfrs server 
one has to write a processor routine to get to the parameters, as in 
this form the cxfrs is only used to match the HTTP request.


May be, if all you have to do is to effectively proxy the request, the 
camel http component can be simpler to use; if you'd like to use cxfrs 
then consider using CXF JAXRS endpoint directly (use Camel Servlet and 
transport to link to it), have it processing GET and uploading to the 
destination with the code like this one:


http://cxf.apache.org/docs/jax-rs-multiparts.html#JAX-RSMultiparts-Uploadingfiles

and then return from the route.
However it sounds like it may be not the easiest approach, so I'm not 
100% sure


Cheers, Sergey



On 06/03/13 12:51, jamalissimo wrote:

Hello guys,

I am currently working on quite exciting assignment. Here is what I want to
do:

@GET REST response -  CXF to get parameters from exchange -  3rd Party API
to get session_id -  BEAN to send data via POST method and in
multipart/mixed( it is for uploading files )

My first problem is that I don't know how to set the REST, for now it looks
like this:

@GET
@Path(/{myServerHost}/upload)
@Produces(MediaType.APPLICATION_JSON)
@Consumes(MediaType.MULTIPART_FORM_DATA)

public Response uploadFile(@PathParam(myHost) String knowledgetreeHost,
@QueryParam(myPort) String knowledgetreePort, 
@QueryParam(user)
String user,
@QueryParam(password) String password, 
@QueryParam(file) String file)
{
return null;
}

Then I have route and I am setting http method to post

.when(header(CxfConstants.OPERATION_NAME).isEqualTo(uploadFile))

.recipientList(https://myserver.com/service/?method=loginusername=myusernamepassword=123456;)
  .beanRef(myBean, getSessionId)
   // For now I needed data in GET(session_id),it is no problem, but in
the following method
   // I need to send POST request
.setHeader(Exchange.HTTP_METHOD, constant(POST))
 .beanRef(myBean,uploadMyFile)
.endChoice()

Method uploadMyFile should send POST request. For now it looks like this:

public void uploadMyFile(Exchange exchange) throws IOException {
 //SESSION_ID is set in previous steps of route
String sessionId = 
exchange.getProperty(SESSION_ID).toString();
//FILENAME is taken from URL
/**
   String filename = (String) msgList.get(4);
  exchange.setProperty(FILENAME, filename);
 */
String filename = 
@+exchange.getProperty(FILENAME).toString();
String pathToUploader = 
https://myserver.com/service/upload.php;;

// Instantiate an HttpClient
HttpClient client = new HttpClient();

// Instantiate a POST HTTP method
PostMethod method = new PostMethod(pathToUploader);
method.setRequestHeader(Content-type,
exchange.getIn().getHeader(CONTENT_TYPE) + ;charset=+
exchange.getIn().getHeader(CONTENT_ENCODING));

// Define name-value pairs to set into the QueryString

NameValuePair nvp1 = new NameValuePair(session_id, sessionId);
NameValuePair nvp2 = new NameValuePair(action, A);
NameValuePair nvp3 = new NameValuePair(myfile, filename);

method.setQueryString(new NameValuePair[] { nvp1, nvp2, nvp3 });

try {
int statusCode = client.executeMethod(method);

System.out.println(Status Code =  + statusCode);
System.out.println(QueryString   + 
method.getQueryString());
System.out.println(Status Text +
HttpStatus.getStatusText(statusCode));

// Get data as a String
System.out.println(method.getResponseBodyAsString());

exchange.getIn().setHeader(HTTP_METHOD, POST);

exchange.getIn().setBody(method.getResponseBodyAsString());

// release connection
method.releaseConnection();
} catch (IOException e) {
e.printStackTrace();
}

}

Basically I need to know how to set REST and how to set POST method for CXF

Thanks

-Br, Roman



--
View this message in context: 
http://camel.465427.n5.nabble.com/Send-file-via-POST-request-tp5728674.html
Sent from the Camel - Users mailing list archive at Nabble.com.





camel-ftp 2.10.4 fails to connect on windows

2013-03-08 Thread xuloo
I'm building an Eclipse RCP application - i've created a plug-in which uses
Camel and, more specifically, the camel-ftp component to connect to an FTP
server.

FTP server is vsftpd running on a ubuntu 12.x box with standard config.

running the application from my macosx 10.8.2 machine it connects fine and
polls the server, pulls files... all is well.

However, when connecting from windows 7 (haven't tested other windows
versions) i get this:

20954 [Camel (camel-1) thread #0 - ftp://username@1.2.3.4] INFO 
org.apache.camel.component.file.remote.FtpConsumer  - Connected and logged
in to: ftp://username@1.2.3.4:21
22112 [Camel (camel-1) thread #0 - ftp://username@1.2.3.4] WARN 
org.apache.camel.component.file.remote.RemoteFilePollingConsumerPollStrategy 
- Trying to recover by disconnecting from remote server forcing a re-connect
at next poll: ftp://username@1.2.3.4:21
22344 [Camel (camel-1) thread #0 - ftp://username@1.2.3.4] WARN 
org.apache.camel.component.file.remote.FtpConsumer  - Consumer
FtpConsumer[ftp://username@1.2.3.4?passiveMode=truepassword=**] failed
polling endpoint:
Endpoint[ftp://username@1.2.3.4?passiveMode=truepassword=**]. Will try
again at next poll. Caused by:
[org.apache.camel.component.file.GenericFileOperationFailedException - File
operation failed: 550 Failed to change directory.
 Cannot change directory to: \. Code: 550]
org.apache.camel.component.file.GenericFileOperationFailedException: File
operation failed: 550 Failed to change directory.
 Cannot change directory to: \. Code: 550
at
org.apache.camel.component.file.remote.FtpOperations.doChangeDirectory(FtpOperations.java:704)
at
org.apache.camel.component.file.remote.FtpOperations.changeCurrentDirectory(FtpOperations.java:667)
at
org.apache.camel.component.file.remote.FtpConsumer.pollDirectory(FtpConsumer.java:53)
at
org.apache.camel.component.file.GenericFileConsumer.poll(GenericFileConsumer.java:107)
at
org.apache.camel.impl.ScheduledPollConsumer.doRun(ScheduledPollConsumer.java:142)
at
org.apache.camel.impl.ScheduledPollConsumer.run(ScheduledPollConsumer.java:92)
at java.util.concurrent.Executors$RunnableAdapter.call(Unknown Source)
at java.util.concurrent.FutureTask$Sync.innerRunAndReset(Unknown Source)
at java.util.concurrent.FutureTask.runAndReset(Unknown Source)
at
java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$301(Unknown
Source)
at
java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(Unknown
Source)
at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)

seems to be trying to do a windows-style backslash and fails (cause that
directory doesn't exist).

I've googled the hell out of this and can't find any hint of anyone else
having the same problem, nor can i find any suggestion for a camel-ftp
setting that would allow me to sidestep this.

Any suggestions?

Mac 'java -version' - 

java version 1.6.0_37
Java(TM) SE Runtime Environment (build 1.6.0_37-b06-434-11M3909)
Java HotSpot(TM) 64-Bit Server VM (build 20.12-b01-434, mixed mode)

Windows 'java -version' - 

java version 1.7.0_02
Java(TM) SE Runtime Environment (build 1.7.0_02-b13)
Java HotSpot(TM) Client VM (build 22.0-b10, mixed mode, sharing)



--
View this message in context: 
http://camel.465427.n5.nabble.com/camel-ftp-2-10-4-fails-to-connect-on-windows-tp5728815.html
Sent from the Camel - Users mailing list archive at Nabble.com.


Re: Send file via POST request

2013-03-08 Thread jamalissimo
Hi,

I will describe what steps I need to do and what I have done. This route
servers as file uploader but not in the right sense of the word. It does not
upload file via stream but I need to send the file as part of post request

What I need to do:

1. Get QueryParams from given url e.g.
http://localhost:1555/cxf/127.0.0.1/uploadFile?port=443user=myuserpassword=mypasswordfile=/path/to/myfile.txt

2. Set appropriate properties for passing data through the route

3. Pass this data to method where I set MultipartEntity and send the POST
request

--

Yesterday I was able to make the consumer work as you saw at 
http://cxf.547215.n5.nabble.com/MultipartBody-with-PathParam-and-QueryParam-td5724291.html#a5724293
http://cxf.547215.n5.nabble.com/MultipartBody-with-PathParam-and-QueryParam-td5724291.html#a5724293
  

The tricky part is how to send different type of data then only multipart.
For now it works with this hard-coded data:

CXF:
--

@POST
@Path(/upload)
@Consumes(MediaType.APPLICATION_FORM_URLENCODED)
@Produces(MediaType.APPLICATION_JSON)
public Response uploadFile(
@Multipart(value = session_id) String sessionId,
@Multipart(value = action) String action
){
return null;
}

JAVA:
--

public void sendPost(Exchange exchange) throws IOException {

String pathToUploader = 
https://myserver.com/service/upload.php;;

String session_id = 0kk1sobmbuforgjamj10470a23;
String action = A;
File myfile = new File(/path/to/myfile.txt);

HttpClient client = new DefaultHttpClient();

client.getParams().setParameter(CoreProtocolPNames.PROTOCOL_VERSION,
HttpVersion.HTTP_1_1);
HttpPost post = new HttpPost(pathToUploader);

MultipartEntity entity = new MultipartEntity(
HttpMultipartMode.BROWSER_COMPATIBLE );

// For File parameters
entity.addPart(myfile, new FileBody((( File ) myfile),
application/octet-stream ));
 
// For usual String parameters
entity.addPart(session_id, new StringBody(session_id, 
text/plain,
Charset.forName( UTF-8 )));
entity.addPart(action, new StringBody(action, 
text/plain,
Charset.forName( UTF-8 )));

post.setEntity( entity );   

   }

This will send the correct http request via POST method and I can see file
uploaded on my server. 

To add additional parameters I tried to do something like this:

@POST
@Path(/upload)
@Consumes(MediaType.APPLICATION_FORM_URLENCODED)
@Produces(MediaType.APPLICATION_JSON)
public Response uploadFile(
@PathParam(host) String host,
@QueryParam(port) String port,
@Multipart(value = session_id) String sessionId,
@Multipart(value = action) String action
){
return null;
}

which actually works, I can get data via MessageContentsList, set properties
and pass them to method sendPost(). 

But this is the point where sending of multipart POST request stops working.
I can see that everything is set correctly, but the request is sent with
incorrect data or format and I can't see the uploaded file.

-Br, Roman



--
View this message in context: 
http://camel.465427.n5.nabble.com/Send-file-via-POST-request-tp5728674p5728817.html
Sent from the Camel - Users mailing list archive at Nabble.com.


Re: Write enriched data after a split in a file

2013-03-08 Thread Jean Francois LE BESCONT
Thanks Willem for help.

My explaination are sometime to complicate, I will present it differently.

I have a big file to process efficiently, for that if I have tried :

Method 1 :
   from(file://C:/Temp/camel/input_test/?noop=true)
  .split()
 .tokenize(\n)
// Business logic with possible reject and enrich
.recipientList(
simple(stream:file?fileName=C:/Temp/camel/output_test/out.csv))
.end()
  .end()
   .end();

With this method, my process take 11 seconds but my file is not released
(windows file is locked in windows).

So I try with append :

Method 2 :

   from(file://C:/Temp/camel/input_test/?noop=true)
  .split()
 .tokenize(\n)
// Business logic with possible reject and enrich

.to(file://?fileName=C:/Temp/camel/output_test/out.csvfileExist=Append)
  .end()

   .end();

File is not locked after but it take 1,40 minutes ...

I finally try with the aggregate :

Method 3 :

   from(file://C:/Temp/camel/input_test/?noop=true)
  .split()
 .tokenize(\n)
// Business logic with possible reject and enrich
.aggregate(header(Exchange.FILE_NAME_ONLY), new
BodyInAggregatingStrategy())
   .completionTimeout(3000)
   .to(file://C:/Temp/camel/output_test/)
.end()
  .end()
   .end();

As the example, but the process never finish, so I try to specify
completionSize(7500) and  completionTimeout(15000) but my output file
doesn't contains all my row ( only 1 %). I have not find an example of how
to use these parameters ...

Please, what should I do to have a process efficient and with no lock ?

Thanks

JF


Re: Write enriched data after a split in a file

2013-03-08 Thread Marco Westermann

Hi,

maybe you can process this by using a bean. Then you can open the stream 
at the beginning and close it at the end. I try to show you what I mean:


FileWriterBean fwBean = new FileWriterBean();

public void configure() {
from(file://)
.bean(fwBean, openFileForProcessing)
.split().tokenize(\n)
// do your enrichment
.bean(fwBean, writeLine)
.end()
.bean(fwBean, closeFile);
}

regards, Marco


Am 08.03.2013 12:23, schrieb Jean Francois LE BESCONT:

Thanks Willem for help.

My explaination are sometime to complicate, I will present it differently.

I have a big file to process efficiently, for that if I have tried :

Method 1 :
from(file://C:/Temp/camel/input_test/?noop=true)
   .split()
  .tokenize(\n)
 // Business logic with possible reject and enrich
 .recipientList(
simple(stream:file?fileName=C:/Temp/camel/output_test/out.csv))
 .end()
   .end()
.end();

With this method, my process take 11 seconds but my file is not released
(windows file is locked in windows).

So I try with append :

Method 2 :

from(file://C:/Temp/camel/input_test/?noop=true)
   .split()
  .tokenize(\n)
 // Business logic with possible reject and enrich

.to(file://?fileName=C:/Temp/camel/output_test/out.csvfileExist=Append)
   .end()

.end();

File is not locked after but it take 1,40 minutes ...

I finally try with the aggregate :

Method 3 :

from(file://C:/Temp/camel/input_test/?noop=true)
   .split()
  .tokenize(\n)
 // Business logic with possible reject and enrich
 .aggregate(header(Exchange.FILE_NAME_ONLY), new
BodyInAggregatingStrategy())
.completionTimeout(3000)
.to(file://C:/Temp/camel/output_test/)
 .end()
   .end()
.end();

As the example, but the process never finish, so I try to specify
completionSize(7500) and  completionTimeout(15000) but my output file
doesn't contains all my row ( only 1 %). I have not find an example of how
to use these parameters ...

Please, what should I do to have a process efficient and with no lock ?

Thanks

JF





Re: Send file via POST request

2013-03-08 Thread Sergey Beryozkin

Hi,

On 08/03/13 11:07, jamalissimo wrote:

Hi,

I will describe what steps I need to do and what I have done. This route
servers as file uploader but not in the right sense of the word. It does not
upload file via stream but I need to send the file as part of post request

What I need to do:

1. Get QueryParams from given url e.g.
http://localhost:1555/cxf/127.0.0.1/uploadFile?port=443user=myuserpassword=mypasswordfile=/path/to/myfile.txt

2. Set appropriate properties for passing data through the route

3. Pass this data to method where I set MultipartEntity and send the POST
request

--

Yesterday I was able to make the consumer work as you saw at
http://cxf.547215.n5.nabble.com/MultipartBody-with-PathParam-and-QueryParam-td5724291.html#a5724293
http://cxf.547215.n5.nabble.com/MultipartBody-with-PathParam-and-QueryParam-td5724291.html#a5724293

The tricky part is how to send different type of data then only multipart.
For now it works with this hard-coded data:

CXF:
--

@POST
@Path(/upload)
@Consumes(MediaType.APPLICATION_FORM_URLENCODED)
@Produces(MediaType.APPLICATION_JSON)
public Response uploadFile(
@Multipart(value = session_id) String sessionId,
@Multipart(value = action) String action
){
return null;
}

JAVA:
--

public void sendPost(Exchange exchange) throws IOException {

String pathToUploader = 
https://myserver.com/service/upload.php;;

String session_id = 0kk1sobmbuforgjamj10470a23;
String action = A;
File myfile = new File(/path/to/myfile.txt);

HttpClient client = new DefaultHttpClient();

client.getParams().setParameter(CoreProtocolPNames.PROTOCOL_VERSION,
HttpVersion.HTTP_1_1);
HttpPost post = new HttpPost(pathToUploader);

MultipartEntity entity = new MultipartEntity(
HttpMultipartMode.BROWSER_COMPATIBLE );

// For File parameters
entity.addPart(myfile, new FileBody((( File ) myfile),
application/octet-stream ));

// For usual String parameters
entity.addPart(session_id, new StringBody(session_id, 
text/plain,
Charset.forName( UTF-8 )));
entity.addPart(action, new StringBody(action, 
text/plain,
Charset.forName( UTF-8 )));

post.setEntity( entity );   

}

This will send the correct http request via POST method and I can see file
uploaded on my server.

To add additional parameters I tried to do something like this:

@POST
@Path(/upload)
@Consumes(MediaType.APPLICATION_FORM_URLENCODED)
@Produces(MediaType.APPLICATION_JSON)
public Response uploadFile(
 @PathParam(host) String host,
@QueryParam(port) String port,
@Multipart(value = session_id) String sessionId,
@Multipart(value = action) String action
){
return null;
}

which actually works, I can get data via MessageContentsList, set properties
and pass them to method sendPost().

But this is the point where sending of multipart POST request stops working.
I can see that everything is set correctly, but the request is sent with
incorrect data or format and I can't see the uploaded file.


Are you saying that as soon as you add @PathParam(host) and 
@QueryParam(port) then the sendPost() stops working ?


Cheers, Sergey



-Br, Roman



--
View this message in context: 
http://camel.465427.n5.nabble.com/Send-file-via-POST-request-tp5728674p5728817.html
Sent from the Camel - Users mailing list archive at Nabble.com.





Re: Send file via POST request

2013-03-08 Thread Sergey Beryozkin

On 08/03/13 11:56, jamalissimo wrote:

Hi,

yes, exactly. When I add QueryParam ,PathParam or both together, then no
POST is send and file is not uploaded.

That is very strange. I've played with the CXF test where @Multipart 
annotations are used, added @PathParam there (actually returning 'null', 
same as in your case, given that no matching template variable exists in 
@Path(/uploadFile)), it works fine.


I think the best way forward is to get the cxfrs source and put a 
breakpoint there and see why adding these two extra parameters 
effectively breaks the route, can you please try that and let us know 
what happens ? You may've discovered some bug that needs to be fixed...


Thanks, Sergey


-Roman



--
View this message in context: 
http://camel.465427.n5.nabble.com/Send-file-via-POST-request-tp5728674p5728821.html
Sent from the Camel - Users mailing list archive at Nabble.com.



--
Sergey Beryozkin

Talend Community Coders
http://coders.talend.com/

Blog: http://sberyozkin.blogspot.com


Re: Write enriched data after a split in a file

2013-03-08 Thread Jean Francois LE BESCONT
Thanks Marco !

It is an idea ! Claused to the Composed Message Processor (
http://camel.apache.org/composed-message-processor.html paragraph Example
using only Splitter).

I am really suprised to have to make a such tips, it looks very complicated
for a simple use case no ?


2013/3/8 Marco Westermann marwesterm...@gmx.de

 Hi,

 maybe you can process this by using a bean. Then you can open the stream
 at the beginning and close it at the end. I try to show you what I mean:

 FileWriterBean fwBean = new FileWriterBean();

 public void configure() {
 from(file://)
 .bean(fwBean, openFileForProcessing)
 .split().tokenize(\n)
 // do your enrichment
 .bean(fwBean, writeLine)
 .end()
 .bean(fwBean, closeFile);
 }

 regards, Marco


 Am 08.03.2013 12:23, schrieb Jean Francois LE BESCONT:

  Thanks Willem for help.

 My explaination are sometime to complicate, I will present it differently.

 I have a big file to process efficiently, for that if I have tried :

 Method 1 :
 from(file://C:/Temp/camel/**input_test/?noop=true)
.split()
   .tokenize(\n)
  // Business logic with possible reject and enrich
  .recipientList(
 simple(stream:file?fileName=**C:/Temp/camel/output_test/out.**csv))
  .end()
.end()
 .end();

 With this method, my process take 11 seconds but my file is not released
 (windows file is locked in windows).

 So I try with append :

 Method 2 :

 from(file://C:/Temp/camel/**input_test/?noop=true)
.split()
   .tokenize(\n)
  // Business logic with possible reject and enrich

 .to(file://?fileName=C:/Temp/**camel/output_test/out.csv**
 fileExist=Append)
.end()

 .end();

 File is not locked after but it take 1,40 minutes ...

 I finally try with the aggregate :

 Method 3 :

 from(file://C:/Temp/camel/**input_test/?noop=true)
.split()
   .tokenize(\n)
  // Business logic with possible reject and enrich
  .aggregate(header(Exchange.**FILE_NAME_ONLY), new
 BodyInAggregatingStrategy())
 .completionTimeout(3000)
 .to(file://C:/Temp/camel/**output_test/)
  .end()
.end()
 .end();

 As the example, but the process never finish, so I try to specify
 completionSize(7500) and  completionTimeout(15000) but my output file
 doesn't contains all my row ( only 1 %). I have not find an example of how
 to use these parameters ...

 Please, what should I do to have a process efficient and with no lock ?

 Thanks

 JF





Re: Camel blueprint and drools

2013-03-08 Thread AlanFoster
I had planned to do that, but i've spent the past week trying to do this with
no luck unfortunately! :(

I firstly noticed that drools doesn't offer a blueprint namespace handler,
so I can't use any of the spring xml instantiation blocks that it has within
blueprint! :(

I've also tried to expose the drools camel component from spring as an osgi
service so that it can be used in the blueprint routes, but it then dies on
the following code within one of the blueprint routes

   DroolsEndpoint.java
protected void configure(DroolsComponent component,
 String uri) {
String nodeId = getExecuteNodeId( uri );
ksessionId = getKsessionId( uri );

if ( !StringUtils.isEmpty( nodeId ) ) {
// let's look it up
node = component.getCamelContext().getRegistry().lookup( nodeId,

GridNode.class );
if ( node == null ) {
throw new RuntimeCamelException( Could not find GridNode
for uri=\ + uri + \ in CamelContext. Check configuration. );
}


Presumably this is because the camel context doesn't know about the GridNode
class declared in a completely different bundle...

I wonder if there's an easy way to make this work at all?

I would greatly appreciate any help you can give :)


Claus Ibsen-2 wrote
 On Thu, Mar 7, 2013 at 2:04 PM, AlanFoster lt;

 alan@

 gt; wrote:
 Hi Claus,

 Thanks for the response;

 I spotted this example before, but unfortunately the spring example
 doesn't
 work when trying to convert it to a blueprint bundle

 Do you happen to know where a blueprint bundle example can be found? :)

 
 No I have not seen a blueprint example. Maybe you can port that
 example to blueprint?
 
 Alan


 Claus Ibsen-2 wrote
 Hi

 There is a Camel and Drools example here
 https://github.com/FuseByExample/camel-drools-example


 On Thu, Mar 7, 2013 at 1:03 PM, AlanFoster lt;

 alan@

 gt; wrote:
 Hi all,

 Just wondering if there's any examples of drools running under
 blueprint?

 I can see that there is a camel-spring example, which works great, but
 not a
 camel-blueprint example anywhere

 I'd appreciate if anyone knows anything about this :)

 Thanks,
 Alan



 --
 View this message in context:
 http://camel.465427.n5.nabble.com/Camel-blueprint-and-drools-tp5728744.html
 Sent from the Camel - Users mailing list archive at Nabble.com.



 --
 Claus Ibsen
 -
 Red Hat, Inc.
 FuseSource is now part of Red Hat
 Email:

 cibsen@

 Web: http://fusesource.com
 Twitter: davsclaus
 Blog: http://davsclaus.com
 Author of Camel in Action: http://www.manning.com/ibsen





 --
 View this message in context:
 http://camel.465427.n5.nabble.com/Camel-blueprint-and-drools-tp5728744p5728750.html
 Sent from the Camel - Users mailing list archive at Nabble.com.
 
 
 
 -- 
 Claus Ibsen
 -
 Red Hat, Inc.
 FuseSource is now part of Red Hat
 Email: 

 cibsen@

 Web: http://fusesource.com
 Twitter: davsclaus
 Blog: http://davsclaus.com
 Author of Camel in Action: http://www.manning.com/ibsen





--
View this message in context: 
http://camel.465427.n5.nabble.com/Camel-blueprint-and-drools-tp5728744p5728824.html
Sent from the Camel - Users mailing list archive at Nabble.com.


Re: Write enriched data after a split in a file

2013-03-08 Thread Jean Francois LE BESCONT
That is the best practice for do it ?


2013/3/8 Jean Francois LE BESCONT jflebesc...@gmail.com

 Thanks Marco !

 It is an idea ! Claused to the Composed Message Processor (
 http://camel.apache.org/composed-message-processor.html paragraph Example
 using only Splitter).

 I am really suprised to have to make a such tips, it looks very
 complicated for a simple use case no ?


 2013/3/8 Marco Westermann marwesterm...@gmx.de

 Hi,

 maybe you can process this by using a bean. Then you can open the stream
 at the beginning and close it at the end. I try to show you what I mean:

 FileWriterBean fwBean = new FileWriterBean();

 public void configure() {
 from(file://)
 .bean(fwBean, openFileForProcessing)
 .split().tokenize(\n)
 // do your enrichment
 .bean(fwBean, writeLine)
 .end()
 .bean(fwBean, closeFile);
 }

 regards, Marco


 Am 08.03.2013 12:23, schrieb Jean Francois LE BESCONT:

  Thanks Willem for help.

 My explaination are sometime to complicate, I will present it
 differently.

 I have a big file to process efficiently, for that if I have tried :

 Method 1 :
 from(file://C:/Temp/camel/**input_test/?noop=true)
.split()
   .tokenize(\n)
  // Business logic with possible reject and enrich
  .recipientList(
 simple(stream:file?fileName=**C:/Temp/camel/output_test/out.**csv))
  .end()
.end()
 .end();

 With this method, my process take 11 seconds but my file is not released
 (windows file is locked in windows).

 So I try with append :

 Method 2 :

 from(file://C:/Temp/camel/**input_test/?noop=true)
.split()
   .tokenize(\n)
  // Business logic with possible reject and enrich

 .to(file://?fileName=C:/Temp/**camel/output_test/out.csv**
 fileExist=Append)
.end()

 .end();

 File is not locked after but it take 1,40 minutes ...

 I finally try with the aggregate :

 Method 3 :

 from(file://C:/Temp/camel/**input_test/?noop=true)
.split()
   .tokenize(\n)
  // Business logic with possible reject and enrich
  .aggregate(header(Exchange.**FILE_NAME_ONLY), new
 BodyInAggregatingStrategy())
 .completionTimeout(3000)
 .to(file://C:/Temp/camel/**output_test/)
  .end()
.end()
 .end();

 As the example, but the process never finish, so I try to specify
 completionSize(7500) and  completionTimeout(15000) but my output file
 doesn't contains all my row ( only 1 %). I have not find an example of
 how
 to use these parameters ...

 Please, what should I do to have a process efficient and with no lock ?

 Thanks

 JF






Re: Write enriched data after a split in a file

2013-03-08 Thread jeff
the more performante way looks to do : 

   from(file://C:/Temp/camel/input_test/?noop=true)   
  .split()
  .tokenize(\n)
 // Business lock with possible reject / enrich etc ...
 .streaming()

.to(stream:file?fileName=C:/Temp/camel/output_test/out.csv)
.end()  
   .end();

But the stream is not closed ... Please help, I have to finish my proof of
concept ! :) 

Thanks

JF





--
View this message in context: 
http://camel.465427.n5.nabble.com/Write-enriched-data-after-a-split-in-a-file-tp5728761p5728829.html
Sent from the Camel - Users mailing list archive at Nabble.com.


Re: Write enriched data after a split in a file

2013-03-08 Thread Claus Ibsen
On Fri, Mar 8, 2013 at 2:39 PM, jeff jflebesc...@gmail.com wrote:
 the more performante way looks to do :

from(file://C:/Temp/camel/input_test/?noop=true)
   .split()
   .tokenize(\n)
  // Business lock with possible reject / enrich etc ...
  .streaming()

 .to(stream:file?fileName=C:/Temp/camel/output_test/out.csv)
 .end()
.end();

 But the stream is not closed ... Please help, I have to finish my proof of
 concept ! :)


Just use a bean to write to the file, and keep the FileOutputStream
open until the last message is processed.

Something a long the lines of:

public class MyFileWriter {

private FileOutputStream fos;

public void writeMyStuff(String data, @Header(CamelSplitCompleted)
boolean done) {
if (fos == null) {
   fos = new FileOutputStream(new File());
}
fos.write(data.getBytes());
if (done) {
   fos.close();
   fos = null;
}
}
}

And then use this bean in the splitter instead of the to:stream


.bean(MyFileWriter.class);




 Thanks

 JF





 --
 View this message in context: 
 http://camel.465427.n5.nabble.com/Write-enriched-data-after-a-split-in-a-file-tp5728761p5728829.html
 Sent from the Camel - Users mailing list archive at Nabble.com.



-- 
Claus Ibsen
-
Red Hat, Inc.
FuseSource is now part of Red Hat
Email: cib...@redhat.com
Web: http://fusesource.com
Twitter: davsclaus
Blog: http://davsclaus.com
Author of Camel in Action: http://www.manning.com/ibsen


Re: Write enriched data after a split in a file

2013-03-08 Thread Raúl Kripalani
I wonder if split().shareUnitOfWork() would help here?

On Mar 8, 2013, at 14:02, Claus Ibsen wrote:

 On Fri, Mar 8, 2013 at 2:39 PM, jeff jflebesc...@gmail.com wrote:
 the more performante way looks to do :
 
   from(file://C:/Temp/camel/input_test/?noop=true)
  .split()
  .tokenize(\n)
 // Business lock with possible reject / enrich etc ...
 .streaming()
 
 .to(stream:file?fileName=C:/Temp/camel/output_test/out.csv)
.end()
   .end();
 
 But the stream is not closed ... Please help, I have to finish my proof of
 concept ! :)
 
 
 Just use a bean to write to the file, and keep the FileOutputStream
 open until the last message is processed.
 
 Something a long the lines of:
 
 public class MyFileWriter {
 
 private FileOutputStream fos;
 
 public void writeMyStuff(String data, @Header(CamelSplitCompleted)
 boolean done) {
if (fos == null) {
   fos = new FileOutputStream(new File());
}
fos.write(data.getBytes());
if (done) {
   fos.close();
   fos = null;
}
 }
 }
 
 And then use this bean in the splitter instead of the to:stream
 
 
 .bean(MyFileWriter.class);
 
 
 
 
 Thanks
 
 JF
 
 
 
 
 
 --
 View this message in context: 
 http://camel.465427.n5.nabble.com/Write-enriched-data-after-a-split-in-a-file-tp5728761p5728829.html
 Sent from the Camel - Users mailing list archive at Nabble.com.
 
 
 
 -- 
 Claus Ibsen
 -
 Red Hat, Inc.
 FuseSource is now part of Red Hat
 Email: cib...@redhat.com
 Web: http://fusesource.com
 Twitter: davsclaus
 Blog: http://davsclaus.com
 Author of Camel in Action: http://www.manning.com/ibsen



Re: Write enriched data after a split in a file

2013-03-08 Thread Claus Ibsen
On Fri, Mar 8, 2013 at 3:13 PM, Raúl Kripalani r...@evosent.com wrote:
 I wonder if split().shareUnitOfWork() would help here?


Thats related to have all the work appear as one unit, so when you do
error handling / dead letter queue etc. then the entire route rollback
if one of the splitter failed etc.

 On Mar 8, 2013, at 14:02, Claus Ibsen wrote:

 On Fri, Mar 8, 2013 at 2:39 PM, jeff jflebesc...@gmail.com wrote:
 the more performante way looks to do :

   from(file://C:/Temp/camel/input_test/?noop=true)
  .split()
  .tokenize(\n)
 // Business lock with possible reject / enrich etc ...
 .streaming()

 .to(stream:file?fileName=C:/Temp/camel/output_test/out.csv)
.end()
   .end();

 But the stream is not closed ... Please help, I have to finish my proof of
 concept ! :)


 Just use a bean to write to the file, and keep the FileOutputStream
 open until the last message is processed.

 Something a long the lines of:

 public class MyFileWriter {

 private FileOutputStream fos;

 public void writeMyStuff(String data, @Header(CamelSplitCompleted)
 boolean done) {
if (fos == null) {
   fos = new FileOutputStream(new File());
}
fos.write(data.getBytes());
if (done) {
   fos.close();
   fos = null;
}
 }
 }

 And then use this bean in the splitter instead of the to:stream


 .bean(MyFileWriter.class);




 Thanks

 JF





 --
 View this message in context: 
 http://camel.465427.n5.nabble.com/Write-enriched-data-after-a-split-in-a-file-tp5728761p5728829.html
 Sent from the Camel - Users mailing list archive at Nabble.com.



 --
 Claus Ibsen
 -
 Red Hat, Inc.
 FuseSource is now part of Red Hat
 Email: cib...@redhat.com
 Web: http://fusesource.com
 Twitter: davsclaus
 Blog: http://davsclaus.com
 Author of Camel in Action: http://www.manning.com/ibsen




-- 
Claus Ibsen
-
Red Hat, Inc.
FuseSource is now part of Red Hat
Email: cib...@redhat.com
Web: http://fusesource.com
Twitter: davsclaus
Blog: http://davsclaus.com
Author of Camel in Action: http://www.manning.com/ibsen


Re: Write enriched data after a split in a file

2013-03-08 Thread Claus Ibsen
On Fri, Mar 8, 2013 at 2:39 PM, jeff jflebesc...@gmail.com wrote:
 the more performante way looks to do :

from(file://C:/Temp/camel/input_test/?noop=true)
   .split()
   .tokenize(\n)
  // Business lock with possible reject / enrich etc ...
  .streaming()

 .to(stream:file?fileName=C:/Temp/camel/output_test/out.csv)
 .end()
.end();

 But the stream is not closed ... Please help, I have to finish my proof of
 concept ! :)


We should improve the stream:file to be able to auto close when it
detects the splitter is done, as we have a completed property on the
exchange to tell us.

Fell free to log a JIRA ticket, then we can add an option on stream:file

stream:file?fileName=C:/Temp/camel/output_test/out.csvcloseOnDone=true

Just have to figure out a good name for the option.


 Thanks

 JF





 --
 View this message in context: 
 http://camel.465427.n5.nabble.com/Write-enriched-data-after-a-split-in-a-file-tp5728761p5728829.html
 Sent from the Camel - Users mailing list archive at Nabble.com.



-- 
Claus Ibsen
-
Red Hat, Inc.
FuseSource is now part of Red Hat
Email: cib...@redhat.com
Web: http://fusesource.com
Twitter: davsclaus
Blog: http://davsclaus.com
Author of Camel in Action: http://www.manning.com/ibsen


Re: camel-ftp 2.10.4 fails to connect on windows

2013-03-08 Thread xuloo
Seems to be related to this:

http://serverfault.com/questions/262760/vsftp-path-with-backslash

Camel, on windows, is telling the ftp server to cd \.

on mac it does something different - i'm assuming it uses a forward slash /.

so a camel-ftp client running on windows (within eclipse RCP, at least)
can't connect to a FTP server running on a *nix system?

That doesn't sound right to me. Surely someone must have come across this
before?

I'll put up a windows server to test if it connects ok - but would like a
more suitable fix but i'm guessing there's a platform-specific
FILE_SEPARATOR that can't be overridden?



--
View this message in context: 
http://camel.465427.n5.nabble.com/camel-ftp-2-10-4-fails-to-connect-on-windows-tp5728815p5728834.html
Sent from the Camel - Users mailing list archive at Nabble.com.


Polling in subfolder with sftp fail (camel 2.10.4)

2013-03-08 Thread seazor
It seems that the problems sftp  camel are going better but it's not
finished...

I upgraded from 2.10.3 - 2.10.4 (see
http://camel.465427.n5.nabble.com/Problem-with-donefilename-on-sftp-td5728209.html
)
Some of my problems are corrected, but i've one more :
I have a route who is polling in a subfolder of an sftp server, and i have
an exception.

So
1)
from(ftp://camel@port-jogu/rfolder?password=***amp;move=doneamp;doneFileName=$simple{file:name.noext}.okamp;localWorkDirectory=/tmp;)
works OK

2)
from(sftp://camel@port-jogu/?password=***amp;move=doneamp;doneFileName=$simple{file:name.noext}.okamp;localWorkDirectory=/tmp;)
works OK

BUT 3)
from(sftp://camel@port-jogu/rfolder?password=***amp;move=doneamp;doneFileName=$simple{file:name.noext}.okamp;localWorkDirectory=/tmp;)
give this error :
org.apache.camel.component.file.GenericFileOperationFailedException: Cannot
change directory to: rfolder
at
org.apache.camel.component.file.remote.SftpOperations.doChangeDirectory(SftpOperations.java:437)
at
org.apache.camel.component.file.remote.SftpOperations.changeCurrentDirectory(SftpOperations.java:425)
at
org.apache.camel.component.file.remote.SftpConsumer.doPollDirectory(SftpConsumer.java:78)
at
org.apache.camel.component.file.remote.SftpConsumer.pollDirectory(SftpConsumer.java:50)
at
org.apache.camel.component.file.GenericFileConsumer.poll(GenericFileConsumer.java:107)
at
org.apache.camel.impl.ScheduledPollConsumer.doRun(ScheduledPollConsumer.java:142)
at
org.apache.camel.impl.ScheduledPollConsumer.run(ScheduledPollConsumer.java:92)
at 
java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:441)
at
java.util.concurrent.FutureTask$Sync.innerRunAndReset(FutureTask.java:317)
at java.util.concurrent.FutureTask.runAndReset(FutureTask.java:150)
at
java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$101(ScheduledThreadPoolExecutor.java:98)
at
java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.runPeriodic(ScheduledThreadPoolExecutor.java:181)
at
java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:205)
at
java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)
at
java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:909)
at java.lang.Thread.run(Thread.java:619)
Caused by: 4: Failure
at com.jcraft.jsch.ChannelSftp.throwStatusError(ChannelSftp.java:2569)
at com.jcraft.jsch.ChannelSftp._realpath(ChannelSftp.java:2100)
at com.jcraft.jsch.ChannelSftp.cd(ChannelSftp.java:315)
at
org.apache.camel.component.file.remote.SftpOperations.doChangeDirectory(SftpOperations.java:435)
... 15 more

If somebody have an idea to help me, feel free !
Thanks in advance...



--
View this message in context: 
http://camel.465427.n5.nabble.com/Polling-in-subfolder-with-sftp-fail-camel-2-10-4-tp5728836.html
Sent from the Camel - Users mailing list archive at Nabble.com.


Calling a route which uses a quartz consumer via the producertemplate

2013-03-08 Thread gilboy
Hi

Assume I have the following route:

*from(quartz..).to(...)*

Now, assume I want to call this route out of the quartz schedule. I was
hoping to be able to use the producertemplate. However, it looks like the
quartz endpoint does not have a producer.

Is there any other way I can invoke the above route in an ad-hoc type manner
out of schedule

Thanks
Joe



--
View this message in context: 
http://camel.465427.n5.nabble.com/Calling-a-route-which-uses-a-quartz-consumer-via-the-producertemplate-tp5728839.html
Sent from the Camel - Users mailing list archive at Nabble.com.


Re: Write enriched data after a split in a file

2013-03-08 Thread Jean Francois LE BESCONT
OK !

I have create a jira : https://issues.apache.org/jira/browse/CAMEL-6147  (
my first :)


By the way the solution is a route like this :

from(file://C:/Temp/camel/input_test/?noop=true)
.setProperty(OutputFileName  ,
simple(C:/Temp/camel/output_test/${headers.CamelFileName}))
.split()
.tokenize(\n)
.streaming()
.bean(MyFileWriter.class, writeLine)
.end()
.end();

With a MyFileWriter like this :

public class AEDFileWriter {

private FileOutputStream fos;

public void writeLine(String data, @Property(OutputFileName) String
OutputFileName,  @Header(CamelSplitComplete) boolean done) throws
IOException {

if (fos == null) {
fos = new FileOutputStream(new File(OutputFileName));
}
fos.write(data.getBytes());
if (done) {
fos.close();
fos = null;
}

}
}


I am closed to the end :)


2013/3/8 Claus Ibsen claus.ib...@gmail.com

 On Fri, Mar 8, 2013 at 2:39 PM, jeff jflebesc...@gmail.com wrote:
  the more performante way looks to do :
 
 from(file://C:/Temp/camel/input_test/?noop=true)
.split()
.tokenize(\n)
   // Business lock with possible reject / enrich etc
 ...
   .streaming()
 
  .to(stream:file?fileName=C:/Temp/camel/output_test/out.csv)
  .end()
 .end();
 
  But the stream is not closed ... Please help, I have to finish my proof
 of
  concept ! :)
 

 We should improve the stream:file to be able to auto close when it
 detects the splitter is done, as we have a completed property on the
 exchange to tell us.

 Fell free to log a JIRA ticket, then we can add an option on stream:file

 stream:file?fileName=C:/Temp/camel/output_test/out.csvcloseOnDone=true

 Just have to figure out a good name for the option.


  Thanks
 
  JF
 
 
 
 
 
  --
  View this message in context:
 http://camel.465427.n5.nabble.com/Write-enriched-data-after-a-split-in-a-file-tp5728761p5728829.html
  Sent from the Camel - Users mailing list archive at Nabble.com.



 --
 Claus Ibsen
 -
 Red Hat, Inc.
 FuseSource is now part of Red Hat
 Email: cib...@redhat.com
 Web: http://fusesource.com
 Twitter: davsclaus
 Blog: http://davsclaus.com
 Author of Camel in Action: http://www.manning.com/ibsen



base class for context component?

2013-03-08 Thread Sven Bauhan

Hi,

I'm trying to build my own context component as described in 
http://camel.apache.org/context.html.
I wonder if there is a base class or interface I can use for 
MyContextComponent. I saw there exists org.apache.camel.Component. But 
the method createEndpoint() I have to implement does not make sense for 
a context component.
Is there a better interface for this? Or should i create my own class 
without interface?


Thanks,
Sven Bauhan



Re: Calling a route which uses a quartz consumer via the producertemplate

2013-03-08 Thread Claus Ibsen
On Fri, Mar 8, 2013 at 4:10 PM, gilboy josephoto...@gmail.com wrote:
 Hi

 Assume I have the following route:

 *from(quartz..).to(...)*

 Now, assume I want to call this route out of the quartz schedule. I was
 hoping to be able to use the producertemplate. However, it looks like the
 quartz endpoint does not have a producer.

 Is there any other way I can invoke the above route in an ad-hoc type manner
 out of schedule


You can have a direct route you always can call from a producer template

from quartz
   to direct foo

from direct foo


Though we have in the past debated whether to introduce a new route
endpoint, so you can send a message to any route by its id, eg

 from quartz   routeId(myCoolRoute)
...


And then you can do

template.sendBody(route:myCoolRoute, Something here)

Though that is not possible. And hence the direct route would work.





 Thanks
 Joe



 --
 View this message in context: 
 http://camel.465427.n5.nabble.com/Calling-a-route-which-uses-a-quartz-consumer-via-the-producertemplate-tp5728839.html
 Sent from the Camel - Users mailing list archive at Nabble.com.



-- 
Claus Ibsen
-
Red Hat, Inc.
FuseSource is now part of Red Hat
Email: cib...@redhat.com
Web: http://fusesource.com
Twitter: davsclaus
Blog: http://davsclaus.com
Author of Camel in Action: http://www.manning.com/ibsen


Re: Write enriched data after a split in a file

2013-03-08 Thread Jean Francois LE BESCONT
It works fine with the simple example that is present but in a seda queue
executed with concurrentConsumers the bean throw an  exception due to
concurrency ...


2013/3/8 Jean Francois LE BESCONT jflebesc...@gmail.com

 OK !

 I have create a jira : https://issues.apache.org/jira/browse/CAMEL-6147 ( my 
 first :)


 By the way the solution is a route like this :

 from(file://C:/Temp/camel/input_test/?noop=true)
  .setProperty(OutputFileName  ,
 simple(C:/Temp/camel/output_test/${headers.CamelFileName}))
 .split()
  .tokenize(\n)
 .streaming()
 .bean(MyFileWriter.class, writeLine)
  .end()
 .end();

 With a MyFileWriter like this :

 public class AEDFileWriter {

 private FileOutputStream fos;

 public void writeLine(String data, @Property(OutputFileName) String
 OutputFileName,  @Header(CamelSplitComplete) boolean done) throws
 IOException {

 if (fos == null) {
 fos = new FileOutputStream(new File(OutputFileName));
 }
  fos.write(data.getBytes());
 if (done) {
 fos.close();
  fos = null;
 }

 }
 }


 I am closed to the end :)


 2013/3/8 Claus Ibsen claus.ib...@gmail.com

 On Fri, Mar 8, 2013 at 2:39 PM, jeff jflebesc...@gmail.com wrote:
  the more performante way looks to do :
 
 from(file://C:/Temp/camel/input_test/?noop=true)
.split()
.tokenize(\n)
   // Business lock with possible reject / enrich etc
 ...
   .streaming()
 
  .to(stream:file?fileName=C:/Temp/camel/output_test/out.csv)
  .end()
 .end();
 
  But the stream is not closed ... Please help, I have to finish my proof
 of
  concept ! :)
 

 We should improve the stream:file to be able to auto close when it
 detects the splitter is done, as we have a completed property on the
 exchange to tell us.

 Fell free to log a JIRA ticket, then we can add an option on stream:file

 stream:file?fileName=C:/Temp/camel/output_test/out.csvcloseOnDone=true

 Just have to figure out a good name for the option.


  Thanks
 
  JF
 
 
 
 
 
  --
  View this message in context:
 http://camel.465427.n5.nabble.com/Write-enriched-data-after-a-split-in-a-file-tp5728761p5728829.html
  Sent from the Camel - Users mailing list archive at Nabble.com.



 --
 Claus Ibsen
 -
 Red Hat, Inc.
 FuseSource is now part of Red Hat
 Email: cib...@redhat.com
 Web: http://fusesource.com
 Twitter: davsclaus
 Blog: http://davsclaus.com
 Author of Camel in Action: http://www.manning.com/ibsen





Re: Write enriched data after a split in a file

2013-03-08 Thread Jean Francois LE BESCONT
I have added it to manage an pool of stream, it works fine.

public class AEDFileWriter {

private MapString,FileOutputStream fosPool= new HashMap();

public void writeLine(@Body String data, @Property(OutputFileName) String
OutputFileName,  @Header(CamelSplitComplete) boolean done) throws
IOException {

// Get the outputStream
FileOutputStream fos  = fosPool.get(OutputFileName);
 // Create it if not exist
if (fos == null) {
fos = new FileOutputStream(new File(OutputFileName));
fosPool.put(OutputFileName, fos);
}
 // Add data
fos.write(data.getBytes());
 // Eventually close the pool
if (done) {
fos.close();
fos = null;
fosPool.remove(OutputFileName);
}
}
}

My POC is finish, camel can process ( on my laptop )  1200 line of CSV per
second and this number is growing via threading.

I will put on gitHub the source of this project I think it could be help
full for lot of camel beginner who need to deal with giga bytes of file  !


Thanks

JF









2013/3/8 Jean Francois LE BESCONT jflebesc...@gmail.com

 It works fine with the simple example that is present but in a seda queue
 executed with concurrentConsumers the bean throw an  exception due to
 concurrency ...


 2013/3/8 Jean Francois LE BESCONT jflebesc...@gmail.com

 OK !

 I have create a jira : https://issues.apache.org/jira/browse/CAMEL-6147 ( my 
 first :)


 By the way the solution is a route like this :

 from(file://C:/Temp/camel/input_test/?noop=true)
  .setProperty(OutputFileName  ,
 simple(C:/Temp/camel/output_test/${headers.CamelFileName}))
 .split()
  .tokenize(\n)
 .streaming()
 .bean(MyFileWriter.class, writeLine)
  .end()
 .end();

 With a MyFileWriter like this :

 public class AEDFileWriter {

 private FileOutputStream fos;

 public void writeLine(String data, @Property(OutputFileName) String
 OutputFileName,  @Header(CamelSplitComplete) boolean done) throws
 IOException {

 if (fos == null) {
 fos = new FileOutputStream(new File(OutputFileName));
 }
  fos.write(data.getBytes());
 if (done) {
 fos.close();
  fos = null;
 }

 }
 }


 I am closed to the end :)


 2013/3/8 Claus Ibsen claus.ib...@gmail.com

 On Fri, Mar 8, 2013 at 2:39 PM, jeff jflebesc...@gmail.com wrote:
  the more performante way looks to do :
 
 from(file://C:/Temp/camel/input_test/?noop=true)
.split()
.tokenize(\n)
   // Business lock with possible reject / enrich
 etc ...
   .streaming()
 
  .to(stream:file?fileName=C:/Temp/camel/output_test/out.csv)
  .end()
 .end();
 
  But the stream is not closed ... Please help, I have to finish my
 proof of
  concept ! :)
 

 We should improve the stream:file to be able to auto close when it
 detects the splitter is done, as we have a completed property on the
 exchange to tell us.

 Fell free to log a JIRA ticket, then we can add an option on stream:file

 stream:file?fileName=C:/Temp/camel/output_test/out.csvcloseOnDone=true

 Just have to figure out a good name for the option.


  Thanks
 
  JF
 
 
 
 
 
  --
  View this message in context:
 http://camel.465427.n5.nabble.com/Write-enriched-data-after-a-split-in-a-file-tp5728761p5728829.html
  Sent from the Camel - Users mailing list archive at Nabble.com.



 --
 Claus Ibsen
 -
 Red Hat, Inc.
 FuseSource is now part of Red Hat
 Email: cib...@redhat.com
 Web: http://fusesource.com
 Twitter: davsclaus
 Blog: http://davsclaus.com
 Author of Camel in Action: http://www.manning.com/ibsen






Re: zip file best practices

2013-03-08 Thread Henryk Konsek
Hi guys,

 Puff, sorry. The Jira is https://issues.apache.org/jira/browse/CAMEL-6139

Actually we already got ZipFile component [1], however it supports
only single-entry zip files at the moment.

Instead of creating separated module with zip file splitter I suggest
to add multi-entry zip files support to the
ZipFileDataFormat#unmarshal method, which could just return the
iterator. We would be able to split zip file as follows then...

from(direct:multi-entry-zip-file).unmarshal().zip().split().to(direct:single-zip-entry);

Are there any particular reasons against reusing and improving
existing ZipFile data format?

Best regards.

[1] http://camel.apache.org/zip-dataformat.html

--
Henryk Konsek
http://henryk-konsek.blogspot.com


Issue: Aggregator2 : BatchCompletion disturbed by other completions and fails to happen (when it probably should)

2013-03-08 Thread Tim Pierce
There is a bug - at least I assume it not desired functionality where if
you have more than one completion of which .completionFromBatchConsumer()
is one of them

if Exchange property CamelBatchSize is 2505 and .completionSize( ) is 1000

you would like batches of

1000 - compeltionSize
1000 - completionSize
505 - batchCompletion

but actually this will never happen, this is because the batch-counter
AtomicInteger does not get updated if a different completion occurs, so in
the above example
the counter will finish at 2503 and never reach 2505, because each time the
completionSize occured the method quit

it could be easily remedied by moving the onCompletionBatch section of the
method

AggregateProcessor: isCompleted(String key, Exchange exchange)

to the top of the method instead of the bottom.

batchConsumerCounter is the thing that doesnt get updated if another
compeltion occurs

I'd be happy to code this and submit it, but not sure if that sioluition
fits with your existing ideas about the module. It looks fairly obvivously
like a bug to me... if you guys are happy with that.
sorry not written a test-case


Routing REST request to external URI

2013-03-08 Thread ramrubio
Does Camel support routing an incoming REST request to an external RESTful
service for all http operations.

For example,

Client Submits REST request to server A.  Server A uses Camel to route to
appropriate service which resides in Server B.

I would like to to this for all HTTP operations (GET, POST, DELETE, etc...).

Is this possible with Camel?

Thanks,

/Ramon



--
View this message in context: 
http://camel.465427.n5.nabble.com/Routing-REST-request-to-external-URI-tp5728852.html
Sent from the Camel - Users mailing list archive at Nabble.com.


Re: Camel mina : data truncated to 1024 bytes

2013-03-08 Thread Christian Müller
Good to know you could figure it out by yourself.

Best,
Christian

Sent from a mobile device
Am 07.03.2013 23:44 schrieb nil icicn...@hotmail.com:

 We finally find the problem which was in our ProtocolEncoder
 implementation.
 In fact, the doDecode was reading just 1024 first bytes in the ByteBuffer
 whereas our frame (which know its length) was indicating more bytes. To
 prevent that, we resume reading in IoSession and returns false in doDocode
 if our length is not the same as remaining in the ByteBuffer.

 Thanks for all.

 NIL



 --
 View this message in context:
 http://camel.465427.n5.nabble.com/Camel-mina-data-truncated-to-1024-bytes-tp5728733p5728804.html
 Sent from the Camel - Users mailing list archive at Nabble.com.



Re: Routing REST request to external URI

2013-03-08 Thread Christian Müller
Yes, checkout the jetty and servlet component.

Sent from a mobile device
Am 08.03.2013 13:46 schrieb ramrubio ramru...@yahoo.com:

 Does Camel support routing an incoming REST request to an external RESTful
 service for all http operations.

 For example,

 Client Submits REST request to server A.  Server A uses Camel to route to
 appropriate service which resides in Server B.

 I would like to to this for all HTTP operations (GET, POST, DELETE,
 etc...).

 Is this possible with Camel?

 Thanks,

 /Ramon



 --
 View this message in context:
 http://camel.465427.n5.nabble.com/Routing-REST-request-to-external-URI-tp5728852.html
 Sent from the Camel - Users mailing list archive at Nabble.com.



Re: dynamic URI parameter in from URI?

2013-03-08 Thread Christian Müller
You have to create a new route at runtime to archive this, e.g. in a
processor:

CamelContext context = exchange.getContext();
context.addRoutes(new RouteBuilder() {
public void configure() throws Exception {
from()
.to();
}
});

Best,
Christian

Sent from a mobile device
Am 08.03.2013 14:34 schrieb Doug Douglass douglass.d...@gmail.com:

 I'm familiar with dynamic to URI support in Camel[1], but I'm looking for
 ways to dynamically set the from URI or at least update a parameter in a
 from URI.

 Specifically, I'm using the Atom component to access a paged feed and want
 to follow next links to consume the entire feed (could total thousands to
 tens of thousands of entries) and then poll the feed. I'm currently using
 Camel 2.10.2, but can switch to any version if need be. Note that the Atom
 service I'm testing returns HTTP 304 if the next link has no updated
 entries; perhaps I should switch gears and use Timer and HTTP/HTTP4
 components and do my own processing via Abdera...

 Any tips are appreciated.

 Doug

 [1] http://camel.apache.org/how-do-i-use-dynamic-uri-in-to.html



Re: Camel blueprint and drools

2013-03-08 Thread Scott Cranton
Alan,

I haven't tried drools with camel and blueprint yet, but I do know
that they've made a bunch of osgi enhancements to drools in
6.0-SNAPSHOT. I was thinking of upgrading that camel drools example
(still with spring) to see if I could eliminate more of the uberjar
stuff...

You may want to try your tests against latest snapshot to see if at
least the OSGi parts work better...

Scott

On Fri, Mar 8, 2013 at 7:53 AM, AlanFoster a...@alanfoster.me wrote:
 I had planned to do that, but i've spent the past week trying to do this with
 no luck unfortunately! :(

 I firstly noticed that drools doesn't offer a blueprint namespace handler,
 so I can't use any of the spring xml instantiation blocks that it has within
 blueprint! :(

 I've also tried to expose the drools camel component from spring as an osgi
 service so that it can be used in the blueprint routes, but it then dies on
 the following code within one of the blueprint routes

DroolsEndpoint.java
 protected void configure(DroolsComponent component,
  String uri) {
 String nodeId = getExecuteNodeId( uri );
 ksessionId = getKsessionId( uri );

 if ( !StringUtils.isEmpty( nodeId ) ) {
 // let's look it up
 node = component.getCamelContext().getRegistry().lookup( nodeId,

 GridNode.class );
 if ( node == null ) {
 throw new RuntimeCamelException( Could not find GridNode
 for uri=\ + uri + \ in CamelContext. Check configuration. );
 }


 Presumably this is because the camel context doesn't know about the GridNode
 class declared in a completely different bundle...

 I wonder if there's an easy way to make this work at all?

 I would greatly appreciate any help you can give :)


 Claus Ibsen-2 wrote
 On Thu, Mar 7, 2013 at 2:04 PM, AlanFoster lt;

 alan@

 gt; wrote:
 Hi Claus,

 Thanks for the response;

 I spotted this example before, but unfortunately the spring example
 doesn't
 work when trying to convert it to a blueprint bundle

 Do you happen to know where a blueprint bundle example can be found? :)


 No I have not seen a blueprint example. Maybe you can port that
 example to blueprint?

 Alan


 Claus Ibsen-2 wrote
 Hi

 There is a Camel and Drools example here
 https://github.com/FuseByExample/camel-drools-example


 On Thu, Mar 7, 2013 at 1:03 PM, AlanFoster lt;

 alan@

 gt; wrote:
 Hi all,

 Just wondering if there's any examples of drools running under
 blueprint?

 I can see that there is a camel-spring example, which works great, but
 not a
 camel-blueprint example anywhere

 I'd appreciate if anyone knows anything about this :)

 Thanks,
 Alan



 --
 View this message in context:
 http://camel.465427.n5.nabble.com/Camel-blueprint-and-drools-tp5728744.html
 Sent from the Camel - Users mailing list archive at Nabble.com.



 --
 Claus Ibsen
 -
 Red Hat, Inc.
 FuseSource is now part of Red Hat
 Email:

 cibsen@

 Web: http://fusesource.com
 Twitter: davsclaus
 Blog: http://davsclaus.com
 Author of Camel in Action: http://www.manning.com/ibsen





 --
 View this message in context:
 http://camel.465427.n5.nabble.com/Camel-blueprint-and-drools-tp5728744p5728750.html
 Sent from the Camel - Users mailing list archive at Nabble.com.



 --
 Claus Ibsen
 -
 Red Hat, Inc.
 FuseSource is now part of Red Hat
 Email:

 cibsen@

 Web: http://fusesource.com
 Twitter: davsclaus
 Blog: http://davsclaus.com
 Author of Camel in Action: http://www.manning.com/ibsen





 --
 View this message in context: 
 http://camel.465427.n5.nabble.com/Camel-blueprint-and-drools-tp5728744p5728824.html
 Sent from the Camel - Users mailing list archive at Nabble.com.


Re: camel-blueprint-test issues

2013-03-08 Thread Ryan Moquin
Right, I can see it was getting a new snapshot.  Wasn't sure if there was a
way to correlate the numbers.  I thought about building the source, but
figured I'd be patient :)

Thabks for the help!

Ryan
On Mar 7, 2013 5:55 AM, Claus Ibsen claus.ib...@gmail.com wrote:

 On Sun, Mar 3, 2013 at 2:38 PM, Ryan Moquin fragility...@gmail.com
 wrote:
  This fix would be in a snapshot by now right?   Just want to make sure I
  try it against a corrected snapshot.
 

 Yeah you can see on the timestamp on the SNAPSHOT JAR being downloaded.

 Though you can build the source yourself and use that
 http://camel.apache.org/building.html

  Ryan
 
 
  On Sat, Mar 2, 2013 at 3:17 PM, Ryan Moquin fragility...@gmail.com
 wrote:
 
  Awesome, was sure I wasn't crazy. :) Happy it's fixed already!
 
  Ryan
  On Feb 28, 2013 3:48 AM, Claus Ibsen claus.ib...@gmail.com wrote:
 
  Hi
 
  Well spotted. I have logged a ticket
  https://issues.apache.org/jira/browse/CAMEL-6111
 
  On Thu, Feb 28, 2013 at 5:32 AM, Ryan Moquin fragility...@gmail.com
  wrote:
   I converted a test that was using the camel-test library to the
   camel-test-blueprint library and it appears that the route runs at
 least
   twice, but at the exact same time.  I'm not sure why each route is
 being
   created more than once per test.  I do see at the beginning of the
 test
  it
   print out that I't loading the bundle activator twice.  I also
  generated a
   sample camel blueprint project from the maven archetype and it
 appears
  to
   exhibit the same behavior.
  
   I'using 2.11-SNAPSHOT btw.  I haven't seen anyone mention this nor
 did I
   see anything in jira about it.  Has anyone noticed anything similar?
I decided I'd have to try using karaf pax exam instead since I just
  can't
   to figure out how to get the blueprint the testing working correctly.
Hopefully someone has seen and gotten past that behavior.
  
   Thanks for any suggestions or help!
  
   Ryan
 
 
 
  --
  Claus Ibsen
  -
  Red Hat, Inc.
  FuseSource is now part of Red Hat
  Email: cib...@redhat.com
  Web: http://fusesource.com
  Twitter: davsclaus
  Blog: http://davsclaus.com
  Author of Camel in Action: http://www.manning.com/ibsen
 
 



 --
 Claus Ibsen
 -
 Red Hat, Inc.
 FuseSource is now part of Red Hat
 Email: cib...@redhat.com
 Web: http://fusesource.com
 Twitter: davsclaus
 Blog: http://davsclaus.com
 Author of Camel in Action: http://www.manning.com/ibsen



CamelContext resume does not reactivate the route

2013-03-08 Thread rajesh_h
Hello experts,

I have a route consuming from file endpoint and then other routes chained
downstream using direct:.

When I get a particular kind of exception, I want to be able to suspend the
CamelContext (camelContext.suspend). And then be able to resume the Context
from JMX. 

Now, what happens is that as soon as I issue suspend context from the
code, it goes through the defaultShutDownStrategy and logs these messages
for 300 seconds (expected).

*INFO.org.apache.camel.impl.DefaultShutdownStrategy:
org.apache.camel.impl.DefaultShutdownStrategy$ShutdownTask.run.523 Waiting
as there are still 5 inflight and pending exchanges to complete, timeout in
43 seconds.*

Not sure why the 5 inflight exchanges are not getting flushed out, but
eventually, times out and suspends the route. 

WARN.org.apache.camel.impl.DefaultShutdownStrategy:
*org.apache.camel.impl.DefaultShutdownStrategy.doShutdown.191 Timeout
occurred. Now forcing the routes to be shutdown now.
WARN.org.apache.camel.impl.DefaultShutdownStrategy:
org.apache.camel.impl.DefaultShutdownStrategy$ShutdownTask.run.531
Interrupted while waiting during graceful shutdown, will force shutdown
now.*
INFO.org.apache.camel.impl.DefaultShutdownStrategy:
org.apache.camel.impl.DefaultShutdownStrategy$ShutdownTask.run.556 Route:
*route-psp1* suspend complete, was consuming from:*
Endpoint[file:///h/apps/proj/input?maxMessagesPerPoll=1noop=falsereadLock=changed*]
INFO.org.apache.camel.impl.DefaultShutdownStrategy:
org.apache.camel.impl.DefaultShutdownStrategy$ShutdownTask.run.556 Route:
route-psp2 suspend complete, was consuming from: Endpoint[direct://csv]
INFO.org.apache.camel.impl.DefaultShutdownStrategy:
org.apache.camel.impl.DefaultShutdownStrategy.doShutdown.213 Graceful
shutdown of 6 routes completed in 300 seconds
INFO.org.apache.camel.impl.DefaultShutdownStrategy:
org.apache.camel.impl.DefaultShutdownStrategy$ShutdownTask.run.556 Route:
route-psp3 suspend complete, was consuming from:
Endpoint[direct://thousands]
INFO.org.apache.camel.spring.SpringCamelContext:
org.apache.camel.impl.DefaultCamelContext.doSuspend.1353 Apache Camel 2.10.3
(CamelContext: rdlCamelContext) is suspended in 5 minutes
INFO.org.apache.camel.impl.DefaultShutdownStrategy:
org.apache.camel.impl.DefaultShutdownStrategy$ShutdownTask.run.556 Route:
route-psp4 suspend complete, was consuming from: Endpoint[direct://update]
INFO.com.paypal.demandgen.rdl.RdlContextController:
com.paypal.demandgen.rdl.RdlContextController.suspend.33 Context suspended
INFO.org.apache.camel.impl.DefaultShutdownStrategy:
org.apache.camel.impl.DefaultShutdownStrategy$ShutdownTask.run.556 Route:
route-psp5 suspend complete, was consuming from:
Endpoint[direct://stopRoute]
INFO.org.apache.camel.impl.DefaultShutdownStrategy:
org.apache.camel.impl.DefaultShutdownStrategy$ShutdownTask.run.556 Route:
route-psp6 suspend complete, was consuming from:
Endpoint[direct://suspendContext]


Even after I resume the context using JMX, my route-psp1 refuses to pick up
files from the input endpoint location.

Can somebody advice me as to what I am doing wrong? I am using Camel 2.10.3.

Thanks in advance
Rajesh



--
View this message in context: 
http://camel.465427.n5.nabble.com/CamelContext-resume-does-not-reactivate-the-route-tp5728862.html
Sent from the Camel - Users mailing list archive at Nabble.com.


Re: sftp and path

2013-03-08 Thread abhaiji
Hi,I am facing same issue with the sftp component. I tried both stepwise true
and false - but it is giving same error. Strangely, I do not get any error
if I do not specify the directory and just read write from logged in user's
home directory. But if I give a nested or single directory it fails with
same error: with stepwise=falseWriting file failed with: Cannot change
directory to: \home\abhaijiwith stepwise=trueWriting file failed with:
Cannot change directory to: \Here is the endpoint I am using:
sftp://u...@myftp.site.com:22/test?passiveMode=truepassword=**separator=UNIXstepwise=falseI
am using camel 2.10 or higher



--
View this message in context: 
http://camel.465427.n5.nabble.com/sftp-and-path-tp5002111p5728848.html
Sent from the Camel - Users mailing list archive at Nabble.com.

How to send Web Service to Oracle using Apache Camel

2013-03-08 Thread takidean
I have to develop an application with Apache Camel which will play the role
of a middle-ware between a platform named w-board and 3 Oracle servers. I
have to receive Web Services from the w-board and then send that message to
a server. I have to identify the destination from the id then route the
message using sockets.

Any recommendations on what tools I should use?



--
View this message in context: 
http://camel.465427.n5.nabble.com/How-to-send-Web-Service-to-Oracle-using-Apache-Camel-tp5728849.html
Sent from the Camel - Users mailing list archive at Nabble.com.