Handle multipart/form-data with REST DSL

2019-02-07 Thread Tim Dudgeon
I'm struggling to work out how best to handle a multipart/form-data 
using the REST DSL.


My first attempt was to use Camel's MIME-Multipart  data handler [1] 
which works, but gave me the problem that it automatically keeps the 
first part of the message (first form field) as the Exchange body, but 
does not copy the Content-Disposition header of the part to the headers 
for the message.
Without the Content-Disposition header I can't tell which form field 
this corresponds to, and the client(s) that send the request do not 
provide the form fields in the same order. Short story - if I could 
guarantee which is the first part then I'd be OK, but I can't.


My next attempt was to use the commons-fileupload package [2] which 
works with the raw HttpServletRequest. But this didn't work as I got an 
IOException with a  'Stream closed' message when trying to read. Seems 
that Camel is somehow getting to the request first?


My third attempt was to use the Servlet API and call 
HttpServletRequst.getParts() method [3] to get the parts, but this 
failed with an IllegalStateException with this message: "Unable to 
process parts as no multi-part configuration has been provided". 
Googling [4] tells me that I need to annotate the servlet with the 
@MultipartConfig annotation, but of course using Camel's REST DSL I 
don't have access to the servlet class.


Any suggestions for how to handle this. To summarise the needs:
1. need to handle the form fields in any order
2. some of the parts can be large in size so I need an approach that 
streams the data or does not keep it in memory.



[1] http://camel.apache.org/mime-multipart.html
[2] https://commons.apache.org/proper/commons-fileupload/
[3] 
https://docs.oracle.com/javaee/7/api/javax/servlet/http/HttpServletRequest.html#getParts--
[4] 
https://www.moreofless.co.uk/unable-process-parts-no-multi-part-configuration-provided/




Re: HTTP response is not being chunked

2019-01-23 Thread Tim Dudgeon

For the record, I created this issue to try resolve this:
https://issues.apache.org/jira/browse/CAMEL-13092

On 16/01/2019 18:48, Luiz Eduardo Valmont wrote:

Hi Tim!

Sorry about the delay. I was summoned into a meeting that took a while.
Plus my PC is in the process of upgrading from Debian 9 to Debian
10/testing.

On the important matter.

There are certainly differences when it comes to headers. But I suspect the
culprit is the accept-encoding. I don't think it's the Camel headers.

I believe because it has to compress the content, it has to read everything
beforehand. Try adding "-H 'Accept-Encoding: gzip'" (double quotes
excluded) to your curl command and see if it changes the actual behaviour.

If it does, then you'll have to configure your client accordingly.

In any case, you can emulate the Async request in full by configuring the
headers with curl's "-H" parameter.

HTH


On Wed, 16 Jan 2019, 15:17 Tim Dudgeon 
Hi Luiz,

here are the request headers. For Apache HTTPClient:

accept -> chemical/x-mdl-sdfile
accept-encoding -> gzip
breadcrumbId -> ID-6667e3dab68a-38877-1547658276076-0-15
CamelHttpMethod -> POST
CamelHttpPath ->
CamelHttpQuery -> null
CamelHttpServletRequest ->
org.apache.catalina.connector.RequestFacade@7551baa3
CamelHttpServletResponse ->
org.apache.catalina.connector.ResponseFacade@60e05546
CamelHttpUri ->
/chem-services-cdk-basic/rest/v1/converters/dataset_to_sdf
CamelHttpUrl ->

http://localhost:8092/chem-services-cdk-basic/rest/v1/converters/dataset_to_sdf
CamelServletContextPath -> /v1/converters/dataset_to_sdf
connection -> Keep-Alive
content-encoding -> gzip
Content-Type -> application/x-squonk-dataset-molecule+json
host -> localhost:8092
transfer-encoding -> chunked
user-agent -> Apache-HttpAsyncClient/4.1.4 (Java/1.8.0_191)

For curl:

accept -> chemical/x-mdl-sdfile
breadcrumbId -> ID-09b7601451a2-34027-1547658868812-0-15
CamelHttpMethod -> POST
CamelHttpPath ->
CamelHttpQuery -> null
CamelHttpServletRequest ->
org.apache.catalina.connector.RequestFacade@3af9ee39
CamelHttpServletResponse ->
org.apache.catalina.connector.ResponseFacade@1f33d20b
CamelHttpUri ->
/chem-services-cdk-basic/rest/v1/converters/dataset_to_sdf
CamelHttpUrl ->

http://localhost:8092/chem-services-cdk-basic/rest/v1/converters/dataset_to_sdf
CamelServletContextPath -> /v1/converters/dataset_to_sdf
content-encoding -> gzip
content-length -> 19397182
Content-Type -> application/x-squonk-dataset-molecule+json
expect -> 100-continue
host -> localhost:8092
user-agent -> curl/7.55.1


On 16/01/2019 16:55, Luiz Eduardo Valmont wrote:

Hi, Tim!

I'd suggest trying to intercept / dump the HttpAsyncClient request as

well

as the curl one. A simple "nc -l -p " in an *NIX OS will do.

My guess is that the perceived difference lies in the request headers.
Might be in the Accept.

Can you post both requests in full, body excluded?

Thanks!

On Wed, 16 Jan 2019, 14:46 Tim Dudgeon 
I'm hitting a strange problem with a route that is using the servlet
component to send a large stream of data in its response.
This is part of a route that uses the REST DSL which is set up like

this:

restConfiguration().component("servlet").host("0.0.0.0");

The route sets the response body as an PipedInputStream and then (in a
separate thread) writes to that InputStream and eventually closes it.
The expectation is that as the response size is unknown the data will be
chunked and response returned to the client immediately and the client
will start to consume the data immediately.

When using curl as the client it seems to be working correctly, and I
see a 'Transfer-Encoding: chunked' header in the response.

However my real client is Apache HttpAsyncClient and with that what I'm
seeing is that the response is not returned until all the data is
written, and instead of a 'Transfer-Encoding: chunked' header I see a
'Content-Length: 19196336' header suggesting that Camel has waited for
the entire content to be written so that it can set the Content-Length.
I tried manually setting the 'Transfer-Encoding: chunked' in the
response message but it did not appear and instead I saw the
Content-Length header.
I've got HttpAsyncClient working in a test example to prove that it can
received the response asynchronously, so I think (but can't be sure)
that the problem is on the server (Camel) side.

What can explain this different behaviour from the same service when
using different clients?




Re: HTTP response is not being chunked

2019-01-17 Thread Tim Dudgeon
So on further reflection it seems that there should be an option that 
allows to control this - it's not reasonable that when you turn on gzip 
compression for a response that the entire content gets cached so that 
the Content-Length can be determined, especially when you've specified 
that you want Transfer-Encoding to be chunked.


So either I'm not aware of any option that allows this, or alternatively 
it could really be considered a bug.


Can any Camel guru comment on this?

BTW - I'm using Camel 2.18.0 which I know is a little old.

Tim

On 17/01/2019 07:44, Tim Dudgeon wrote:
Yes, you are right - the 'Accept-Encoding: gzip' header is the cause. 
Adding that to the curl request causes the response to block, while 
removing it from Apache HTTP client request prevents the response 
blocking.


But I'm not sure why this would be the case. Gzip compression is 
something that can be done of a streaming basis so there should be no 
need to read the entire dataset.


Turning off compression will have a big performance impact!

Tim

On 16/01/2019 18:48, Luiz Eduardo Valmont wrote:

Hi Tim!

Sorry about the delay. I was summoned into a meeting that took a while.
Plus my PC is in the process of upgrading from Debian 9 to Debian
10/testing.

On the important matter.

There are certainly differences when it comes to headers. But I 
suspect the

culprit is the accept-encoding. I don't think it's the Camel headers.

I believe because it has to compress the content, it has to read 
everything

beforehand. Try adding "-H 'Accept-Encoding: gzip'" (double quotes
excluded) to your curl command and see if it changes the actual 
behaviour.


If it does, then you'll have to configure your client accordingly.

In any case, you can emulate the Async request in full by configuring 
the

headers with curl's "-H" parameter.

HTH


On Wed, 16 Jan 2019, 15:17 Tim Dudgeon 
Hi Luiz,

here are the request headers. For Apache HTTPClient:

    accept -> chemical/x-mdl-sdfile
    accept-encoding -> gzip
    breadcrumbId -> ID-6667e3dab68a-38877-1547658276076-0-15
    CamelHttpMethod -> POST
    CamelHttpPath ->
    CamelHttpQuery -> null
    CamelHttpServletRequest ->
org.apache.catalina.connector.RequestFacade@7551baa3
    CamelHttpServletResponse ->
org.apache.catalina.connector.ResponseFacade@60e05546
    CamelHttpUri ->
/chem-services-cdk-basic/rest/v1/converters/dataset_to_sdf
    CamelHttpUrl ->

http://localhost:8092/chem-services-cdk-basic/rest/v1/converters/dataset_to_sdf 


    CamelServletContextPath -> /v1/converters/dataset_to_sdf
    connection -> Keep-Alive
    content-encoding -> gzip
    Content-Type -> application/x-squonk-dataset-molecule+json
    host -> localhost:8092
    transfer-encoding -> chunked
    user-agent -> Apache-HttpAsyncClient/4.1.4 (Java/1.8.0_191)

For curl:

    accept -> chemical/x-mdl-sdfile
    breadcrumbId -> ID-09b7601451a2-34027-1547658868812-0-15
    CamelHttpMethod -> POST
    CamelHttpPath ->
    CamelHttpQuery -> null
    CamelHttpServletRequest ->
org.apache.catalina.connector.RequestFacade@3af9ee39
    CamelHttpServletResponse ->
org.apache.catalina.connector.ResponseFacade@1f33d20b
    CamelHttpUri ->
/chem-services-cdk-basic/rest/v1/converters/dataset_to_sdf
    CamelHttpUrl ->

http://localhost:8092/chem-services-cdk-basic/rest/v1/converters/dataset_to_sdf 


    CamelServletContextPath -> /v1/converters/dataset_to_sdf
    content-encoding -> gzip
    content-length -> 19397182
    Content-Type -> application/x-squonk-dataset-molecule+json
    expect -> 100-continue
    host -> localhost:8092
    user-agent -> curl/7.55.1


On 16/01/2019 16:55, Luiz Eduardo Valmont wrote:

Hi, Tim!

I'd suggest trying to intercept / dump the HttpAsyncClient request as

well

as the curl one. A simple "nc -l -p " in an *NIX OS will do.

My guess is that the perceived difference lies in the request headers.
Might be in the Accept.

Can you post both requests in full, body excluded?

Thanks!

On Wed, 16 Jan 2019, 14:46 Tim Dudgeon 
I'm hitting a strange problem with a route that is using the servlet
component to send a large stream of data in its response.
This is part of a route that uses the REST DSL which is set up like

this:

restConfiguration().component("servlet").host("0.0.0.0");

The route sets the response body as an PipedInputStream and then 
(in a

separate thread) writes to that InputStream and eventually closes it.
The expectation is that as the response size is unknown the data 
will be
chunked and response returned to the client immediately and the 
client

will start to consume the data immediately.

When using curl as the client it seems to be working correctly, and I
see a 'Transfer-Encoding: chunked' header in the response.

However my real clie

Re: HTTP response is not being chunked

2019-01-16 Thread Tim Dudgeon
Yes, you are right - the 'Accept-Encoding: gzip' header is the cause. 
Adding that to the curl request causes the response to block, while 
removing it from Apache HTTP client request prevents the response blocking.


But I'm not sure why this would be the case. Gzip compression is 
something that can be done of a streaming basis so there should be no 
need to read the entire dataset.


Turning off compression will have a big performance impact!

Tim

On 16/01/2019 18:48, Luiz Eduardo Valmont wrote:

Hi Tim!

Sorry about the delay. I was summoned into a meeting that took a while.
Plus my PC is in the process of upgrading from Debian 9 to Debian
10/testing.

On the important matter.

There are certainly differences when it comes to headers. But I suspect the
culprit is the accept-encoding. I don't think it's the Camel headers.

I believe because it has to compress the content, it has to read everything
beforehand. Try adding "-H 'Accept-Encoding: gzip'" (double quotes
excluded) to your curl command and see if it changes the actual behaviour.

If it does, then you'll have to configure your client accordingly.

In any case, you can emulate the Async request in full by configuring the
headers with curl's "-H" parameter.

HTH


On Wed, 16 Jan 2019, 15:17 Tim Dudgeon 
Hi Luiz,

here are the request headers. For Apache HTTPClient:

accept -> chemical/x-mdl-sdfile
accept-encoding -> gzip
breadcrumbId -> ID-6667e3dab68a-38877-1547658276076-0-15
CamelHttpMethod -> POST
CamelHttpPath ->
CamelHttpQuery -> null
CamelHttpServletRequest ->
org.apache.catalina.connector.RequestFacade@7551baa3
CamelHttpServletResponse ->
org.apache.catalina.connector.ResponseFacade@60e05546
CamelHttpUri ->
/chem-services-cdk-basic/rest/v1/converters/dataset_to_sdf
CamelHttpUrl ->

http://localhost:8092/chem-services-cdk-basic/rest/v1/converters/dataset_to_sdf
CamelServletContextPath -> /v1/converters/dataset_to_sdf
connection -> Keep-Alive
content-encoding -> gzip
Content-Type -> application/x-squonk-dataset-molecule+json
host -> localhost:8092
transfer-encoding -> chunked
user-agent -> Apache-HttpAsyncClient/4.1.4 (Java/1.8.0_191)

For curl:

accept -> chemical/x-mdl-sdfile
breadcrumbId -> ID-09b7601451a2-34027-1547658868812-0-15
CamelHttpMethod -> POST
CamelHttpPath ->
CamelHttpQuery -> null
CamelHttpServletRequest ->
org.apache.catalina.connector.RequestFacade@3af9ee39
CamelHttpServletResponse ->
org.apache.catalina.connector.ResponseFacade@1f33d20b
CamelHttpUri ->
/chem-services-cdk-basic/rest/v1/converters/dataset_to_sdf
CamelHttpUrl ->

http://localhost:8092/chem-services-cdk-basic/rest/v1/converters/dataset_to_sdf
CamelServletContextPath -> /v1/converters/dataset_to_sdf
content-encoding -> gzip
content-length -> 19397182
Content-Type -> application/x-squonk-dataset-molecule+json
expect -> 100-continue
host -> localhost:8092
user-agent -> curl/7.55.1


On 16/01/2019 16:55, Luiz Eduardo Valmont wrote:

Hi, Tim!

I'd suggest trying to intercept / dump the HttpAsyncClient request as

well

as the curl one. A simple "nc -l -p " in an *NIX OS will do.

My guess is that the perceived difference lies in the request headers.
Might be in the Accept.

Can you post both requests in full, body excluded?

Thanks!

On Wed, 16 Jan 2019, 14:46 Tim Dudgeon 
I'm hitting a strange problem with a route that is using the servlet
component to send a large stream of data in its response.
This is part of a route that uses the REST DSL which is set up like

this:

restConfiguration().component("servlet").host("0.0.0.0");

The route sets the response body as an PipedInputStream and then (in a
separate thread) writes to that InputStream and eventually closes it.
The expectation is that as the response size is unknown the data will be
chunked and response returned to the client immediately and the client
will start to consume the data immediately.

When using curl as the client it seems to be working correctly, and I
see a 'Transfer-Encoding: chunked' header in the response.

However my real client is Apache HttpAsyncClient and with that what I'm
seeing is that the response is not returned until all the data is
written, and instead of a 'Transfer-Encoding: chunked' header I see a
'Content-Length: 19196336' header suggesting that Camel has waited for
the entire content to be written so that it can set the Content-Length.
I tried manually setting the 'Transfer-Encoding: chunked' in the
response message but it did not appear and instead I saw the
Content-Length header.
I've got HttpAsyncClient working in a test example to prove that it can
received the response asynchronously, so I think (but can't be sure)
that the problem is on the server (Camel) side.

What can explain this different behaviour from the same service when
using different clients?




Re: HTTP response is not being chunked

2019-01-16 Thread Tim Dudgeon

Hi Luiz,

here are the request headers. For Apache HTTPClient:

  accept -> chemical/x-mdl-sdfile
  accept-encoding -> gzip
  breadcrumbId -> ID-6667e3dab68a-38877-1547658276076-0-15
  CamelHttpMethod -> POST
  CamelHttpPath ->
  CamelHttpQuery -> null
  CamelHttpServletRequest -> 
org.apache.catalina.connector.RequestFacade@7551baa3
  CamelHttpServletResponse -> 
org.apache.catalina.connector.ResponseFacade@60e05546
  CamelHttpUri -> 
/chem-services-cdk-basic/rest/v1/converters/dataset_to_sdf
  CamelHttpUrl -> 
http://localhost:8092/chem-services-cdk-basic/rest/v1/converters/dataset_to_sdf

  CamelServletContextPath -> /v1/converters/dataset_to_sdf
  connection -> Keep-Alive
  content-encoding -> gzip
  Content-Type -> application/x-squonk-dataset-molecule+json
  host -> localhost:8092
  transfer-encoding -> chunked
  user-agent -> Apache-HttpAsyncClient/4.1.4 (Java/1.8.0_191)

For curl:

  accept -> chemical/x-mdl-sdfile
  breadcrumbId -> ID-09b7601451a2-34027-1547658868812-0-15
  CamelHttpMethod -> POST
  CamelHttpPath ->
  CamelHttpQuery -> null
  CamelHttpServletRequest -> 
org.apache.catalina.connector.RequestFacade@3af9ee39
  CamelHttpServletResponse -> 
org.apache.catalina.connector.ResponseFacade@1f33d20b
  CamelHttpUri -> 
/chem-services-cdk-basic/rest/v1/converters/dataset_to_sdf
  CamelHttpUrl -> 
http://localhost:8092/chem-services-cdk-basic/rest/v1/converters/dataset_to_sdf

  CamelServletContextPath -> /v1/converters/dataset_to_sdf
  content-encoding -> gzip
  content-length -> 19397182
  Content-Type -> application/x-squonk-dataset-molecule+json
  expect -> 100-continue
  host -> localhost:8092
  user-agent -> curl/7.55.1


On 16/01/2019 16:55, Luiz Eduardo Valmont wrote:

Hi, Tim!

I'd suggest trying to intercept / dump the HttpAsyncClient request as well
as the curl one. A simple "nc -l -p " in an *NIX OS will do.

My guess is that the perceived difference lies in the request headers.
Might be in the Accept.

Can you post both requests in full, body excluded?

Thanks!

On Wed, 16 Jan 2019, 14:46 Tim Dudgeon 
I'm hitting a strange problem with a route that is using the servlet
component to send a large stream of data in its response.
This is part of a route that uses the REST DSL which is set up like this:

restConfiguration().component("servlet").host("0.0.0.0");

The route sets the response body as an PipedInputStream and then (in a
separate thread) writes to that InputStream and eventually closes it.
The expectation is that as the response size is unknown the data will be
chunked and response returned to the client immediately and the client
will start to consume the data immediately.

When using curl as the client it seems to be working correctly, and I
see a 'Transfer-Encoding: chunked' header in the response.

However my real client is Apache HttpAsyncClient and with that what I'm
seeing is that the response is not returned until all the data is
written, and instead of a 'Transfer-Encoding: chunked' header I see a
'Content-Length: 19196336' header suggesting that Camel has waited for
the entire content to be written so that it can set the Content-Length.
I tried manually setting the 'Transfer-Encoding: chunked' in the
response message but it did not appear and instead I saw the
Content-Length header.
I've got HttpAsyncClient working in a test example to prove that it can
received the response asynchronously, so I think (but can't be sure)
that the problem is on the server (Camel) side.

What can explain this different behaviour from the same service when
using different clients?




HTTP response is not being chunked

2019-01-16 Thread Tim Dudgeon
I'm hitting a strange problem with a route that is using the servlet 
component to send a large stream of data in its response.

This is part of a route that uses the REST DSL which is set up like this:

restConfiguration().component("servlet").host("0.0.0.0");

The route sets the response body as an PipedInputStream and then (in a 
separate thread) writes to that InputStream and eventually closes it.
The expectation is that as the response size is unknown the data will be 
chunked and response returned to the client immediately and the client 
will start to consume the data immediately.


When using curl as the client it seems to be working correctly, and I 
see a 'Transfer-Encoding: chunked' header in the response.


However my real client is Apache HttpAsyncClient and with that what I'm 
seeing is that the response is not returned until all the data is 
written, and instead of a 'Transfer-Encoding: chunked' header I see a 
'Content-Length: 19196336' header suggesting that Camel has waited for 
the entire content to be written so that it can set the Content-Length. 
I tried manually setting the 'Transfer-Encoding: chunked' in the 
response message but it did not appear and instead I saw the 
Content-Length header.
I've got HttpAsyncClient working in a test example to prove that it can 
received the response asynchronously, so I think (but can't be sure) 
that the problem is on the server (Camel) side.


What can explain this different behaviour from the same service when 
using different clients?




Re: reading multipart mime dataformat

2018-06-08 Thread Tim Dudgeon

Here is the example:

https://github.com/tdudgeon/camel-cdi-servlet-example


On 08/06/18 09:44, Claus Ibsen wrote:

Hi Tom

I am afraid what we have is the docs you can find, but they are more
up to date on github
https://github.com/apache/camel/blob/master/components/camel-mail/src/main/docs/mime-multipart-dataformat.adoc

If you can build an unit test - reproducer sample project you are
welcome to log a JIRA and attach - link to that.
Also if possible try to test with latest released version.

We should try to get this fixed so it works via a plain curl command.


On Thu, Jun 7, 2018 at 6:00 PM, Tim Dudgeon  wrote:

I'm wanting to send a small set of files to a HTTP server as a POST request
and have Camel handle the request.

Seems like one way of doing this is to use curl on the sending end to create
the POST request and have the Camel MIME-Multipart data format [1] handle
the request on the receiving end. So I set up a simple test. My camel route
contains this:

 rest("/multi/")
 .produces("text/plain")
 .post()
 .route()
 .log("POSTed data\n${body}")
 .unmarshal().mimeMultipart()
 .log("${body}")
 .transform(constant("OK\n"))
 .endRest();

On the sending end I post some simple test data like this:

 curl -X POST -F name=superman -F power=flying
"http://localhost:8080/path/to/multi/";

This generates a body that looks like this:

--77d51bae19fb6cc5
Content-Disposition: form-data; name="name"

Superman
--77d51bae19fb6cc5
Content-Disposition: form-data; name="power"

flying
--77d51bae19fb6cc5--


But Camel fails to handle this with this error:

javax.mail.internet.ParseException: Missing start boundary
 at javax.mail.internet.MimeMultipart.parse(MimeMultipart.java:691)
 at
javax.mail.internet.MimeMultipart.getBodyPart(MimeMultipart.java:350)
 at
org.apache.camel.dataformat.mime.multipart.MimeMultipartDataFormat.unmarshal(MimeMultipartDataFormat.java:246)
 at
org.apache.camel.processor.UnmarshalProcessor.process(UnmarshalProcessor.java:69)


Any hints on how to get this working? The documentation page doesn't contain
much info for reading multipart requests, only writing them :-(


[1] http://camel.apache.org/mime-multipart.html








Re: reading multipart mime dataformat

2018-06-08 Thread Tim Dudgeon

Actually I got it working. I'll post an example once I've got it sorted.

Tim


On 08/06/18 09:44, Claus Ibsen wrote:

Hi Tom

I am afraid what we have is the docs you can find, but they are more
up to date on github
https://github.com/apache/camel/blob/master/components/camel-mail/src/main/docs/mime-multipart-dataformat.adoc

If you can build an unit test - reproducer sample project you are
welcome to log a JIRA and attach - link to that.
Also if possible try to test with latest released version.

We should try to get this fixed so it works via a plain curl command.


On Thu, Jun 7, 2018 at 6:00 PM, Tim Dudgeon  wrote:

I'm wanting to send a small set of files to a HTTP server as a POST request
and have Camel handle the request.

Seems like one way of doing this is to use curl on the sending end to create
the POST request and have the Camel MIME-Multipart data format [1] handle
the request on the receiving end. So I set up a simple test. My camel route
contains this:

 rest("/multi/")
 .produces("text/plain")
 .post()
 .route()
 .log("POSTed data\n${body}")
 .unmarshal().mimeMultipart()
 .log("${body}")
 .transform(constant("OK\n"))
 .endRest();

On the sending end I post some simple test data like this:

 curl -X POST -F name=superman -F power=flying
"http://localhost:8080/path/to/multi/";

This generates a body that looks like this:

--77d51bae19fb6cc5
Content-Disposition: form-data; name="name"

Superman
--77d51bae19fb6cc5
Content-Disposition: form-data; name="power"

flying
--77d51bae19fb6cc5--


But Camel fails to handle this with this error:

javax.mail.internet.ParseException: Missing start boundary
 at javax.mail.internet.MimeMultipart.parse(MimeMultipart.java:691)
 at
javax.mail.internet.MimeMultipart.getBodyPart(MimeMultipart.java:350)
 at
org.apache.camel.dataformat.mime.multipart.MimeMultipartDataFormat.unmarshal(MimeMultipartDataFormat.java:246)
 at
org.apache.camel.processor.UnmarshalProcessor.process(UnmarshalProcessor.java:69)


Any hints on how to get this working? The documentation page doesn't contain
much info for reading multipart requests, only writing them :-(


[1] http://camel.apache.org/mime-multipart.html








reading multipart mime dataformat

2018-06-07 Thread Tim Dudgeon
I'm wanting to send a small set of files to a HTTP server as a POST 
request and have Camel handle the request.


Seems like one way of doing this is to use curl on the sending end to 
create the POST request and have the Camel MIME-Multipart data format 
[1] handle the request on the receiving end. So I set up a simple test. 
My camel route contains this:


    rest("/multi/")
    .produces("text/plain")
    .post()
    .route()
    .log("POSTed data\n${body}")
    .unmarshal().mimeMultipart()
    .log("${body}")
    .transform(constant("OK\n"))
    .endRest();

On the sending end I post some simple test data like this:

    curl -X POST -F name=superman -F power=flying 
"http://localhost:8080/path/to/multi/";


This generates a body that looks like this:

--77d51bae19fb6cc5
Content-Disposition: form-data; name="name"

Superman
--77d51bae19fb6cc5
Content-Disposition: form-data; name="power"

flying
--77d51bae19fb6cc5--


But Camel fails to handle this with this error:

javax.mail.internet.ParseException: Missing start boundary
    at javax.mail.internet.MimeMultipart.parse(MimeMultipart.java:691)
    at 
javax.mail.internet.MimeMultipart.getBodyPart(MimeMultipart.java:350)
    at 
org.apache.camel.dataformat.mime.multipart.MimeMultipartDataFormat.unmarshal(MimeMultipartDataFormat.java:246)
    at 
org.apache.camel.processor.UnmarshalProcessor.process(UnmarshalProcessor.java:69)



Any hints on how to get this working? The documentation page doesn't 
contain much info for reading multipart requests, only writing them :-(



[1] http://camel.apache.org/mime-multipart.html



Re: host not found when using http4 in docker container

2018-06-06 Thread Tim Dudgeon

OK, I think I worked out how to resolve this.
It seems you need to have a `depends_on` property in the container that 
is posting the HTTP request. The service that is receiving the request 
need to be present in the `depends_on` otherwise Java cannot resolve the 
host names (even though the operating system can). e.g. in my case I 
needed to specify something like this:


    depends_on:
    coreservices:
    condition: service_healthy

Clearly a Docker and Java thing, not really anything to do with Camel or 
the HTTP4 component.

But very strange nonetheless!


On 06/06/18 04:35, Willem Jiang wrote:

Can  you add a link  to the camel container just like this ?

camel:
image: "camel:0.3.0-SNAPSHOT"
hostname: camel
links:
- "otherHost"
- "zipkin:zipkin.io"


Willem Jiang

Twitter: willemjiang
Weibo: 姜宁willem

On Wed, Jun 6, 2018 at 4:40 AM, Tim Dudgeon  wrote:


On 05/06/18 20:40, Robin Vanderhallen wrote:


Are both containers in the same network in the docker compose file?


Yes. Both are in the same network environment, but this is not the default
network.

 networks:
 - xxx

Tim





Re: host not found when using http4 in docker container

2018-06-06 Thread Tim Dudgeon
I don't see how that would help (and the links attribute is a legacy 
feature and not recommended).


My situation is that the two containers are on the same network and can 
see each other. e.g. you can open a shell in one and ping the other 
using its hostname.

So the networking at the container level is perfectly OK.

The problem is that when using the HTTP4 camel component the same 
hostname does not get resolved. It looks like this is being done by the 
org.apache.http.impl.conn.SystemDefaultDnsResolver class in 
httpcomponents [1] which states in its docs: "DNS resolver that uses the 
default OS implementation for resolving host names." But it seems like 
it doesn't do this correctly?



[1] 
https://hc.apache.org/httpcomponents-client-ga/httpclient/apidocs/org/apache/http/impl/conn/SystemDefaultDnsResolver.html


On 06/06/18 04:35, Willem Jiang wrote:

Can  you add a link  to the camel container just like this ?

camel:
image: "camel:0.3.0-SNAPSHOT"
hostname: camel
links:
- "otherHost"
- "zipkin:zipkin.io"


Willem Jiang

Twitter: willemjiang
Weibo: 姜宁willem

On Wed, Jun 6, 2018 at 4:40 AM, Tim Dudgeon  wrote:


On 05/06/18 20:40, Robin Vanderhallen wrote:


Are both containers in the same network in the docker compose file?


Yes. Both are in the same network environment, but this is not the default
network.

 networks:
 - xxx

Tim





Re: host not found when using http4 in docker container

2018-06-05 Thread Tim Dudgeon

On 05/06/18 20:40, Robin Vanderhallen wrote:

Are both containers in the same network in the docker compose file?
Yes. Both are in the same network environment, but this is not the 
default network.


    networks:
    - xxx

Tim


host not found when using http4 in docker container

2018-06-05 Thread Tim Dudgeon
I'm running camel inside a Docker container and trying to use the HTTP4 
component to post a request to a service running in a different 
container (both containers are managed through Docker compose).

Essentially I'm trying to do a post to a route like this:
http4:coreservices:8080/coreservices/rest/v1/services
where coreservices is the name of the other container.

This fails with a  java.net.UnknownHostException (see below).
But the other container is definitely accessible from this container as 
if I open a shell in it I can the curl the 'coreservices' host.


Any idea what's going wrong here?

Thanks
Tim


05-Jun-2018 17:09:34.667 SEVERE [localhost-startStop-1] 
org.apache.camel.util.CamelLogger.log Failed delivery for (MessageId: 
ID-4b81ce1e6383-46459-1528218572076-1-3 on ExchangeId: 
ID-4b81ce1e6383-46459-1528218572076-1-2). Exhausted after delivery 
attempt: 1 caught: java.net.UnknownHostException: coreservices: Name or 
service not known


Message History
---
RouteId  ProcessorId Processor Elapsed (ms)
[route6    ] [route6    ] 
[direct://post-service-descriptors ] [   283]

[route6    ] [log1  ] [log ] [ 5]
[route6    ] [process1  ] [Processor@0xa8e9d5 ] [   173]
[route6    ] [to1   ] 
[http4:coreservices:8080/coreservices/rest/v1/services ] [    95]


Stacktrace
---
 java.net.UnknownHostException: coreservices: Name or service not known
    at java.net.Inet4AddressImpl.lookupAllHostAddr(Native Method)
    at java.net.InetAddress$2.lookupAllHostAddr(InetAddress.java:928)
    at 
java.net.InetAddress.getAddressesFromNameService(InetAddress.java:1323)

    at java.net.InetAddress.getAllByName0(InetAddress.java:1276)
    at java.net.InetAddress.getAllByName(InetAddress.java:1192)
    at java.net.InetAddress.getAllByName(InetAddress.java:1126)
    at 
org.apache.http.impl.conn.SystemDefaultDnsResolver.resolve(SystemDefaultDnsResolver.java:45)
    at 
org.apache.http.impl.conn.DefaultHttpClientConnectionOperator.connect(DefaultHttpClientConnectionOperator.java:111)
    at 
org.apache.http.impl.conn.PoolingHttpClientConnectionManager.connect(PoolingHttpClientConnectionManager.java:353)
    at 
org.apache.http.impl.execchain.MainClientExec.establishRoute(MainClientExec.java:380)
    at 
org.apache.http.impl.execchain.MainClientExec.execute(MainClientExec.java:236)
    at 
org.apache.http.impl.execchain.ProtocolExec.execute(ProtocolExec.java:184)

    at org.apache.http.impl.execchain.RetryExec.execute(RetryExec.java:88)
    at 
org.apache.http.impl.execchain.RedirectExec.execute(RedirectExec.java:110)
    at 
org.apache.http.impl.client.InternalHttpClient.doExecute(InternalHttpClient.java:184)
    at 
org.apache.http.impl.client.CloseableHttpClient.execute(CloseableHttpClient.java:82)
    at 
org.apache.http.impl.client.CloseableHttpClient.execute(CloseableHttpClient.java:55)
    at 
org.apache.camel.component.http4.HttpProducer.executeMethod(HttpProducer.java:306)
    at 
org.apache.camel.component.http4.HttpProducer.process(HttpProducer.java:178)
    at 
org.apache.camel.util.AsyncProcessorConverterHelper$ProcessorToAsyncProcessorBridge.process(AsyncProcessorConverterHelper.java:61)
    at 
org.apache.camel.processor.SendProcessor.process(SendProcessor.java:145)
    at 
org.apache.camel.management.InstrumentationProcessor.process(InstrumentationProcessor.java:77)
    at 
org.apache.camel.processor.RedeliveryErrorHandler.process(RedeliveryErrorHandler.java:542)
    at 
org.apache.camel.processor.CamelInternalProcessor.process(CamelInternalProcessor.java:197)

    at org.apache.camel.processor.Pipeline.process(Pipeline.java:120)
    at org.apache.camel.processor.Pipeline.process(Pipeline.java:83)
    at 
org.apache.camel.processor.CamelInternalProcessor.process(CamelInternalProcessor.java:197)
    at 
org.apache.camel.component.direct.DirectProducer.process(DirectProducer.java:62)
    at 
org.apache.camel.processor.CamelInternalProcessor.process(CamelInternalProcessor.java:197)
    at 
org.apache.camel.processor.DelegateAsyncProcessor.process(DelegateAsyncProcessor.java:97)
    at 
org.apache.camel.impl.ProducerCache$1.doInProducer(ProducerCache.java:529)
    at 
org.apache.camel.impl.ProducerCache$1.doInProducer(ProducerCache.java:497)
    at 
org.apache.camel.impl.ProducerCache.doInProducer(ProducerCache.java:365)
    at 
org.apache.camel.impl.ProducerCache.sendExchange(ProducerCache.java:497)

    at org.apache.camel.impl.ProducerCache.send(ProducerCache.java:242)
    at 
org.apache.camel.impl.DefaultProducerTemplate.send(DefaultProducerTemplate.java:148)
    at 
org.apache.camel.impl.DefaultProducerTemplate.sendBody(DefaultProducerTempl

Writing to message body

2017-12-11 Thread Tim Dudgeon
I have a payload that is generated in a Camel Processor that allows its 
data to be obtained with a writeTo(OutputStream out) method.


Is there an easy way to use this to write to the output Message's body 
using this method?
e.g. Normally you might have an InputStream and and set it using 
something like exchange.getOut().setBody(inputStream), but here I have 
something that writes to an OutputSteam.


I know I can used a java.io.PipedInputStream if necessary but thinking 
there should be an easier way.




Re: MIME-Mutipart DataFormat streaming?

2017-12-11 Thread Tim Dudgeon

Following up on this again (after a long delay).

I tried using the MIME-Multipart DataFormat to send and hit a problem 
when the input stream for an attachment cannot be read multiple times. 
It looks like in the MimeMultipartDataFormat.marshal( ... ) method [1] 
this InputStream for an attachment is read on both of these lines:


Line 140: mm.saveChanges();
Line 154: mm.writeTo(stream, headers.toArray(new String[0]));

When using input that can be read repeatedly (e.g. ByteArrayInputStream) 
it works fine. When using an InputStream that can only be consumed once 
then it blows up the second time it is read.


I recognise that when reading a mulitpart message there can be 
complications, but when writing one it should be possible to do this by 
only reading the input once, so I believe this should be considered a bug.


Shall I raise an issue for this?

[1] 
https://github.com/apache/camel/blob/master/components/camel-mail/src/main/java/org/apache/camel/dataformat/mime/multipart/MimeMultipartDataFormat.java#L92:L160



On 26/10/16 06:43, Siano, Stephan wrote:

Hi Tim,

The MIME-Multipart DataFormat uses javamail as the underlying technology. The 
DataFormat is using streaming as far as the DataFormat is concerned, but I fear 
that javamail as such keeps a lot of stuff in memory so there is very likely no 
full streaming with that component available. For marshalling this might work 
with streaming as long as the component providing the Camel Message with its 
attachments is stream capbable, but for unmarshalling, I think that the 
javamail component will create ByteArrayDataSources at least for the 
attachments.

Best regards
Stephan

-Original Message-
From: Tim Dudgeon [mailto:tdudgeon...@gmail.com]
Sent: Dienstag, 25. Oktober 2016 14:21
To: users@camel.apache.org
Subject: MIME-Mutipart DataFormat streaming?

I was looking at the MIME-Mutipart DataFormat and it looks very useful:
https://camel.apache.org/mime-multipart.html

But I was not sure if it fully streams the data for the body and
attachments, or whether it holds the content in memory (this is for both
marshalling and unmarshalling).

Thanks
Tim





Re: Specifying file names using Dropbox component

2017-01-30 Thread Tim Dudgeon
JIRA issue: https://issues.apache.org/jira/browse/CAMEL-10768



--
View this message in context: 
http://camel.465427.n5.nabble.com/Specifying-file-names-using-Dropbox-component-tp5793105p5793222.html
Sent from the Camel - Users mailing list archive at Nabble.com.


Specifying file names using Dropbox component

2017-01-27 Thread Tim Dudgeon
I'm trying to use the Dropbox component and got the basics working.
The docs for this component suggest that when working with files (e.g. using
the get operation) the file name have to be included in the route URL e.g.
like this:
to("dropbox://get?accessToken=XXX&clientIdentifier=XXX&remotePath=/root/folder1/file1.tar.gz")

There is no mention of being able to specify this information as headers, as
in most similar components (file, box ...). Is this not supported in the
Dropbox component? If so then its not really useful for much.

Thanks
Tim



--
View this message in context: 
http://camel.465427.n5.nabble.com/Specifying-file-names-using-Dropbox-component-tp5793105.html
Sent from the Camel - Users mailing list archive at Nabble.com.


Re: Using Box component

2017-01-27 Thread Tim Dudgeon
So I looked at using Dropbox instead, and found that Camel is using a
deprecated version of that API that will be turned off this year.
I created https://issues.apache.org/jira/browse/CAMEL-10754 for this.



--
View this message in context: 
http://camel.465427.n5.nabble.com/Using-Box-component-tp5792922p5793104.html
Sent from the Camel - Users mailing list archive at Nabble.com.


Re: Using Box component

2017-01-27 Thread Tim Dudgeon
Here is the JIRA issue:
https://issues.apache.org/jira/browse/CAMEL-10753



--
View this message in context: 
http://camel.465427.n5.nabble.com/Using-Box-component-tp5792922p5793098.html
Sent from the Camel - Users mailing list archive at Nabble.com.


Re: Using Box component

2017-01-26 Thread Tim Dudgeon
What I've found out so far is that the box library used by Camel is an old
project.

The one currently recommended by box.com is this this GitHub project
https://github.com/box/box-java-sdk which has maven coordinates of
com.box:box-java-sdk:2.1.1
(https://search.maven.org/#search%7Cga%7C1%7Ca%3A%22box-java-sdk%22) and
plenty of examples which I got running fine.

The one used in Camel have Maven coords of  net.box:boxjavalibv2:3.2.1 (
https://search.maven.org/#search%7Cga%7C1%7Ca%3A%22boxjavalibv2%22) and has
not been updated since 2014. I can't find source code or much info for this
so have not yet been able to test whether it still works against the current
box.com site.

I suspect this is cause of the problem, and, if so, wonder if any of the
Camel box component functions work correctly today.

Tim





--
View this message in context: 
http://camel.465427.n5.nabble.com/Using-Box-component-tp5792922p5793091.html
Sent from the Camel - Users mailing list archive at Nabble.com.


Re: Using Box component

2017-01-26 Thread Tim Dudgeon
Any thoughts on how to address this?
As the box route starts OK and I'm only getting this error when I trigger an
event on the box.com side it seems to me that the authentication is working
OK (but how can I be sure of this?).

I checked the version of the box java library being used and Camel seems to
be using the latest version (net.box:boxjavalibv2:3.2.1). But the error is
clearly "Failed to parse response". How to best track down what the real
problem is?

Thanks
Tim



--
View this message in context: 
http://camel.465427.n5.nabble.com/Using-Box-component-tp5792922p5793074.html
Sent from the Camel - Users mailing list archive at Nabble.com.


Re: Using Box component

2017-01-23 Thread Tim Dudgeon
rtyTypeDeserializer._deserializeTypedForId(AsPropertyTypeDeserializer.java:112)
at 
com.fasterxml.jackson.databind.jsontype.impl.AsPropertyTypeDeserializer.deserializeTypedFromObject(AsPropertyTypeDeserializer.java:97)
at 
com.fasterxml.jackson.databind.deser.BeanDeserializerBase.deserializeWithType(BeanDeserializerBase.java:1088)
at 
com.fasterxml.jackson.databind.deser.std.CollectionDeserializer.deserialize(CollectionDeserializer.java:279)
at 
com.fasterxml.jackson.databind.deser.std.CollectionDeserializer.deserialize(CollectionDeserializer.java:249)
at 
com.fasterxml.jackson.databind.deser.std.CollectionDeserializer.deserialize(CollectionDeserializer.java:26)
at 
com.fasterxml.jackson.databind.deser.SettableBeanProperty.deserialize(SettableBeanProperty.java:499)
at 
com.fasterxml.jackson.databind.deser.impl.MethodProperty.deserializeAndSet(MethodProperty.java:101)
at 
com.fasterxml.jackson.databind.deser.BeanDeserializer.vanillaDeserialize(BeanDeserializer.java:276)
at 
com.fasterxml.jackson.databind.deser.BeanDeserializer.deserialize(BeanDeserializer.java:140)
at 
com.fasterxml.jackson.databind.ObjectMapper._readValue(ObjectMapper.java:3761)
at 
com.fasterxml.jackson.databind.ObjectMapper.readValue(ObjectMapper.java:2090)
at 
com.box.boxjavalibv2.jsonparsing.BoxJSONParser.parseIntoBoxObject(BoxJSONParser.java:99)

... 14 more
Caused by: java.lang.IllegalArgumentException: Class 
com.box.boxjavalibv2.dao.BoxUserBase not subtype of [simple type, class 
com.box.boxjavalibv2.dao.BoxUser]
at 
com.fasterxml.jackson.databind.type.TypeFactory.constructSpecializedType(TypeFactory.java:359)
at 
com.fasterxml.jackson.databind.jsontype.impl.StdTypeResolverBuilder.buildTypeDeserializer(StdTypeResolverBuilder.java:118)
at 
com.fasterxml.jackson.databind.deser.BasicDeserializerFactory.findTypeDeserializer(BasicDeserializerFactory.java:1359)
at 
com.fasterxml.jackson.databind.deser.BasicDeserializerFactory.findPropertyTypeDeserializer(BasicDeserializerFactory.java:1494)
at 
com.fasterxml.jackson.databind.deser.BasicDeserializerFactory.resolveMemberAndTypeAnnotations(BasicDeserializerFactory.java:1843)
at 
com.fasterxml.jackson.databind.deser.BeanDeserializerFactory.constructSettableProperty(BeanDeserializerFactory.java:728)
at 
com.fasterxml.jackson.databind.deser.BeanDeserializerFactory.addBeanProps(BeanDeserializerFactory.java:516)
at 
com.fasterxml.jackson.databind.deser.BeanDeserializerFactory.buildBeanDeserializer(BeanDeserializerFactory.java:226)
at 
com.fasterxml.jackson.databind.deser.BeanDeserializerFactory.createBeanDeserializer(BeanDeserializerFactory.java:141)
at 
com.fasterxml.jackson.databind.deser.DeserializerCache._createDeserializer2(DeserializerCache.java:406)
at 
com.fasterxml.jackson.databind.deser.DeserializerCache._createDeserializer(DeserializerCache.java:352)
at 
com.fasterxml.jackson.databind.deser.DeserializerCache._createAndCache2(DeserializerCache.java:264)

... 31 more
[Camel (camel-1) thread #1 - CamelBox] INFO 
org.apache.camel.component.box.internal.LongPollingEventsManager - 
Stopped event polling thread for {login:tdudgeon...@gmail.com, 
client_id:b2qg97dks2bgrfnyjgrb48n3rdsmsdzd}



I don't fully understand this but looks like Jackson is barfing at the 
JSON returned, so there might be a library mismatch issue here?


Tim


On 23/01/2017 12:30, Claus Ibsen wrote:

You can configure a box configuration on the component level with your
login details.

On Mon, Jan 23, 2017 at 11:54 AM, Tim Dudgeon  wrote:

Is there a workaround that can be used with the current code?


On 22/01/2017 17:11, Claus Ibsen wrote:

Hi

Can you log a ticket as its a bug. The code is not so good with the
shared client stuff.

On Sun, Jan 22, 2017 at 5:56 PM, Tim Dudgeon 
wrote:

mmm, from this docs this is what is says about boxConfig:

"Custom Box SDK configuration, not required normally"

Tim



On 22/01/2017 13:41, souciance wrote:

Not sure but from the look of BoxComponent.java at line 83 it seems you
are
missing the parameter boxConfig.

On Sun, Jan 22, 2017 at 1:56 PM, Tim Dudgeon [via Camel] <
ml-node+s465427n5792922...@n5.nabble.com> wrote:


Hi All,

I'm having difficulty getting started with the Box component (using
Camel 2.18.1).
I'm using a route definition like this:



from("box://poll-events/poll?userName={{box_username}}&userPassword={{box_
userpassword}}&clientId={{box_client_id}}&clientSecret={{
box_client_secret}}&streamPosition=-1&streamType=all&limit=100")
...;

Other than the parameters in the route definition there's nothing else
Box related configured.

The parameters seem to be getting incorporated correctly, but the route
fails to start because of:

Exception in thread "main"
org.apache.camel.FailedToCreateRouteException: Failed to create route
route4: Route(route4)[[From[box://poll-events/poll?userName={{box_us...
becau

Re: Simple CDI setup with Weld

2017-01-23 Thread Tim Dudgeon

I put together this complete minimal example (uses Gradle or build):
https://github.com/tdudgeon/camel-cdi-se-example

Tim


On 20/01/2017 12:11, Antonin Stefanutti wrote:

Hi Tim,

DeltaSpike is only used by this Main class to bootstrap Camel CDI in Java SE. 
So the dependency is optional to avoid polluting the classpath for other target 
runtimes.

In the Camel examples, we add it to the Camel Maven plugin dependency, see: 
https://github.com/apache/camel/blob/6e95af29bc289a60fa633530118f5a11a1ff55cd/examples/camel-example-cdi-metrics/pom.xml#L109-L113

Note that this dependency may be removed with CDI 2.0, as a standard way of 
bootstrapping CDI in Java SE is now provided.

Antonin


On 20 Jan 2017, at 12:47, Tim Dudgeon  wrote:

Hi,

I'm trying to setup a simple Java SE app using Camel CDI and Weld.

The docs state that this can be run using the org.apache.camel.cdi.Main class.
However when running this I get an exception:

Exception in thread "main" java.lang.NoClassDefFoundError: 
org/apache/deltaspike/cdise/api/CdiContainerLoader
at org.apache.camel.cdi.Main.doStart(Main.java:96)
at org.apache.camel.support.ServiceSupport.start(ServiceSupport.java:61)
at org.apache.camel.main.MainSupport.run(MainSupport.java:138)
at org.apache.camel.main.MainSupport.run(MainSupport.java:390)
at org.apache.camel.cdi.Main.main(Main.java:64)
Caused by: java.lang.ClassNotFoundException: 
org.apache.deltaspike.cdise.api.CdiContainerLoader
at java.net.URLClassLoader.findClass(URLClassLoader.java:381)
at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:331)
at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
... 5 more

Looking at the source for that class is seems to assume its using Deltaspike as 
the CDI implementation, but obviously I don't have the Deltaspike classes 
present (not are they a transient dependency of camel-cdi.

So what is the right way to launch a Weld CDI Camel Java SE app?

Tim







Re: Using Box component

2017-01-23 Thread Tim Dudgeon

Is there a workaround that can be used with the current code?


On 22/01/2017 17:11, Claus Ibsen wrote:

Hi

Can you log a ticket as its a bug. The code is not so good with the
shared client stuff.

On Sun, Jan 22, 2017 at 5:56 PM, Tim Dudgeon  wrote:

mmm, from this docs this is what is says about boxConfig:

"Custom Box SDK configuration, not required normally"

Tim



On 22/01/2017 13:41, souciance wrote:

Not sure but from the look of BoxComponent.java at line 83 it seems you
are
missing the parameter boxConfig.

On Sun, Jan 22, 2017 at 1:56 PM, Tim Dudgeon [via Camel] <
ml-node+s465427n5792922...@n5.nabble.com> wrote:


Hi All,

I'm having difficulty getting started with the Box component (using
Camel 2.18.1).
I'm using a route definition like this:


from("box://poll-events/poll?userName={{box_username}}&userPassword={{box_
userpassword}}&clientId={{box_client_id}}&clientSecret={{
box_client_secret}}&streamPosition=-1&streamType=all&limit=100")
...;

Other than the parameters in the route definition there's nothing else
Box related configured.

The parameters seem to be getting incorporated correctly, but the route
fails to start because of:

Exception in thread "main"
org.apache.camel.FailedToCreateRouteException: Failed to create route
route4: Route(route4)[[From[box://poll-events/poll?userName={{box_us...
because of Failed to resolve endpoint:
box://poll-events/poll?clientId=xxx&clientSecret=xxx&

limit=100&streamPosition=-1&streamType=all&userName=xxx&userPassword=RAW(xxx)

due to: Cannot auto create component: box
   at

org.apache.camel.model.RouteDefinition.addRoutes(RouteDefinition.java:201)

   at

org.apache.camel.impl.DefaultCamelContext.startRoute(DefaultCamelContext.java:1008)

   at

org.apache.camel.impl.DefaultCamelContext.startRouteDefinitions(DefaultCamelContext.java:3397)

   at

org.apache.camel.impl.DefaultCamelContext.doStartCamel(DefaultCamelContext.java:3128)

   at
org.apache.camel.impl.DefaultCamelContext.access$
000(DefaultCamelContext.java:182)
   at

org.apache.camel.impl.DefaultCamelContext$2.call(DefaultCamelContext.java:2957)

   at

org.apache.camel.impl.DefaultCamelContext$2.call(DefaultCamelContext.java:2953)

   at

org.apache.camel.impl.DefaultCamelContext.doWithDefinedClassLoader(DefaultCamelContext.java:2976)

   at

org.apache.camel.impl.DefaultCamelContext.doStart(DefaultCamelContext.java:2953)

   at
org.apache.camel.support.ServiceSupport.start(ServiceSupport.java:61)
   at

org.apache.camel.impl.DefaultCamelContext.start(DefaultCamelContext.java:2920)

   at com.im.ext.xchem.filedrop.Main.main(Main.java:28)
Caused by: org.apache.camel.ResolveEndpointFailedException: Failed to
resolve endpoint:
box://poll-events/poll?clientId=xxx&clientSecret=xxx&

limit=100&streamPosition=-1&streamType=all&userName=xxx&userPassword=RAW(xxx)

due to: Cannot auto create component: box
   at

org.apache.camel.impl.DefaultCamelContext.getEndpoint(DefaultCamelContext.java:622)

   at

org.apache.camel.util.CamelContextHelper.getMandatoryEndpoint(CamelContextHelper.java:79)

   at

org.apache.camel.model.RouteDefinition.resolveEndpoint(RouteDefinition.java:211)

   at

org.apache.camel.impl.DefaultRouteContext.resolveEndpoint(DefaultRouteContext.java:108)

   at

org.apache.camel.impl.DefaultRouteContext.resolveEndpoint(DefaultRouteContext.java:114)

   at

org.apache.camel.model.FromDefinition.resolveEndpoint(FromDefinition.java:69)

   at

org.apache.camel.impl.DefaultRouteContext.getEndpoint(DefaultRouteContext.java:90)

   at

org.apache.camel.model.RouteDefinition.addRoutes(RouteDefinition.java:1051)

   at

org.apache.camel.model.RouteDefinition.addRoutes(RouteDefinition.java:196)

   ... 11 more
Caused by: org.apache.camel.RuntimeCamelException: Cannot auto create
component: box
   at

org.apache.camel.impl.DefaultCamelContext.initComponent(DefaultCamelContext.java:436)

   at

org.apache.camel.impl.DefaultCamelContext.lambda$getComponent$16(DefaultCamelContext.java:411)

   at
org.apache.camel.impl.DefaultCamelContext$$Lambda$4/2033968586
<(203)%20396-8586>.apply(Unknown
Source)
   at

java.util.concurrent.ConcurrentHashMap.computeIfAbsent(ConcurrentHashMap.java:1660)

   at

org.apache.camel.impl.DefaultCamelContext.getComponent(DefaultCamelContext.java:411)

   at

org.apache.camel.impl.DefaultCamelContext.getComponent(DefaultCamelContext.java:402)

   at

org.apache.camel.impl.DefaultCamelContext.getEndpoint(DefaultCamelContext.java:592)

   ... 19 more
Caused by: java.lang.IllegalArgumentException: Unable to connect, Box
component configuration is missing
   at
org.apache.camel.component.box.BoxComponent.doStart(BoxComponent.java:83)
   at
org.apache.camel.support.ServiceSupport.start(Se

Re: Using Box component

2017-01-22 Thread Tim Dudgeon

Done:

https://issues.apache.org/jira/browse/CAMEL-10736


On 22/01/2017 17:11, Claus Ibsen wrote:

Hi

Can you log a ticket as its a bug. The code is not so good with the
shared client stuff.

On Sun, Jan 22, 2017 at 5:56 PM, Tim Dudgeon  wrote:

mmm, from this docs this is what is says about boxConfig:

"Custom Box SDK configuration, not required normally"

Tim



On 22/01/2017 13:41, souciance wrote:

Not sure but from the look of BoxComponent.java at line 83 it seems you
are
missing the parameter boxConfig.

On Sun, Jan 22, 2017 at 1:56 PM, Tim Dudgeon [via Camel] <
ml-node+s465427n5792922...@n5.nabble.com> wrote:


Hi All,

I'm having difficulty getting started with the Box component (using
Camel 2.18.1).
I'm using a route definition like this:


from("box://poll-events/poll?userName={{box_username}}&userPassword={{box_
userpassword}}&clientId={{box_client_id}}&clientSecret={{
box_client_secret}}&streamPosition=-1&streamType=all&limit=100")
...;

Other than the parameters in the route definition there's nothing else
Box related configured.

The parameters seem to be getting incorporated correctly, but the route
fails to start because of:

Exception in thread "main"
org.apache.camel.FailedToCreateRouteException: Failed to create route
route4: Route(route4)[[From[box://poll-events/poll?userName={{box_us...
because of Failed to resolve endpoint:
box://poll-events/poll?clientId=xxx&clientSecret=xxx&

limit=100&streamPosition=-1&streamType=all&userName=xxx&userPassword=RAW(xxx)

due to: Cannot auto create component: box
   at

org.apache.camel.model.RouteDefinition.addRoutes(RouteDefinition.java:201)

   at

org.apache.camel.impl.DefaultCamelContext.startRoute(DefaultCamelContext.java:1008)

   at

org.apache.camel.impl.DefaultCamelContext.startRouteDefinitions(DefaultCamelContext.java:3397)

   at

org.apache.camel.impl.DefaultCamelContext.doStartCamel(DefaultCamelContext.java:3128)

   at
org.apache.camel.impl.DefaultCamelContext.access$
000(DefaultCamelContext.java:182)
   at

org.apache.camel.impl.DefaultCamelContext$2.call(DefaultCamelContext.java:2957)

   at

org.apache.camel.impl.DefaultCamelContext$2.call(DefaultCamelContext.java:2953)

   at

org.apache.camel.impl.DefaultCamelContext.doWithDefinedClassLoader(DefaultCamelContext.java:2976)

   at

org.apache.camel.impl.DefaultCamelContext.doStart(DefaultCamelContext.java:2953)

   at
org.apache.camel.support.ServiceSupport.start(ServiceSupport.java:61)
   at

org.apache.camel.impl.DefaultCamelContext.start(DefaultCamelContext.java:2920)

   at com.im.ext.xchem.filedrop.Main.main(Main.java:28)
Caused by: org.apache.camel.ResolveEndpointFailedException: Failed to
resolve endpoint:
box://poll-events/poll?clientId=xxx&clientSecret=xxx&

limit=100&streamPosition=-1&streamType=all&userName=xxx&userPassword=RAW(xxx)

due to: Cannot auto create component: box
   at

org.apache.camel.impl.DefaultCamelContext.getEndpoint(DefaultCamelContext.java:622)

   at

org.apache.camel.util.CamelContextHelper.getMandatoryEndpoint(CamelContextHelper.java:79)

   at

org.apache.camel.model.RouteDefinition.resolveEndpoint(RouteDefinition.java:211)

   at

org.apache.camel.impl.DefaultRouteContext.resolveEndpoint(DefaultRouteContext.java:108)

   at

org.apache.camel.impl.DefaultRouteContext.resolveEndpoint(DefaultRouteContext.java:114)

   at

org.apache.camel.model.FromDefinition.resolveEndpoint(FromDefinition.java:69)

   at

org.apache.camel.impl.DefaultRouteContext.getEndpoint(DefaultRouteContext.java:90)

   at

org.apache.camel.model.RouteDefinition.addRoutes(RouteDefinition.java:1051)

   at

org.apache.camel.model.RouteDefinition.addRoutes(RouteDefinition.java:196)

   ... 11 more
Caused by: org.apache.camel.RuntimeCamelException: Cannot auto create
component: box
   at

org.apache.camel.impl.DefaultCamelContext.initComponent(DefaultCamelContext.java:436)

   at

org.apache.camel.impl.DefaultCamelContext.lambda$getComponent$16(DefaultCamelContext.java:411)

   at
org.apache.camel.impl.DefaultCamelContext$$Lambda$4/2033968586
<(203)%20396-8586>.apply(Unknown
Source)
   at

java.util.concurrent.ConcurrentHashMap.computeIfAbsent(ConcurrentHashMap.java:1660)

   at

org.apache.camel.impl.DefaultCamelContext.getComponent(DefaultCamelContext.java:411)

   at

org.apache.camel.impl.DefaultCamelContext.getComponent(DefaultCamelContext.java:402)

   at

org.apache.camel.impl.DefaultCamelContext.getEndpoint(DefaultCamelContext.java:592)

   ... 19 more
Caused by: java.lang.IllegalArgumentException: Unable to connect, Box
component configuration is missing
   at
org.apache.camel.component.box.BoxComponent.doStart(BoxComponent.java:83)
   at
org.apache.camel.support.ServiceSupport.start(Se

Re: Using Box component

2017-01-22 Thread Tim Dudgeon

mmm, from this docs this is what is says about boxConfig:

"Custom Box SDK configuration, not required normally"

Tim


On 22/01/2017 13:41, souciance wrote:

Not sure but from the look of BoxComponent.java at line 83 it seems you are
missing the parameter boxConfig.

On Sun, Jan 22, 2017 at 1:56 PM, Tim Dudgeon [via Camel] <
ml-node+s465427n5792922...@n5.nabble.com> wrote:


Hi All,

I'm having difficulty getting started with the Box component (using
Camel 2.18.1).
I'm using a route definition like this:

from("box://poll-events/poll?userName={{box_username}}&userPassword={{box_
userpassword}}&clientId={{box_client_id}}&clientSecret={{
box_client_secret}}&streamPosition=-1&streamType=all&limit=100")
...;

Other than the parameters in the route definition there's nothing else
Box related configured.

The parameters seem to be getting incorporated correctly, but the route
fails to start because of:

Exception in thread "main"
org.apache.camel.FailedToCreateRouteException: Failed to create route
route4: Route(route4)[[From[box://poll-events/poll?userName={{box_us...
because of Failed to resolve endpoint:
box://poll-events/poll?clientId=xxx&clientSecret=xxx&
limit=100&streamPosition=-1&streamType=all&userName=xxx&userPassword=RAW(xxx)

due to: Cannot auto create component: box
  at
org.apache.camel.model.RouteDefinition.addRoutes(RouteDefinition.java:201)

  at
org.apache.camel.impl.DefaultCamelContext.startRoute(DefaultCamelContext.java:1008)

  at
org.apache.camel.impl.DefaultCamelContext.startRouteDefinitions(DefaultCamelContext.java:3397)

  at
org.apache.camel.impl.DefaultCamelContext.doStartCamel(DefaultCamelContext.java:3128)

  at
org.apache.camel.impl.DefaultCamelContext.access$
000(DefaultCamelContext.java:182)
  at
org.apache.camel.impl.DefaultCamelContext$2.call(DefaultCamelContext.java:2957)

  at
org.apache.camel.impl.DefaultCamelContext$2.call(DefaultCamelContext.java:2953)

  at
org.apache.camel.impl.DefaultCamelContext.doWithDefinedClassLoader(DefaultCamelContext.java:2976)

  at
org.apache.camel.impl.DefaultCamelContext.doStart(DefaultCamelContext.java:2953)

  at
org.apache.camel.support.ServiceSupport.start(ServiceSupport.java:61)
  at
org.apache.camel.impl.DefaultCamelContext.start(DefaultCamelContext.java:2920)

  at com.im.ext.xchem.filedrop.Main.main(Main.java:28)
Caused by: org.apache.camel.ResolveEndpointFailedException: Failed to
resolve endpoint:
box://poll-events/poll?clientId=xxx&clientSecret=xxx&
limit=100&streamPosition=-1&streamType=all&userName=xxx&userPassword=RAW(xxx)

due to: Cannot auto create component: box
  at
org.apache.camel.impl.DefaultCamelContext.getEndpoint(DefaultCamelContext.java:622)

  at
org.apache.camel.util.CamelContextHelper.getMandatoryEndpoint(CamelContextHelper.java:79)

  at
org.apache.camel.model.RouteDefinition.resolveEndpoint(RouteDefinition.java:211)

  at
org.apache.camel.impl.DefaultRouteContext.resolveEndpoint(DefaultRouteContext.java:108)

  at
org.apache.camel.impl.DefaultRouteContext.resolveEndpoint(DefaultRouteContext.java:114)

  at
org.apache.camel.model.FromDefinition.resolveEndpoint(FromDefinition.java:69)

  at
org.apache.camel.impl.DefaultRouteContext.getEndpoint(DefaultRouteContext.java:90)

  at
org.apache.camel.model.RouteDefinition.addRoutes(RouteDefinition.java:1051)

  at
org.apache.camel.model.RouteDefinition.addRoutes(RouteDefinition.java:196)

  ... 11 more
Caused by: org.apache.camel.RuntimeCamelException: Cannot auto create
component: box
  at
org.apache.camel.impl.DefaultCamelContext.initComponent(DefaultCamelContext.java:436)

  at
org.apache.camel.impl.DefaultCamelContext.lambda$getComponent$16(DefaultCamelContext.java:411)

  at
org.apache.camel.impl.DefaultCamelContext$$Lambda$4/2033968586
<(203)%20396-8586>.apply(Unknown
Source)
  at
java.util.concurrent.ConcurrentHashMap.computeIfAbsent(ConcurrentHashMap.java:1660)

  at
org.apache.camel.impl.DefaultCamelContext.getComponent(DefaultCamelContext.java:411)

  at
org.apache.camel.impl.DefaultCamelContext.getComponent(DefaultCamelContext.java:402)

  at
org.apache.camel.impl.DefaultCamelContext.getEndpoint(DefaultCamelContext.java:592)

  ... 19 more
Caused by: java.lang.IllegalArgumentException: Unable to connect, Box
component configuration is missing
  at
org.apache.camel.component.box.BoxComponent.doStart(BoxComponent.java:83)
  at
org.apache.camel.support.ServiceSupport.start(ServiceSupport.java:61)
  at
org.apache.camel.impl.DefaultCamelContext.startService(DefaultCamelContext.java:3371)

  at
org.apache.camel.impl.DefaultCamelContext.initComponent(DefaultCamelContext.java:431)

  ... 25 more

Can anyone spot what is wrong here?
Are there any examples anywhere to look at?

Thanks

Tim





Using Box component

2017-01-22 Thread Tim Dudgeon

Hi All,

I'm having difficulty getting started with the Box component (using 
Camel 2.18.1).

I'm using a route definition like this:

from("box://poll-events/poll?userName={{box_username}}&userPassword={{box_userpassword}}&clientId={{box_client_id}}&clientSecret={{box_client_secret}}&streamPosition=-1&streamType=all&limit=100")
...;

Other than the parameters in the route definition there's nothing else 
Box related configured.


The parameters seem to be getting incorporated correctly, but the route 
fails to start because of:


Exception in thread "main" 
org.apache.camel.FailedToCreateRouteException: Failed to create route 
route4: Route(route4)[[From[box://poll-events/poll?userName={{box_us... 
because of Failed to resolve endpoint: 
box://poll-events/poll?clientId=xxx&clientSecret=xxx&limit=100&streamPosition=-1&streamType=all&userName=xxx&userPassword=RAW(xxx) 
due to: Cannot auto create component: box
at 
org.apache.camel.model.RouteDefinition.addRoutes(RouteDefinition.java:201)
at 
org.apache.camel.impl.DefaultCamelContext.startRoute(DefaultCamelContext.java:1008)
at 
org.apache.camel.impl.DefaultCamelContext.startRouteDefinitions(DefaultCamelContext.java:3397)
at 
org.apache.camel.impl.DefaultCamelContext.doStartCamel(DefaultCamelContext.java:3128)
at 
org.apache.camel.impl.DefaultCamelContext.access$000(DefaultCamelContext.java:182)
at 
org.apache.camel.impl.DefaultCamelContext$2.call(DefaultCamelContext.java:2957)
at 
org.apache.camel.impl.DefaultCamelContext$2.call(DefaultCamelContext.java:2953)
at 
org.apache.camel.impl.DefaultCamelContext.doWithDefinedClassLoader(DefaultCamelContext.java:2976)
at 
org.apache.camel.impl.DefaultCamelContext.doStart(DefaultCamelContext.java:2953)
at 
org.apache.camel.support.ServiceSupport.start(ServiceSupport.java:61)
at 
org.apache.camel.impl.DefaultCamelContext.start(DefaultCamelContext.java:2920)

at com.im.ext.xchem.filedrop.Main.main(Main.java:28)
Caused by: org.apache.camel.ResolveEndpointFailedException: Failed to 
resolve endpoint: 
box://poll-events/poll?clientId=xxx&clientSecret=xxx&limit=100&streamPosition=-1&streamType=all&userName=xxx&userPassword=RAW(xxx) 
due to: Cannot auto create component: box
at 
org.apache.camel.impl.DefaultCamelContext.getEndpoint(DefaultCamelContext.java:622)
at 
org.apache.camel.util.CamelContextHelper.getMandatoryEndpoint(CamelContextHelper.java:79)
at 
org.apache.camel.model.RouteDefinition.resolveEndpoint(RouteDefinition.java:211)
at 
org.apache.camel.impl.DefaultRouteContext.resolveEndpoint(DefaultRouteContext.java:108)
at 
org.apache.camel.impl.DefaultRouteContext.resolveEndpoint(DefaultRouteContext.java:114)
at 
org.apache.camel.model.FromDefinition.resolveEndpoint(FromDefinition.java:69)
at 
org.apache.camel.impl.DefaultRouteContext.getEndpoint(DefaultRouteContext.java:90)
at 
org.apache.camel.model.RouteDefinition.addRoutes(RouteDefinition.java:1051)
at 
org.apache.camel.model.RouteDefinition.addRoutes(RouteDefinition.java:196)

... 11 more
Caused by: org.apache.camel.RuntimeCamelException: Cannot auto create 
component: box
at 
org.apache.camel.impl.DefaultCamelContext.initComponent(DefaultCamelContext.java:436)
at 
org.apache.camel.impl.DefaultCamelContext.lambda$getComponent$16(DefaultCamelContext.java:411)
at 
org.apache.camel.impl.DefaultCamelContext$$Lambda$4/2033968586.apply(Unknown 
Source)
at 
java.util.concurrent.ConcurrentHashMap.computeIfAbsent(ConcurrentHashMap.java:1660)
at 
org.apache.camel.impl.DefaultCamelContext.getComponent(DefaultCamelContext.java:411)
at 
org.apache.camel.impl.DefaultCamelContext.getComponent(DefaultCamelContext.java:402)
at 
org.apache.camel.impl.DefaultCamelContext.getEndpoint(DefaultCamelContext.java:592)

... 19 more
Caused by: java.lang.IllegalArgumentException: Unable to connect, Box 
component configuration is missing
at 
org.apache.camel.component.box.BoxComponent.doStart(BoxComponent.java:83)
at 
org.apache.camel.support.ServiceSupport.start(ServiceSupport.java:61)
at 
org.apache.camel.impl.DefaultCamelContext.startService(DefaultCamelContext.java:3371)
at 
org.apache.camel.impl.DefaultCamelContext.initComponent(DefaultCamelContext.java:431)

... 25 more

Can anyone spot what is wrong here?
Are there any examples anywhere to look at?

Thanks

Tim




Re: Simple CDI setup with Weld

2017-01-20 Thread Tim Dudgeon

Thanks. Adding Deltaspike explicitly was the solution.

Tim

On 20/01/2017 12:11, Antonin Stefanutti wrote:

Hi Tim,

DeltaSpike is only used by this Main class to bootstrap Camel CDI in Java SE. 
So the dependency is optional to avoid polluting the classpath for other target 
runtimes.

In the Camel examples, we add it to the Camel Maven plugin dependency, see: 
https://github.com/apache/camel/blob/6e95af29bc289a60fa633530118f5a11a1ff55cd/examples/camel-example-cdi-metrics/pom.xml#L109-L113

Note that this dependency may be removed with CDI 2.0, as a standard way of 
bootstrapping CDI in Java SE is now provided.

Antonin


On 20 Jan 2017, at 12:47, Tim Dudgeon  wrote:

Hi,

I'm trying to setup a simple Java SE app using Camel CDI and Weld.

The docs state that this can be run using the org.apache.camel.cdi.Main class.
However when running this I get an exception:

Exception in thread "main" java.lang.NoClassDefFoundError: 
org/apache/deltaspike/cdise/api/CdiContainerLoader
at org.apache.camel.cdi.Main.doStart(Main.java:96)
at org.apache.camel.support.ServiceSupport.start(ServiceSupport.java:61)
at org.apache.camel.main.MainSupport.run(MainSupport.java:138)
at org.apache.camel.main.MainSupport.run(MainSupport.java:390)
at org.apache.camel.cdi.Main.main(Main.java:64)
Caused by: java.lang.ClassNotFoundException: 
org.apache.deltaspike.cdise.api.CdiContainerLoader
at java.net.URLClassLoader.findClass(URLClassLoader.java:381)
at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:331)
at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
... 5 more

Looking at the source for that class is seems to assume its using Deltaspike as 
the CDI implementation, but obviously I don't have the Deltaspike classes 
present (not are they a transient dependency of camel-cdi.

So what is the right way to launch a Weld CDI Camel Java SE app?

Tim







Simple CDI setup with Weld

2017-01-20 Thread Tim Dudgeon

Hi,

I'm trying to setup a simple Java SE app using Camel CDI and Weld.

The docs state that this can be run using the org.apache.camel.cdi.Main 
class.

However when running this I get an exception:

Exception in thread "main" java.lang.NoClassDefFoundError: 
org/apache/deltaspike/cdise/api/CdiContainerLoader

at org.apache.camel.cdi.Main.doStart(Main.java:96)
at org.apache.camel.support.ServiceSupport.start(ServiceSupport.java:61)
at org.apache.camel.main.MainSupport.run(MainSupport.java:138)
at org.apache.camel.main.MainSupport.run(MainSupport.java:390)
at org.apache.camel.cdi.Main.main(Main.java:64)
Caused by: java.lang.ClassNotFoundException: 
org.apache.deltaspike.cdise.api.CdiContainerLoader

at java.net.URLClassLoader.findClass(URLClassLoader.java:381)
at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:331)
at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
... 5 more

Looking at the source for that class is seems to assume its using 
Deltaspike as the CDI implementation, but obviously I don't have the 
Deltaspike classes present (not are they a transient dependency of 
camel-cdi.


So what is the right way to launch a Weld CDI Camel Java SE app?

Tim





Re: MIME-Mutipart DataFormat streaming?

2016-10-29 Thread Tim Dudgeon

Thanks Stephan, that's what I feared.
Are there any suggested alternatives to this?
In my case I have Camel at both ends of an HTTP connection so hope 
there's some solution.
I would typically have a small body, and a small number of attachments, 
but these could potentially be very large. Seems like I should be able 
to use multipart form, but I'm not sure how to ensure its 100% streamed 
at both ends?


Tim


On 26/10/2016 06:43, Siano, Stephan wrote:

Hi Tim,

The MIME-Multipart DataFormat uses javamail as the underlying technology. The 
DataFormat is using streaming as far as the DataFormat is concerned, but I fear 
that javamail as such keeps a lot of stuff in memory so there is very likely no 
full streaming with that component available. For marshalling this might work 
with streaming as long as the component providing the Camel Message with its 
attachments is stream capbable, but for unmarshalling, I think that the 
javamail component will create ByteArrayDataSources at least for the 
attachments.

Best regards
Stephan

-Original Message-
From: Tim Dudgeon [mailto:tdudgeon...@gmail.com]
Sent: Dienstag, 25. Oktober 2016 14:21
To: users@camel.apache.org
Subject: MIME-Mutipart DataFormat streaming?

I was looking at the MIME-Mutipart DataFormat and it looks very useful:
https://camel.apache.org/mime-multipart.html

But I was not sure if it fully streams the data for the body and
attachments, or whether it holds the content in memory (this is for both
marshalling and unmarshalling).

Thanks
Tim





MIME-Mutipart DataFormat streaming?

2016-10-25 Thread Tim Dudgeon

I was looking at the MIME-Mutipart DataFormat and it looks very useful:
https://camel.apache.org/mime-multipart.html

But I was not sure if it fully streams the data for the body and 
attachments, or whether it holds the content in memory (this is for both 
marshalling and unmarshalling).


Thanks
Tim



old javadocs on website?

2016-10-22 Thread Tim Dudgeon
This page on the website: https://camel.apache.org/javadoc.html links to 
here http://camel.apache.org/maven/current/camel-core/apidocs/index.html 
for the core javadocs.


But that page is for the 2.15.0 version, so it a bit out of date. Are 
the current versions available, and can web site be updated?


Tim



regression with REST DSL PUT operations using auto binding?

2016-05-30 Thread Tim Dudgeon
I think I've hit a regression in 2.17.1 (worked in 2.16.2) with PUT 
operations with REST DSL.


When the input contains a body (and only if it does, and only with PUT) 
the auto binding of the output does not seem to work. Something like:


.put("/some/path").description("Update something")
.bindingMode(RestBindingMode.json).consumes("application/json").produces("application/json")
.type(Apple.class).outType(Pear.class)
.route()
.process((Exchange exch) -> {
Apple apple = exch.getIn().getBody(Apple.class);
Pear pear = convert(apple)
exch.getIn().setBody(pear); // no longer gets converted to json
})
.endRest()

If I turn off automatic binding and do it myself its all OK.

Any thoughts?

Tim




Re: swagger injects empty headers in 2.17.0

2016-04-07 Thread Tim Dudgeon

On 07/04/2016 06:12, Claus Ibsen wrote:

Hi

Ah can you log that in the JIRA


Done: https://issues.apache.org/jira/browse/CAMEL-9828


swagger injects empty headers in 2.17.0

2016-04-06 Thread Tim Dudgeon

I'm hit a wierd problem when trying to upgrade from 2.16.2 to 2.17.0

I have routes built using REST DSL, and this includes swagger definitions.
With 2.1.6.2 all was good.
On switching to 2.17.0 I find that having a swagger query parameter 
definition causes a header property to be defined as an empty string 
even when there is no query parameter defined.

As an example, the REST DSL snippet looks like this:

.post("/{notebookid}/e").description("Description ...")
.bindingMode(RestBindingMode.json).produces("application/json")
.outType(Foo.class)
.param().name("notebookid").type(path).description("Notebook 
ID").dataType("long").endParam()

.param().name("parent").type(query).description("The 
parent").dataType("long").required(false).endParam()
.route()
.process((Exchange exch) -> {
Long parent = exch.getIn().getHeader("parent", Long.class);
...
})
.endRest()

"parent" is an optional query param.
With 2.16.2 there was no "parent" header.
With 2.17.0 a "parent" header is magically added with the value being 
the empty string, which causes the TypeConversion to Long to blow up.


If I remove the swagger params then it works OK again.

Presumably this is a bug?

Tim



Re: CDI questions

2016-04-06 Thread Tim Dudgeon

Great, thanks.
Updating to Camel 2.17.0 fixed the need to specify the context name, and 
setting the custom thread pool also works now.

I updated the example to reflect this.

Thanks
Tim

On 06/04/2016 18:07, Antonin Stefanutti wrote:

Tim,

For the second problem, I’ve just looked at how Camel looks up for the custom 
ExecutorService and it actually looks up the CDI registry for a named bean of 
type ExecutorService, so you can just produce your custom ExecutorService 
instead of a ThreadPoolProfile bean. Otherwise, it falls back to the configured 
ExecutorServiceManager so your first way of doing it (with a custom Camel 
context) should work with Camel 2.17.0.

Antonin


On 06 Apr 2016, at 19:00, Antonin Stefanutti  wrote:

Hi Tim,

I see that it uses Camel 2.16.2. The Camel CDI component has been rewritten and 
improved in Camel 2.17.0.

Could you upgrade your Camel dependencies to 2.17.0 version? That should solve 
the issues.

Antonin


On 06 Apr 2016, at 18:13, Tim Dudgeon  wrote:

Hi Antonin

I tried your suggestion for problem 2, but couldn't get it to work.

I've put an example that illustrates both problems here:
https://github.com/tdudgeon/camel-cdi-servlet-example

To reproduce the first problem just remove the @ContextName annotation from the 
HelloRoute class.
To reproduce the second one uncomment line 25 from the same class.

Tim


On 06/04/2016 16:09, Antonin Stefanutti wrote:

Hi Tim,


On 06 Apr 2016, at 16:19, Tim Dudgeon  wrote:

I've found a couple of things I don't understand when using the camel-cdi 
component.

1. The @ContextName("customname") annotation can be used to specify a custom 
name for the camel context. But I'm finding that this annotation is essential.
e.g. if my app comprise just of a couple of classes extending RoutBuilder then 
I MUST have this annotation present.
I would have assumed that if I only have a single CamelContext then this would 
have been unnecessary?

This should work as you assume. For example, if you execute the following test:

@RunWith(Arquillian.class)
public class CdiTest {

@Deployment
public static Archive deployment() {
return ShrinkWrap.create(JavaArchive.class)
// Camel CDI
.addPackage(CdiCamelExtension.class.getPackage())
// Bean archive deployment descriptor
.addAsManifestResource(EmptyAsset.INSTANCE, "beans.xml");
}

static class FirstRoute extends RouteBuilder {

@Override
public void configure() {
from("direct:first").to("mock:first");
}
}

static class SecondRoute extends RouteBuilder {

@Override
public void configure() {
from("direct:second").to("mock:second");
}
}

@Test
public void test() {
}
}

You see that the two route builders get added to the default Camel context:

2016-04-06 16:56:53,201 INFO  [   main] o.a.c.c.CdiCamelExtension   
 : Camel CDI is starting Camel context [camel-1]
2016-04-06 16:56:53,202 INFO  [   main] o.a.c.i.DefaultCamelContext 
 : Apache Camel 2.17.0 (CamelContext: camel-1) is starting
2016-04-06 16:56:53,581 INFO  [   main] o.a.c.i.DefaultCamelContext 
 : Route: route1 started and consuming from: Endpoint[direct://second]
2016-04-06 16:56:53,585 INFO  [   main] o.a.c.i.DefaultCamelContext 
 : Route: route2 started and consuming from: Endpoint[direct://first]
2016-04-06 16:56:53,586 INFO  [   main] o.a.c.i.DefaultCamelContext 
 : Total 2 routes, of which 2 are started.
2016-04-06 16:56:53,587 INFO  [   main] o.a.c.i.DefaultCamelContext 
 : Apache Camel 2.17.0 (CamelContext: camel-1) started in 0.385 seconds
2016-04-06 16:56:53,649 INFO  [   main] o.a.c.c.CamelContextProducer
 : Camel CDI is stopping Camel context [camel-1]
2016-04-06 16:56:53,649 INFO  [   main] o.a.c.i.DefaultCamelContext 
 : Apache Camel 2.17.0 (CamelContext: camel-1) is shutting down
2016-04-06 16:56:53,651 INFO  [   main] o.a.c.i.DefaultShutdownStrategy 
 : Starting to graceful shutdown 2 routes (timeout 300 seconds)
2016-04-06 16:56:53,655 INFO  [ - ShutdownTask] o.a.c.i.DefaultShutdownStrategy 
 : Route: route2 shutdown complete, was consuming from: 
Endpoint[direct://first]
2016-04-06 16:56:53,655 INFO  [ - ShutdownTask] o.a.c.i.DefaultShutdownStrategy 
 : Route: route1 shutdown complete, was consuming from: 
Endpoint[direct://second]
2016-04-06 16:56:53,656 INFO  [   main] o.a.c.i.DefaultShutdownStrategy 
 : Graceful shutdown of 2 routes completed in 0 seconds
2016-04-06 16:56:53,660 INFO  [   main] o.a.c.i.DefaultCamelContext 
 : Apache Camel 2.17.0 (CamelContext: camel-1) uptime 0.459 seconds
2016-04-06 16:56:53,660 INFO  [   main] o.a.c.i.Defaul

Re: CDI questions

2016-04-06 Thread Tim Dudgeon

Hi Antonin

I tried your suggestion for problem 2, but couldn't get it to work.

I've put an example that illustrates both problems here:
https://github.com/tdudgeon/camel-cdi-servlet-example

To reproduce the first problem just remove the @ContextName annotation 
from the HelloRoute class.

To reproduce the second one uncomment line 25 from the same class.

Tim


On 06/04/2016 16:09, Antonin Stefanutti wrote:

Hi Tim,


On 06 Apr 2016, at 16:19, Tim Dudgeon  wrote:

I've found a couple of things I don't understand when using the camel-cdi 
component.

1. The @ContextName("customname") annotation can be used to specify a custom 
name for the camel context. But I'm finding that this annotation is essential.
e.g. if my app comprise just of a couple of classes extending RoutBuilder then 
I MUST have this annotation present.
I would have assumed that if I only have a single CamelContext then this would 
have been unnecessary?

This should work as you assume. For example, if you execute the following test:

@RunWith(Arquillian.class)
public class CdiTest {

 @Deployment
 public static Archive deployment() {
 return ShrinkWrap.create(JavaArchive.class)
 // Camel CDI
 .addPackage(CdiCamelExtension.class.getPackage())
 // Bean archive deployment descriptor
 .addAsManifestResource(EmptyAsset.INSTANCE, "beans.xml");
 }

 static class FirstRoute extends RouteBuilder {

 @Override
 public void configure() {
 from("direct:first").to("mock:first");
 }
 }

 static class SecondRoute extends RouteBuilder {

 @Override
 public void configure() {
 from("direct:second").to("mock:second");
 }
 }

 @Test
 public void test() {
 }
}

You see that the two route builders get added to the default Camel context:

2016-04-06 16:56:53,201 INFO  [   main] o.a.c.c.CdiCamelExtension   
 : Camel CDI is starting Camel context [camel-1]
2016-04-06 16:56:53,202 INFO  [   main] o.a.c.i.DefaultCamelContext 
 : Apache Camel 2.17.0 (CamelContext: camel-1) is starting
2016-04-06 16:56:53,581 INFO  [   main] o.a.c.i.DefaultCamelContext 
 : Route: route1 started and consuming from: Endpoint[direct://second]
2016-04-06 16:56:53,585 INFO  [   main] o.a.c.i.DefaultCamelContext 
 : Route: route2 started and consuming from: Endpoint[direct://first]
2016-04-06 16:56:53,586 INFO  [   main] o.a.c.i.DefaultCamelContext 
 : Total 2 routes, of which 2 are started.
2016-04-06 16:56:53,587 INFO  [   main] o.a.c.i.DefaultCamelContext 
 : Apache Camel 2.17.0 (CamelContext: camel-1) started in 0.385 seconds
2016-04-06 16:56:53,649 INFO  [   main] o.a.c.c.CamelContextProducer
 : Camel CDI is stopping Camel context [camel-1]
2016-04-06 16:56:53,649 INFO  [   main] o.a.c.i.DefaultCamelContext 
 : Apache Camel 2.17.0 (CamelContext: camel-1) is shutting down
2016-04-06 16:56:53,651 INFO  [   main] o.a.c.i.DefaultShutdownStrategy 
 : Starting to graceful shutdown 2 routes (timeout 300 seconds)
2016-04-06 16:56:53,655 INFO  [ - ShutdownTask] o.a.c.i.DefaultShutdownStrategy 
 : Route: route2 shutdown complete, was consuming from: 
Endpoint[direct://first]
2016-04-06 16:56:53,655 INFO  [ - ShutdownTask] o.a.c.i.DefaultShutdownStrategy 
 : Route: route1 shutdown complete, was consuming from: 
Endpoint[direct://second]
2016-04-06 16:56:53,656 INFO  [   main] o.a.c.i.DefaultShutdownStrategy 
 : Graceful shutdown of 2 routes completed in 0 seconds
2016-04-06 16:56:53,660 INFO  [   main] o.a.c.i.DefaultCamelContext 
 : Apache Camel 2.17.0 (CamelContext: camel-1) uptime 0.459 seconds
2016-04-06 16:56:53,660 INFO  [   main] o.a.c.i.DefaultCamelContext 
 : Apache Camel 2.17.0 (CamelContext: camel-1) is shutdown in 0.011 
seconds

Could you please send more details about your deployment so that I can help 
identify why that is not working as expected?


2. I'm try to use a custom thread pool. As described in the docs I use a 
@Producer to generate the thread pool profile:

public class CamelContextFactory {

@Produces
@ApplicationScoped
CamelContext customize() {
DefaultCamelContext context = new DefaultCamelContext();
context.setName("mycontext");
ThreadPoolProfile profile = new 
ThreadPoolProfileBuilder("poolName").poolSize(4).maxPoolSize(50).build();
context.getExecutorServiceManager().registerThreadPoolProfile(profile);
return context;
}
}

This seems to be executed as expected, but when I try to use the thread pool in 
a route like this:

from("direct:foo" )
.threads().executorServiceRef("poolName")
.log("route executed");

the

CDI questions

2016-04-06 Thread Tim Dudgeon
I've found a couple of things I don't understand when using the 
camel-cdi component.


1. The @ContextName("customname") annotation can be used to specify a 
custom name for the camel context. But I'm finding that this annotation 
is essential.
e.g. if my app comprise just of a couple of classes extending 
RoutBuilder then I MUST have this annotation present.
I would have assumed that if I only have a single CamelContext then this 
would have been unnecessary?



2. I'm try to use a custom thread pool. As described in the docs I use a 
@Producer to generate the thread pool profile:


public class CamelContextFactory {

@Produces
@ApplicationScoped
CamelContext customize() {
DefaultCamelContext context = new DefaultCamelContext();
context.setName("mycontext");
ThreadPoolProfile profile = new 
ThreadPoolProfileBuilder("poolName").poolSize(4).maxPoolSize(50).build();

context.getExecutorServiceManager().registerThreadPoolProfile(profile);
return context;
}
}

This seems to be executed as expected, but when I try to use the thread 
pool in a route like this:


from("direct:foo" )
.threads().executorServiceRef("poolName")
.log("route executed");

then the pool can't be found:

Caused by: java.lang.IllegalArgumentException: ExecutorServiceRef poolName not 
found in registry or as a thread pool profile.

Thanks for any advice on these.
Tim




Re: security requirement using swagger java

2016-03-24 Thread Tim Dudgeon

Done: https://issues.apache.org/jira/browse/CAMEL-9751

On 24/03/2016 07:51, Claus Ibsen wrote:

Hi

No its not included currently. You are welcome to log a JIRA about
this so we can add it in a future release
http://camel.apache.org/support.html

On Wed, Mar 23, 2016 at 9:59 PM, Tim Dudgeon  wrote:

Hi
Is it possible to specify swagger security requirements
(http://swagger.io/specification/#securityRequirementObject) using the
swagger java component?
I can't figure it out and can't find any examples.

Tim









security requirement using swagger java

2016-03-23 Thread Tim Dudgeon

Hi
Is it possible to specify swagger security requirements 
(http://swagger.io/specification/#securityRequirementObject) using the 
swagger java component?

I can't figure it out and can't find any examples.

Tim




Re: Camel - CDI and Servlet Context Implementation

2016-01-26 Thread Tim Dudgeon

I didn't see any answer to this, and have hit the same.

I've got Camel running in Tomcat using camel-servlet and 
camel-servletlistener as described here:

http://camel.apache.org/servletlistener-component.html

Also, independently I've used the new camel-cdi stuff found here:
https://github.com/astefanutti/camel-cdi
to get a very basic Camel implementation running using CDI e.g. creating 
a CDI injected subclass of HttpServlet annotated with @WebServlet.


But its not clear how to combine the two. In my case I've got routes 
that use the REST DSL and are using the camel-servlet component.


e.g. starting from a RouteBuilder that looks like this:

@Inject Something something

@Override
public void configure() throws Exception {

restConfiguration().component("servlet").host("0.0.0.0");

rest("/ping")
.get()
.produces("text/plain")
.route()
.transform(constant("Ping\n")).endRest();
}


what's the shortest path of travel to get this working e.g. how to 
define the servlet?


Thanks
Tim


On 19/03/2015 08:02, Naveen Subramanian wrote:

Hi,

I have implemented Camel with Servlet implementation using ServletContext.
I wish to implement CDI as well (which needs CdiCamelConext).

I am unable to find a way to implement both. Please suggest.


My web.xml


routeBuilder-routes
packagescan:com.example.api.routes



CamelContextLifecycle
com.example.api.camel.CustomCamelContextLifeCycle


org.apache.camel.component.servletlistener.SimpleCamelServletContextListener






APIServerServlet
CamelServlet
org.apache.camel.component.servlet.CamelHttpTransportServlet
1



CamelServlet
/*




(P.S no Spring )





Re: State of the camel-cdi component

2016-01-04 Thread Tim Dudgeon

That's great to hear. Roll on 2.17.
What was not clear for me was whether it would work (=how to get it to 
work) in a pure servlet (=jetty, tomcat) environment.


Tim

On 04/01/2016 18:55, Antonin Stefanutti wrote:

Hi Tim,

We are actively working on improving the Camel CDI integration for the upcoming 
2.17.0 release. This is followed-up in 
https://issues.apache.org/jira/browse/CAMEL-9201.

That will be essentially the merging of the work being done in 
https://github.com/astefanutti/camel-cdi.

This will bring, among other things, better CDI programming model integration 
plus the portability to all targeted runtimes (Java SE, servlets containers, 
Java EE, OSGi with the expositing of the CDI camel contexts as OSGi services) 
and implementations (Weld and OpenWebBeans).

In the meantime, you can use the version in 
https://github.com/astefanutti/camel-cdi as a drop-in replacement and switch 
back to the official one once that gets merged and released into the official 
component.

Antonin


On 04 Jan 2016, at 19:37, Tim Dudgeon  wrote:

Hi,

Was wondering what the latest status was here (read below)?
I'm trying to adapt a camel-servlet app to use CDI and it's not clear how to 
best go about this.

Thanks

Tim

On 11/12/2014 16:07, Charles Moulliard wrote:

Hi Jason,

I'm working with Antonin on that new camel-cdi. when the code will be ready
it will be integrated with Camel project

Regards,

On Thu, Dec 11, 2014 at 4:17 PM, Jason Holmberg  wrote:


Will the Camel project will officially adopt:

https://github.com/astefanutti/camel-cdi

as its CDI extension.  I have experimented with the 'official' extension
available in 2.14.0 and feel that it is lacking much of what it needs to a
viable component where as https://github.com/astefanutti/camel-cdi seems
to
have addresses many if not all of the deficiencies.

I see that there is active development on the official camel-cdi component,
I feel that the work being done in
https://github.com/astefanutti/camel-cdi
is looking and working really well.

We would really prefer CDI over Spring for DI.

Thanks,
Jason



--
View this message in context:
http://camel.465427.n5.nabble.com/State-of-the-camel-cdi-component-tp5760578.html
Sent from the Camel - Users mailing list archive at Nabble.com.







Re: State of the camel-cdi component

2016-01-04 Thread Tim Dudgeon

Hi,

Was wondering what the latest status was here (read below)?
I'm trying to adapt a camel-servlet app to use CDI and it's not clear 
how to best go about this.


Thanks

Tim

On 11/12/2014 16:07, Charles Moulliard wrote:

Hi Jason,

I'm working with Antonin on that new camel-cdi. when the code will be ready
it will be integrated with Camel project

Regards,

On Thu, Dec 11, 2014 at 4:17 PM, Jason Holmberg  wrote:


Will the Camel project will officially adopt:

https://github.com/astefanutti/camel-cdi

as its CDI extension.  I have experimented with the 'official' extension
available in 2.14.0 and feel that it is lacking much of what it needs to a
viable component where as https://github.com/astefanutti/camel-cdi seems
to
have addresses many if not all of the deficiencies.

I see that there is active development on the official camel-cdi component,
I feel that the work being done in
https://github.com/astefanutti/camel-cdi
is looking and working really well.

We would really prefer CDI over Spring for DI.

Thanks,
Jason



--
View this message in context:
http://camel.465427.n5.nabble.com/State-of-the-camel-cdi-component-tp5760578.html
Sent from the Camel - Users mailing list archive at Nabble.com.








Re: manual ack with rabbitmq

2016-01-03 Thread Tim Dudgeon
Thanks. So it looks like it will get acknowledged by Camel as long as 
the route doesn't throw an exception. That's good!


Tim

On 03/01/2016 17:09, Preben.Asmussen wrote:

manuel acknowlendgement using channel.basicAck is done internally by the
RabbitMQConsumer when the message is processed.
See
https://github.com/apache/camel/blob/master/components/camel-rabbitmq/src/main/java/org/apache/camel/component/rabbitmq/RabbitMQConsumer.java#L201



--
View this message in context: 
http://camel.465427.n5.nabble.com/manual-ack-with-rabbitmq-tp5775697p5775706.html
Sent from the Camel - Users mailing list archive at Nabble.com.




manual ack with rabbitmq

2016-01-03 Thread Tim Dudgeon

What is the way to do manual acknowledgement using the RabbitMQ component?
I see you can set autoAck=false in the component properties, and the 
rabbitmq.DELIVERY_TAG header gives the delivery tag.

But how does one get hold of the channel to do a manual acknowledgement?

Thanks
Tim


what's happening to camel extra?

2015-08-19 Thread Tim Dudgeon
Now that the Google code site is about to switch to read only 
(https://code.google.com/a/apache-extras.org/p/camel-extra/) I wondered 
what is going to happen to the Camel Extras stuff?


Tim


Re: using spock to test camel

2015-07-02 Thread Tim Dudgeon

Spock works fine with camel.
After all camel is just java.
The only downside I see is the limited refactoring capabilities the IDE 
can provide resulting from it using groovy.


Tim

On 02/07/2015 16:08, Wilson MacGyver wrote:

Hi,

Has anyone ever used spock to test camel before?

I notice only junit and test-ng are supported. I didn't know if anyone has
ever tried it.

Thanks,
Mac





Re: use gradle to build apache camel application

2015-07-02 Thread Tim Dudgeon

The gradle tomcat plugin works fine for running a camel based project.
https://github.com/bmuschko/gradle-tomcat-plugin
I've been using gradle with camel for ages and am very happy with it.
The only major thing that I miss sometimes is the camel maven archetype 
projects.

But on the plus side I haven't worn out the < and > keys on my keyboard :-)
Tim

On 02/07/2015 19:15, Rafael Ponte wrote:

I'm working on a web project (with Camel integrated to Spring), so it's
deployed on Tomcat container.

On Thu, Jul 2, 2015 at 3:08 PM Wilson MacGyver  wrote:


so do you just use the application plugin to build it?

are you using the shadow plugin to create a fatjar to deploy it?

Thanks

On Thu, Jul 2, 2015 at 1:55 PM, Rafael Ponte  wrote:


I don't. I'm just using gradle to handle all dependencies of my project,
build and so on. :-T

On Thu, Jul 2, 2015 at 2:52 PM Wilson MacGyver 
wrote:


not really problem per se. just wanted to know how smooth it's working.

for example, in mvn you can run camel by using mvn camel:run

how do you do that with gradle?

On Thu, Jul 2, 2015 at 1:43 PM, Rafael Ponte  wrote:


Hi Wilson,

I'm using Camel with Gradle managing all dependencies. What problem

do

you

have?


On Thu, Jul 2, 2015 at 2:41 PM Wilson MacGyver 
wrote:


I know camel has excellent support for maven. and even has a mvn

plugin.

has anyone ever used gradle with camel application development

before?

--
Omnem crede diem tibi diluxisse supremum.


--
Rafael Ponte
TriadWorks | Formação Java
http://cursos.triadworks.com.br




--
Omnem crede diem tibi diluxisse supremum.


--
Rafael Ponte
TriadWorks | Formação Java
http://cursos.triadworks.com.br




--
Omnem crede diem tibi diluxisse supremum.





Re: route specification in web.xml

2015-06-28 Thread Tim Dudgeon

Thanks. That's what I need.
But are you aware that all the code snippets are missing from that page?

Tim


On 27/06/2015 09:30, Claus Ibsen wrote:

Hi

Yes there is more documentation here
http://camel.apache.org/servletlistener-component.html

On Thu, Jun 25, 2015 at 1:40 PM, Tim Dudgeon  wrote:

I was trying to get some servlets working, based on the
camel-example-servlet-tomcat-no-spring example.

I'm a bit confused by this section:


 routeBuilder-MyRoute
 
 
classpath:camel-config.xml
   

I worked out by trial and error how to specify an individual RouteBuilder
implementation as a Java class:
foo.bar.bazMyRouteBuilderClass

and how to do a package scan for multiple RouteBuilders:
packagescan:foo.bar.baz

But is there and more detailed information on this sort of thing anywhere?

For instance, what other options are available here, and if you needed to
run multiple camel contexts (separate servlets?) how could you do this.

Thanks
Tim







Re: nonsense ClassCastException

2015-06-26 Thread Tim Dudgeon
Yes, seems so. I fixed it by managing the dependencies, but what was 
happening made no sense to me as two seemingly "identical" setups 
behaved differently.


Tim

On 26/06/2015 11:21, Henryk Konsek wrote:

Hi,

It looks like you have incompatible Servlet API jars included in your WAR.
So your jars do not match the API used by your Tomcat.

Cheers!

czw., 25.06.2015 o 19:11 użytkownik Tim Dudgeon 
napisał:


I'm trying to run some routes in tomcat using the servlet component
(CamelHttpTransportServlet in the web.xml)
In a simple example I've got it running fine, but when I try this in the
real example I get a startup exception that makes no sense at all.

Marking servlet CamelServlet as unavailable
Servlet [CamelServlet] in web application [/job-services] threw load()
exception
java.lang.ClassCastException:
org.apache.camel.component.servlet.CamelHttpTransportServlet cannot be
cast to javax.servlet.Servlet
at

org.apache.catalina.core.StandardWrapper.loadServlet(StandardWrapper.java:1148)
at org.apache.catalina.core.StandardWrapper.load(StandardWrapper.java:1087)
at

org.apache.catalina.core.StandardContext.loadOnStartup(StandardContext.java:5262)
at

org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5550)
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
at

org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1575)
at

org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1565)
at java.util.concurrent.FutureTask.run(FutureTask.java:266)
at

java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
at

java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
at java.lang.Thread.run(Thread.java:745)


Clearly CamelHttpTransportServlet can be cast to javax.servlet.Servlet.
Anyone got any ideas what to look at for this?

Tim






nonsense ClassCastException

2015-06-25 Thread Tim Dudgeon
I'm trying to run some routes in tomcat using the servlet component 
(CamelHttpTransportServlet in the web.xml)
In a simple example I've got it running fine, but when I try this in the 
real example I get a startup exception that makes no sense at all.


Marking servlet CamelServlet as unavailable
Servlet [CamelServlet] in web application [/job-services] threw load() 
exception
java.lang.ClassCastException: 
org.apache.camel.component.servlet.CamelHttpTransportServlet cannot be 
cast to javax.servlet.Servlet
at 
org.apache.catalina.core.StandardWrapper.loadServlet(StandardWrapper.java:1148)

at org.apache.catalina.core.StandardWrapper.load(StandardWrapper.java:1087)
at 
org.apache.catalina.core.StandardContext.loadOnStartup(StandardContext.java:5262)
at 
org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5550)

at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
at 
org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1575)
at 
org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1565)

at java.util.concurrent.FutureTask.run(FutureTask.java:266)
at 
java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
at 
java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)

at java.lang.Thread.run(Thread.java:745)


Clearly CamelHttpTransportServlet can be cast to javax.servlet.Servlet.
Anyone got any ideas what to look at for this?

Tim



route specification in web.xml

2015-06-25 Thread Tim Dudgeon
I was trying to get some servlets working, based on the 
camel-example-servlet-tomcat-no-spring example.


I'm a bit confused by this section:


routeBuilder-MyRoute



classpath:camel-config.xml
  

I worked out by trial and error how to specify an individual 
RouteBuilder implementation as a Java class:

foo.bar.bazMyRouteBuilderClass

and how to do a package scan for multiple RouteBuilders:
packagescan:foo.bar.baz

But is there and more detailed information on this sort of thing anywhere?

For instance, what other options are available here, and if you needed 
to run multiple camel contexts (separate servlets?) how could you do this.


Thanks
Tim


Re: swagger + jetty with REST DSL

2015-06-24 Thread Tim Dudgeon
Not sure I really understand. What I really want is to add the Swagger 
servlet so that it can doument my REST api that is provided by the Camel 
REST DSL, both running in the same Jetty server.
So I use the REST DSL to define operations under /rest and want to have 
swagger running and documenting those endpoints.


Tim


On 24/06/2015 11:39, Claus Ibsen wrote:

Its not intended to add handlers that work with different
context-paths. eg those handlers are for adding security, logging and
whatnot.

But you can turn on matchOnUriPrefix=true and then the camel jetty
route should react. If you want /hello then add /hello to the jetty
route.



On Wed, Jun 24, 2015 at 12:34 PM, Tim Dudgeon  wrote:

I'm struggling with this, so I tried setting up a dead simple servlet
example and can't even get that working.
Using plain Jetty its fine, but I don't seem able to wire it into camel .
I created this GIST to illustrate it:
https://gist.github.com/tdudgeon/69ff3cdeb4e3ac68df87

Jetty responds on
localhost:8000/
but the helloServlet does not respond on anything under
localhost:8000/hello/

What am I doing wrong?

Tim


On 22/06/2015 15:36, Claus Ibsen wrote:

Hi

You need to use the camel-swagger as a servlet
http://camel.apache.org/swagger

How you configure this can be done with web.xml or some fancy @servlet
annotations.

The camel route can be in java dsl and camel-swagger servlet discovers
this using JMX - so they have to be in the same JVM, or better in same
deployment unit. There is a pending ticket to make it separate and so
you can specify which camel context you wanna see the api.

There is an example in the examples dir using tomcat.

On Mon, Jun 22, 2015 at 4:24 PM, Tim Dudgeon 
wrote:

Can someone provide some info on how to get swagger set up with the REST
DSL
in a simple jetty environment.
e.g. something very similar to what Christian described here:

http://blog.christianposta.com/camel/easy-rest-endpoints-with-apache-camel-2-14/
e.g. Java only, no Spring.

Thanks
Tim










Re: swagger + jetty with REST DSL

2015-06-24 Thread Tim Dudgeon
I'm struggling with this, so I tried setting up a dead simple servlet 
example and can't even get that working.

Using plain Jetty its fine, but I don't seem able to wire it into camel .
I created this GIST to illustrate it:
https://gist.github.com/tdudgeon/69ff3cdeb4e3ac68df87

Jetty responds on
localhost:8000/
but the helloServlet does not respond on anything under
localhost:8000/hello/

What am I doing wrong?

Tim

On 22/06/2015 15:36, Claus Ibsen wrote:

Hi

You need to use the camel-swagger as a servlet
http://camel.apache.org/swagger

How you configure this can be done with web.xml or some fancy @servlet
annotations.

The camel route can be in java dsl and camel-swagger servlet discovers
this using JMX - so they have to be in the same JVM, or better in same
deployment unit. There is a pending ticket to make it separate and so
you can specify which camel context you wanna see the api.

There is an example in the examples dir using tomcat.

On Mon, Jun 22, 2015 at 4:24 PM, Tim Dudgeon  wrote:

Can someone provide some info on how to get swagger set up with the REST DSL
in a simple jetty environment.
e.g. something very similar to what Christian described here:
http://blog.christianposta.com/camel/easy-rest-endpoints-with-apache-camel-2-14/
e.g. Java only, no Spring.

Thanks
Tim







Re: REST DSL conundrum

2015-06-22 Thread Tim Dudgeon

No, it wasn't that (though I've been caught be that in the past).
It turned out that its something strange with the result needing to be 
set to the body of the Out message, not the In message.

Not totally sure about it, but I have something that works now.

Tim

On 22/06/2015 18:21, Claus Ibsen wrote:

Hi

If it works without the log, then see this
http://camel.apache.org/why-is-my-message-body-empty.html

On Mon, Jun 22, 2015 at 7:18 PM, Tim Dudgeon  wrote:

I'm struggling with a REST DSL. It handles a POST request for a file upload,
so the request body is binary type, and the response is JSON describing the
result. The container is Jetty.

My DSL looks like this:

rest("/rest/v1/datasets")
.post().description("Upload file to create new dataset")
.bindingMode(RestBindingMode.off)
.produces("application/json")
.route()
.to("direct:process_the_body")  // this processed the body and
returns a result object
.marshal().json(JsonLibrary.Jackson) // which here is converted to JSON
.log("marshal complete. JSON is ${body}")
.endRest()

Its all working fine, and the JSON gets marshalled correctly (the log()
statement
By the request fails with this error:

[qtp562561015-19] INFO route2 - marshal complete. JSON is
{"id":13,"name":"big_bad","size":null,"metadata":{"type":"ITEM","className":"java.util.stream.ReferencePipeline$Head","size":1},"created":1434992702164,"updated":1434992702164,"loid":333226}
[qtp562561015-19] WARN org.eclipse.jetty.server.AbstractHttpConnection -
header full: java.lang.RuntimeException: Header>6144
[qtp562561015-19] ERROR
org.apache.camel.component.jetty.CamelContinuationServlet - Error processing
request
HttpException(500,null,null)
at
org.eclipse.jetty.server.AbstractHttpConnection.commitResponse(AbstractHttpConnection.java:645)
at
org.eclipse.jetty.server.AbstractHttpConnection$Output.flush(AbstractHttpConnection.java:1122)
at org.apache.camel.util.IOHelper.copy(IOHelper.java:201)
at
org.apache.camel.component.http.DefaultHttpBinding.copyStream(DefaultHttpBinding.java:318)
at
org.apache.camel.component.http.DefaultHttpBinding.doWriteDirectResponse(DefaultHttpBinding.java:378)
at
org.apache.camel.component.http.DefaultHttpBinding.doWriteResponse(DefaultHttpBinding.java:299)
at
org.apache.camel.component.http.DefaultHttpBinding.writeResponse(DefaultHttpBinding.java:231)
at
org.apache.camel.component.jetty.CamelContinuationServlet.service(CamelContinuationServlet.java:198)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:668)
at org.eclipse.jetty.servlet.ServletHolder.handle(ServletHolder.java:684)
at
org.eclipse.jetty.servlet.ServletHandler.doHandle(ServletHandler.java:503)
at
org.eclipse.jetty.server.handler.ContextHandler.doHandle(ContextHandler.java:1086)
at org.eclipse.jetty.servlet.ServletHandler.doScope(ServletHandler.java:429)
at
org.eclipse.jetty.server.handler.ContextHandler.doScope(ContextHandler.java:1020)
at
org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:135)
at
org.eclipse.jetty.server.handler.HandlerWrapper.handle(HandlerWrapper.java:116)
at org.eclipse.jetty.server.Server.handleAsync(Server.java:410)
at
org.eclipse.jetty.server.AbstractHttpConnection.handleRequest(AbstractHttpConnection.java:519)
at
org.eclipse.jetty.server.AbstractHttpConnection.headerComplete(AbstractHttpConnection.java:971)
at
org.eclipse.jetty.server.AbstractHttpConnection$RequestHandler.headerComplete(AbstractHttpConnection.java:1033)
at org.eclipse.jetty.http.HttpParser.parseNext(HttpParser.java:651)
at org.eclipse.jetty.http.HttpParser.parseAvailable(HttpParser.java:235)
at
org.eclipse.jetty.server.AsyncHttpConnection.handle(AsyncHttpConnection.java:82)
at
org.eclipse.jetty.io.nio.SelectChannelEndPoint.handle(SelectChannelEndPoint.java:696)
at
org.eclipse.jetty.io.nio.SelectChannelEndPoint$1.run(SelectChannelEndPoint.java:53)
at
org.eclipse.jetty.util.thread.QueuedThreadPool.runJob(QueuedThreadPool.java:608)
at
org.eclipse.jetty.util.thread.QueuedThreadPool$3.run(QueuedThreadPool.java:543)
at java.lang.Thread.run(Thread.java:745)
[qtp562561015-19] WARN org.eclipse.jetty.server.Response - Committed before
500 null
[qtp562561015-19] WARN org.eclipse.jetty.server.AbstractHttpConnection -
/rest/v1/datasets
java.lang.IllegalStateException: Committed
at org.eclipse.jetty.server.Response.resetBuffer(Response.java:1130)
at org.eclipse.jetty.server.Response.sendError(Response.java:317)
at
org.eclipse.jetty.server.handler.ContextHandler.doHandle(ContextHandler.java:1095)
at org.eclipse.jetty.servlet.ServletHandler.doScope(ServletHandler.java:429)
at
org.eclipse.jetty.server.handler.ContextHandler.doScope(ContextHandler.java:1020)
at
org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:135)
at
org.eclipse.jetty.server.handler.HandlerWrappe

REST DSL conundrum

2015-06-22 Thread Tim Dudgeon
I'm struggling with a REST DSL. It handles a POST request for a file 
upload, so the request body is binary type, and the response is JSON 
describing the result. The container is Jetty.


My DSL looks like this:

rest("/rest/v1/datasets")
.post().description("Upload file to create new dataset")
.bindingMode(RestBindingMode.off)
.produces("application/json")
.route()
.to("direct:process_the_body")  // this processed the body and 
returns a result object

.marshal().json(JsonLibrary.Jackson) // which here is converted to JSON
.log("marshal complete. JSON is ${body}")
.endRest()

Its all working fine, and the JSON gets marshalled correctly (the log() 
statement

By the request fails with this error:

[qtp562561015-19] INFO route2 - marshal complete. JSON is 
{"id":13,"name":"big_bad","size":null,"metadata":{"type":"ITEM","className":"java.util.stream.ReferencePipeline$Head","size":1},"created":1434992702164,"updated":1434992702164,"loid":333226}
[qtp562561015-19] WARN org.eclipse.jetty.server.AbstractHttpConnection - 
header full: java.lang.RuntimeException: Header>6144
[qtp562561015-19] ERROR 
org.apache.camel.component.jetty.CamelContinuationServlet - Error 
processing request

HttpException(500,null,null)
at 
org.eclipse.jetty.server.AbstractHttpConnection.commitResponse(AbstractHttpConnection.java:645)
at 
org.eclipse.jetty.server.AbstractHttpConnection$Output.flush(AbstractHttpConnection.java:1122)

at org.apache.camel.util.IOHelper.copy(IOHelper.java:201)
at 
org.apache.camel.component.http.DefaultHttpBinding.copyStream(DefaultHttpBinding.java:318)
at 
org.apache.camel.component.http.DefaultHttpBinding.doWriteDirectResponse(DefaultHttpBinding.java:378)
at 
org.apache.camel.component.http.DefaultHttpBinding.doWriteResponse(DefaultHttpBinding.java:299)
at 
org.apache.camel.component.http.DefaultHttpBinding.writeResponse(DefaultHttpBinding.java:231)
at 
org.apache.camel.component.jetty.CamelContinuationServlet.service(CamelContinuationServlet.java:198)

at javax.servlet.http.HttpServlet.service(HttpServlet.java:668)
at org.eclipse.jetty.servlet.ServletHolder.handle(ServletHolder.java:684)
at 
org.eclipse.jetty.servlet.ServletHandler.doHandle(ServletHandler.java:503)
at 
org.eclipse.jetty.server.handler.ContextHandler.doHandle(ContextHandler.java:1086)

at org.eclipse.jetty.servlet.ServletHandler.doScope(ServletHandler.java:429)
at 
org.eclipse.jetty.server.handler.ContextHandler.doScope(ContextHandler.java:1020)
at 
org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:135)
at 
org.eclipse.jetty.server.handler.HandlerWrapper.handle(HandlerWrapper.java:116)

at org.eclipse.jetty.server.Server.handleAsync(Server.java:410)
at 
org.eclipse.jetty.server.AbstractHttpConnection.handleRequest(AbstractHttpConnection.java:519)
at 
org.eclipse.jetty.server.AbstractHttpConnection.headerComplete(AbstractHttpConnection.java:971)
at 
org.eclipse.jetty.server.AbstractHttpConnection$RequestHandler.headerComplete(AbstractHttpConnection.java:1033)

at org.eclipse.jetty.http.HttpParser.parseNext(HttpParser.java:651)
at org.eclipse.jetty.http.HttpParser.parseAvailable(HttpParser.java:235)
at 
org.eclipse.jetty.server.AsyncHttpConnection.handle(AsyncHttpConnection.java:82)
at 
org.eclipse.jetty.io.nio.SelectChannelEndPoint.handle(SelectChannelEndPoint.java:696)
at 
org.eclipse.jetty.io.nio.SelectChannelEndPoint$1.run(SelectChannelEndPoint.java:53)
at 
org.eclipse.jetty.util.thread.QueuedThreadPool.runJob(QueuedThreadPool.java:608)
at 
org.eclipse.jetty.util.thread.QueuedThreadPool$3.run(QueuedThreadPool.java:543)

at java.lang.Thread.run(Thread.java:745)
[qtp562561015-19] WARN org.eclipse.jetty.server.Response - Committed 
before 500 null
[qtp562561015-19] WARN org.eclipse.jetty.server.AbstractHttpConnection - 
/rest/v1/datasets

java.lang.IllegalStateException: Committed
at org.eclipse.jetty.server.Response.resetBuffer(Response.java:1130)
at org.eclipse.jetty.server.Response.sendError(Response.java:317)
at 
org.eclipse.jetty.server.handler.ContextHandler.doHandle(ContextHandler.java:1095)

at org.eclipse.jetty.servlet.ServletHandler.doScope(ServletHandler.java:429)
at 
org.eclipse.jetty.server.handler.ContextHandler.doScope(ContextHandler.java:1020)
at 
org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:135)
at 
org.eclipse.jetty.server.handler.HandlerWrapper.handle(HandlerWrapper.java:116)

at org.eclipse.jetty.server.Server.handleAsync(Server.java:410)
at 
org.eclipse.jetty.server.AbstractHttpConnection.handleRequest(AbstractHttpConnection.java:519)
at 
org.eclipse.jetty.server.AbstractHttpConnection.headerComplete(AbstractHttpConnection.java:971)
at 
org.eclipse.jetty.server.AbstractHttpConnection$RequestHandler.headerComplete(AbstractHttpConnection.java:1033)

at org.eclipse.jetty.http.HttpParser.parseNext(HttpParser.java:651)
at org.eclipse.jetty.http.HttpParser.parseAvailable(HttpParser.java:235)
at 
org.eclipse.jetty.server.AsyncHttpConnection.handle(AsyncHttpConnection.

swagger + jetty with REST DSL

2015-06-22 Thread Tim Dudgeon
Can someone provide some info on how to get swagger set up with the REST 
DSL in a simple jetty environment.

e.g. something very similar to what Christian described here:
http://blog.christianposta.com/camel/easy-rest-endpoints-with-apache-camel-2-14/
e.g. Java only, no Spring.

Thanks
Tim


routing slip with InOut pattern

2015-06-18 Thread Tim Dudgeon

Is is possible to use routing slip so that it always waits for response?
For instance if the routing slip specifies a seda route then it seems to 
execute asynchronously and the routing slip returns immediately.
If instead I route to a direct endpoint it waits as desired, but that 
direct route is blocked and won't take any more messages until complete.

For example:

from("seda:start")
  .routingSlip(header("someHeader")
  .log("routing finished");

from("direct:routeA")
   .delay(5000)
  .log("hello from route A");

from("seda:routeB")
  .delay(5000)
  .log("hello from route B");


I want to send message to seda:start with routing slip header that 
specifies seda:routeB but I want to see "hello from route B" before I 
see "routing finished".


Thanks
Tim


Re: Is there a tools to convert java dsl to xml ?

2015-06-12 Thread Tim Dudgeon
I was playing with just this a few weeks ago. Here's an example of what 
I got working.
The one gotcha I encountered was that you can't use beans inline in the 
Java DSL. Instead you need to put the bean in the registry and reference 
it from there. Other than that it seems to work "as expected".


Tim

/**
 * Example of how to add a new route to a running Camel context.
 * The route is set as XML. The tricky bit is that any beans used in 
the route

 * need to be set to the registry before setting the route.
*/

package foo

import org.apache.camel.model.language.XQueryExpression
import org.apache.camel.model.language.GroovyExpression
import org.apache.camel.model.*
import org.apache.camel.*
import org.apache.camel.builder.RouteBuilder
import org.apache.camel.impl.DefaultCamelContext
import org.apache.camel.impl.SimpleRegistry

// define route 1 as XML
String xml1 = '''
http://camel.apache.org/schema/spring";>\n\





'''

// generate route 2 and convert to XML
RoutesDefinition routes = new RoutesDefinition()
RouteDefinition route = routes.route()
route.from("timer://foo?fixedRate=true&period=200")
route.log("Hello from Java!")
route.processRef("simpleProcessor2") // the reference to the bean in the 
registry


String xml2 = ModelHelper.dumpModelAsXml(null, routes)
println xml2

// create and start context
long t0 = System.currentTimeMillis();
SimpleRegistry registry = new SimpleRegistry()
CamelContext camelContext = new DefaultCamelContext(registry)
camelContext.start()
long t1 = System.currentTimeMillis();
System.out.println("Camel Context creation took " + (t1 - t0));

// add beans to the registry
registry.put("simpleProcessor1", new SimpleProcessor("simpleProcessor1"))
registry.put("simpleProcessor2", new SimpleProcessor("simpleProcessor2"))
// set route to context
RoutesDefinition routes1 = camelContext.loadRoutesDefinition(new 
ByteArrayInputStream(xml1.bytes))

camelContext.addRouteDefinitions(routes1.getRoutes())
long t3 = System.currentTimeMillis();
RoutesDefinition routes2 = camelContext.loadRoutesDefinition(new 
ByteArrayInputStream(xml2.bytes))

camelContext.addRouteDefinitions(routes2.getRoutes())
long t4 = System.currentTimeMillis();
System.out.println("New route creation took " + (t4 - t3));

// shutdown
sleep(5000)
camelContext.stop()


On 09/06/2015 16:32, Claus Ibsen wrote:

Hi

At runtime you can output any Camel route as xml, there is api on
camel context or jmx api to do so.

This is what tooling such as the camel commands / hawtio etc uses to
visualize the running routes.

On Tue, Jun 9, 2015 at 11:11 AM, cloud  wrote:

hi team,

Is there a tools to convert java dsl to xml ?
Is every java dsl code  have a equal xml counterpart?

When I am reading the camel document's , there are many snippets code that
writen by java dsl .

As a new user , sometimes I have to use xml instead of java dsl  .

In fact , I want to know how could I convert the below code to xml

from("direct:start")
   .setHeader("decisionSlip").method(OrderProcessorBean.class,
"calculateRoute")
   .routingSlip("decisionSlip");


thanks.





--
View this message in context: 
http://camel.465427.n5.nabble.com/Is-there-a-tools-to-convert-java-dsl-to-xml-tp5768015.html
Sent from the Camel - Users mailing list archive at Nabble.com.







Re: Trace from and to endpoints

2015-06-11 Thread Tim Dudgeon
I believe Camel tracks this automatically at the exchange level 
(assuming you are wanting this on a per-exchange basis).
e.g. when you get an exception this information is written to the logs, 
so its already there.

Try looking at the Exchange properties.

Tim

On 10/06/2015 16:51, rwijngaa wrote:

Hi,

What would be the best way to gather the 'path' a camel route takes for an
audit log.
The way i see it i have at least 3 options:  implement my own Tracer
(http://camel.apache.org/tracer.html), implement my own InterceptStrategy or
catch the exchange events by extending the EventNotifierSupport?

Thanks in advance
Regards
Rino



--
View this message in context: 
http://camel.465427.n5.nabble.com/Trace-from-and-to-endpoints-tp5768077.html
Sent from the Camel - Users mailing list archive at Nabble.com.




Tooling for Idea and Netbeans?

2015-06-11 Thread Tim Dudgeon
At today's (really great) Red Hat Microservices Architecture Developer 
Day in London [1] Claus Ibsen mentioned that there is now tooling 
support available for IntelliJ Idea and Netbeans as well as Eclipse 
(presumably what used to be Fuse IDE).

If so this is awesone, but I can't find any info about this.
Could someone provide further info? Sure it will be of interest to many.

Tim


[1] 
http://www.redhatonline.com/uk/seminar/microservices-architecture-developer-day/


Re: deleting jms queue

2015-06-09 Thread Tim Dudgeon

So back to the question about how to delete them :-)

On 09/06/2015 07:54, Claus Ibsen wrote:

Yes then you should use regular queues.


On Tue, Jun 9, 2015 at 8:47 AM, Tim Dudgeon  wrote:

Well, maybe I'm wrong to call it a temp queue. This is not an InOut pattern.
Its InOnly followed (potentially much later) by a response to a "private"
queue (specified by JmsReplyTo header) that is InOnly and handled by a
different route/consumer.
Once processing is complete I need the queue to be deleted.

Tim


On 09/06/2015 07:07, Claus Ibsen wrote:

Hi

Afair temp queues are affilianted with the jms session and automatic
deleted by the broker when the session is closed - eg AMQ should do
this.



On Mon, Jun 8, 2015 at 5:31 PM, Tim Dudgeon  wrote:

I'm using a temp JMS queue to return some results.
Once I've finished processing I want to delete the queue. What's the best
approach?
I'm assuming its best to manually generate the temp queue at the start
and
then manually delete it when finished.
I notice I could use JmsTemporaryQueueEndpoint [1] which I know how to
get
hold of, and that can give me the javax.jms.TemporaryQueue, which I can
then
delete(), but how to get a handle on the javax.jms.Session session?
Or is there a better way?

Thanks
Tim

[1]

http://camel.apache.org/maven/current/camel-jms/apidocs/org/apache/camel/component/jms/JmsTemporaryQueueEndpoint.html
[2] http://docs.oracle.com/javaee/7/api/javax/jms/TemporaryQueue.html










Re: deleting jms queue

2015-06-08 Thread Tim Dudgeon
Well, maybe I'm wrong to call it a temp queue. This is not an InOut 
pattern. Its InOnly followed (potentially much later) by a response to a 
"private" queue (specified by JmsReplyTo header) that is InOnly and 
handled by a different route/consumer.

Once processing is complete I need the queue to be deleted.

Tim

On 09/06/2015 07:07, Claus Ibsen wrote:

Hi

Afair temp queues are affilianted with the jms session and automatic
deleted by the broker when the session is closed - eg AMQ should do
this.



On Mon, Jun 8, 2015 at 5:31 PM, Tim Dudgeon  wrote:

I'm using a temp JMS queue to return some results.
Once I've finished processing I want to delete the queue. What's the best
approach?
I'm assuming its best to manually generate the temp queue at the start and
then manually delete it when finished.
I notice I could use JmsTemporaryQueueEndpoint [1] which I know how to get
hold of, and that can give me the javax.jms.TemporaryQueue, which I can then
delete(), but how to get a handle on the javax.jms.Session session?
Or is there a better way?

Thanks
Tim

[1]
http://camel.apache.org/maven/current/camel-jms/apidocs/org/apache/camel/component/jms/JmsTemporaryQueueEndpoint.html
[2] http://docs.oracle.com/javaee/7/api/javax/jms/TemporaryQueue.html







deleting jms queue

2015-06-08 Thread Tim Dudgeon

I'm using a temp JMS queue to return some results.
Once I've finished processing I want to delete the queue. What's the 
best approach?
I'm assuming its best to manually generate the temp queue at the start 
and then manually delete it when finished.
I notice I could use JmsTemporaryQueueEndpoint [1] which I know how to 
get hold of, and that can give me the javax.jms.TemporaryQueue, which I 
can then delete(), but how to get a handle on the javax.jms.Session session?

Or is there a better way?

Thanks
Tim

[1] 
http://camel.apache.org/maven/current/camel-jms/apidocs/org/apache/camel/component/jms/JmsTemporaryQueueEndpoint.html

[2] http://docs.oracle.com/javaee/7/api/javax/jms/TemporaryQueue.html


programatic access to jms queue

2015-06-08 Thread Tim Dudgeon
I'm wanting to programatically access a JMS queue on a dynamic basis, 
but use the Camel infrastructure to do this.

I've tried something like this:

JmsEndpoint jms = 
getCamelContext().getEndpoint("activemq:queue:myqueue", JmsEndpoint.class);

JmsConsumer consumer = jms.createConsumer((Exchange exchange) -> {
Object body = exchange.getIn().getBody();
System.out.println("BODY: " + body);
});
consumer.start();

But this only processes the first message in the queue.
How should I be doing this?


Tim


Re: monitoring JMS

2015-06-07 Thread Tim Dudgeon

Hi Carsten

Yes, that's what I kinda figured.
I did find BrowsableEndpoint, as described here which actually give me 
most of what I need.

http://camel.465427.n5.nabble.com/Issue-trying-to-browse-a-activemq-queue-td477750.html
Beyond that it looks like I need JMX.

Tim

On 06/06/2015 06:21, Carsten Ringe wrote:

Hi Tim,

sounds like the setup that we are doing as well. I am not aware of any feature 
in the JMS component of Camel and we're using the JMX features of our message 
broker to get the information.

We also deployed Jolokia to all our servers so getting JMX information can be 
done via HTTP requests. That way we don't have to leave our preferred 
communication and it is also fairly easy to get the information into a Camel 
route too.

Hope this helps,

Carsten




monitoring JMS

2015-06-05 Thread Tim Dudgeon

Camel provides a nice way to submit and consume from JMS queues.
I also need to be able to monitor those queues. Does The JMS Component 
provide and nice hooks for inspecting those queues, or do I need to fall 
back to raw JMS or JMX?


Example: I have a service that uses a Camel route to submit to a JMS 
queue, but I also want the service to be able to tell me the number of 
pending messages for the queue.


Thanks
Tim


Re: route <-> XML <-> route

2015-05-26 Thread Tim Dudgeon

On 26/05/2015 16:55, Pontus Ullgren wrote:

Depending on the registry you use you can create the beans in java and add
them to the registry in runtime before you add (and start) the route in the
context.
Yes, that's what I figured. Its the exact mechanism for doing so that 
I'm trying to figure out.


I have some example code on how to do this using a spring registry. However
since you say you are not using spring you will have to figure out how to
add the beans programmatically to the registry implementation you are
using.
I'm not currently using spring, but I could do so if there was a good 
reason too.
Performance is a key issue. I'm finding that creating a new Spring 
ApplicationContext including Camel from XML is fairly slow (about 1.3s), 
whilst creating a new Camel context directly in Java (no Spring) is 
quite a bit faster (about 0.3s) whilst adding a new route to a running 
context is superfast (about 0.01s), hence the preferred option.


Tim



Best regards
Pontus

On Tue, 26 May 2015 16:28 Tim Dudgeon  wrote:


The beans are defined at runtime, so can't go in the spring xml that is
used on startup (and I'm not actually using spring, though could do if
essential).
I need to provide the route definition plus any beans it uses at
runtime, after the context has started.

Tim

On 26/05/2015 15:23, Claus Ibsen wrote:

Hi

If you are using spring xml then the beans need to go in the spring
xml file as .

You may be able to add those beans later using some spring java api.

On Tue, May 26, 2015 at 2:21 PM, Tim Dudgeon 

wrote:

Sorry, not clear on this. Where does the  element go?
The XML generated from the route looks like this:


http://camel.apache.org/schema/spring";>

  
  
  




The  element would normally be part of the spring XML, but

outside the

routes definition looking something like this:





http://camel.apache.org/schema/spring";>
  

  



Can the beans be defined in this way at runtime or is some other

mechanism

needed to instantiate the beans and add them to the registry

independently

of adding the route (as XML)?

Tim




On 26/05/2015 08:19, Claus Ibsen wrote:

Hi

Yeah 

On Tue, May 26, 2015 at 9:02 AM, Tim Dudgeon 
wrote:

Yes, but how to specify the bean that is referenced? Can that be
specified
in the XML using a bean element as if it was being using on startup,

or

does
it need to be added to the registry "manually"?

Tim


On 26/05/2015 07:49, Claus Ibsen wrote:

On Mon, May 25, 2015 at 3:01 PM, Tim Dudgeon 
wrote:

Hi,

I'm wanting some guidance on how to generate a route definition

using

the
API in a way that allows it to be converted to XML and then

executed.

I've
got the basics sorted, but struggling on how to handle processors

and

beans.
For instance, if I generate a route like this:

// generate the route
RoutesDefinition routes1 = new RoutesDefinition()
RouteDefinition route = routes1.route()
route.from("timer://foo?fixedRate=true&period=200")
route.log("Hello World!")
route.process(new SimpleProcessor())

// set route to context
CamelContext camelContext = new DefaultCamelContext()
camelContext.start()
camelContext.addRouteDefinitions(routes1.getRoutes())

Then the route works fine (e.g. my SimpleProcessor gets called as
expected).
But if I generate the XML definition of the route it looks like

this:


http://camel.apache.org/schema/spring";>







e.g. the processor definition has been lost.
I suspect I need to register the processor bean with the registry

and

use
the processRef() method on the route, or something along those

lines.

Does anyone have any examples of how to handle this?


Yes for representing this as xml, you would need to use a ref for the
processor




Thanks
Tim










Re: route <-> XML <-> route

2015-05-26 Thread Tim Dudgeon
The beans are defined at runtime, so can't go in the spring xml that is 
used on startup (and I'm not actually using spring, though could do if 
essential).
I need to provide the route definition plus any beans it uses at 
runtime, after the context has started.


Tim

On 26/05/2015 15:23, Claus Ibsen wrote:

Hi

If you are using spring xml then the beans need to go in the spring
xml file as .

You may be able to add those beans later using some spring java api.

On Tue, May 26, 2015 at 2:21 PM, Tim Dudgeon  wrote:

Sorry, not clear on this. Where does the  element go?
The XML generated from the route looks like this:


http://camel.apache.org/schema/spring";>
   
 
 
 




The  element would normally be part of the spring XML, but outside the
routes definition looking something like this:



   

   http://camel.apache.org/schema/spring";>
 
   
 
   


Can the beans be defined in this way at runtime or is some other mechanism
needed to instantiate the beans and add them to the registry independently
of adding the route (as XML)?

Tim




On 26/05/2015 08:19, Claus Ibsen wrote:

Hi

Yeah 

On Tue, May 26, 2015 at 9:02 AM, Tim Dudgeon 
wrote:

Yes, but how to specify the bean that is referenced? Can that be
specified
in the XML using a bean element as if it was being using on startup, or
does
it need to be added to the registry "manually"?

Tim


On 26/05/2015 07:49, Claus Ibsen wrote:

On Mon, May 25, 2015 at 3:01 PM, Tim Dudgeon 
wrote:

Hi,

I'm wanting some guidance on how to generate a route definition using
the
API in a way that allows it to be converted to XML and then executed.
I've
got the basics sorted, but struggling on how to handle processors and
beans.
For instance, if I generate a route like this:

// generate the route
RoutesDefinition routes1 = new RoutesDefinition()
RouteDefinition route = routes1.route()
route.from("timer://foo?fixedRate=true&period=200")
route.log("Hello World!")
route.process(new SimpleProcessor())

// set route to context
CamelContext camelContext = new DefaultCamelContext()
camelContext.start()
camelContext.addRouteDefinitions(routes1.getRoutes())

Then the route works fine (e.g. my SimpleProcessor gets called as
expected).
But if I generate the XML definition of the route it looks like this:


http://camel.apache.org/schema/spring";>







e.g. the processor definition has been lost.
I suspect I need to register the processor bean with the registry and
use
the processRef() method on the route, or something along those lines.
Does anyone have any examples of how to handle this?


Yes for representing this as xml, you would need to use a ref for the
processor




Thanks
Tim












Re: route <-> XML <-> route

2015-05-26 Thread Tim Dudgeon

Sorry, not clear on this. Where does the  element go?
The XML generated from the route looks like this:


http://camel.apache.org/schema/spring";>
  







The  element would normally be part of the spring XML, but outside 
the routes definition looking something like this:




  

  http://camel.apache.org/schema/spring";>

  

  


Can the beans be defined in this way at runtime or is some other 
mechanism needed to instantiate the beans and add them to the registry 
independently of adding the route (as XML)?


Tim



On 26/05/2015 08:19, Claus Ibsen wrote:

Hi

Yeah 

On Tue, May 26, 2015 at 9:02 AM, Tim Dudgeon  wrote:

Yes, but how to specify the bean that is referenced? Can that be specified
in the XML using a bean element as if it was being using on startup, or does
it need to be added to the registry "manually"?

Tim


On 26/05/2015 07:49, Claus Ibsen wrote:

On Mon, May 25, 2015 at 3:01 PM, Tim Dudgeon 
wrote:

Hi,

I'm wanting some guidance on how to generate a route definition using the
API in a way that allows it to be converted to XML and then executed.
I've
got the basics sorted, but struggling on how to handle processors and
beans.
For instance, if I generate a route like this:

// generate the route
RoutesDefinition routes1 = new RoutesDefinition()
RouteDefinition route = routes1.route()
route.from("timer://foo?fixedRate=true&period=200")
route.log("Hello World!")
route.process(new SimpleProcessor())

// set route to context
CamelContext camelContext = new DefaultCamelContext()
camelContext.start()
camelContext.addRouteDefinitions(routes1.getRoutes())

Then the route works fine (e.g. my SimpleProcessor gets called as
expected).
But if I generate the XML definition of the route it looks like this:


http://camel.apache.org/schema/spring";>







e.g. the processor definition has been lost.
I suspect I need to register the processor bean with the registry and use
the processRef() method on the route, or something along those lines.
Does anyone have any examples of how to handle this?


Yes for representing this as xml, you would need to use a ref for the
processor




Thanks
Tim










Re: route <-> XML <-> route

2015-05-26 Thread Tim Dudgeon
Yes, but how to specify the bean that is referenced? Can that be 
specified in the XML using a bean element as if it was being using on 
startup, or does it need to be added to the registry "manually"?


Tim

On 26/05/2015 07:49, Claus Ibsen wrote:

On Mon, May 25, 2015 at 3:01 PM, Tim Dudgeon  wrote:

Hi,

I'm wanting some guidance on how to generate a route definition using the
API in a way that allows it to be converted to XML and then executed. I've
got the basics sorted, but struggling on how to handle processors and beans.
For instance, if I generate a route like this:

// generate the route
RoutesDefinition routes1 = new RoutesDefinition()
RouteDefinition route = routes1.route()
route.from("timer://foo?fixedRate=true&period=200")
route.log("Hello World!")
route.process(new SimpleProcessor())

// set route to context
CamelContext camelContext = new DefaultCamelContext()
camelContext.start()
camelContext.addRouteDefinitions(routes1.getRoutes())

Then the route works fine (e.g. my SimpleProcessor gets called as expected).
But if I generate the XML definition of the route it looks like this:


http://camel.apache.org/schema/spring";>







e.g. the processor definition has been lost.
I suspect I need to register the processor bean with the registry and use
the processRef() method on the route, or something along those lines.
Does anyone have any examples of how to handle this?


Yes for representing this as xml, you would need to use a ref for the processor




Thanks
Tim







route <-> XML <-> route

2015-05-25 Thread Tim Dudgeon

Hi,

I'm wanting some guidance on how to generate a route definition using 
the API in a way that allows it to be converted to XML and then 
executed. I've got the basics sorted, but struggling on how to handle 
processors and beans.

For instance, if I generate a route like this:

// generate the route
RoutesDefinition routes1 = new RoutesDefinition()
RouteDefinition route = routes1.route()
route.from("timer://foo?fixedRate=true&period=200")
route.log("Hello World!")
route.process(new SimpleProcessor())

// set route to context
CamelContext camelContext = new DefaultCamelContext()
camelContext.start()
camelContext.addRouteDefinitions(routes1.getRoutes())

Then the route works fine (e.g. my SimpleProcessor gets called as expected).
But if I generate the XML definition of the route it looks like this:


http://camel.apache.org/schema/spring";>







e.g. the processor definition has been lost.
I suspect I need to register the processor bean with the registry and 
use the processRef() method on the route, or something along those lines.

Does anyone have any examples of how to handle this?

Thanks
Tim


metadata for components, processors etc

2015-05-01 Thread Tim Dudgeon
Is there any mechanism for specifying metadata that describes what 
inputs and outputs components, processors ... can consume/produce.
I'm thinking of this from the perspective of a GUI builder tool that 
allows a route to be assembled so for this it's necessary to know which 
nodes are "compatible" with others. For instance if one produces bananas 
then it can't be directly piped into one that consumes oranges (of 
course TypeConverters need to be considered here).
For instance, is there an existing mechanism for providing @Consumes and 
@Produces annotations on components, processors etc.

Same question for routes, but I suspect that's much the same question.

Tim


TypeConverter with generics

2015-03-09 Thread Tim Dudgeon
I may be missing something obvious here, but I'm can't find a way to do 
a type conversion that uses generics.
For instance, I want to do a conversion of an InputStream into a 
Collection of Foo objects.

So my convert method might look like this:

@Converter
public List convertToFoo(InputStream input, Exchange exch) {
// something that converts the input into List
}


But to use this I can't specify a generic type, only a class name 
(presumably because of erasures)


List myFoos = camelContext.getTypeConverter().convertTo(List.class);

And this means that I can't have another conversion that converts to 
List.



The only workaround I can see is to create subclasses of List

class FooList extends List { }

class BarList extends List { }


A related topic is described here:
http://gafter.blogspot.co.uk/2006/12/super-type-tokens.html

Are there any better solutions to this?

Tim










Re: REST DSL - including documents

2015-02-01 Thread Tim Dudgeon

Taariq

Thanks so much! Works nicely.
I don't get the hash bit.
The only mention in the docs is like this:
from("jetty:http://0.0.0.0:9080/myservice?handlers=securityHandler";)
which doesn't use a #.
What's the # doing?

Tim

On 01/02/2015 15:47, Taariq Levack wrote:

Tim you missed the hash in the context handler, should be #contextHandler
I also had to redefine that handler, you'll find the working code in your
gist.

Taariq



On Sat, Jan 31, 2015 at 8:56 PM, Tim Dudgeon  wrote:


Pinging again on this.
I looked over my attempts to add a ContextHandler to Jetty to serve up
static content and can't find what's wrong.
Here's the gist again:
https://gist.github.com/tdudgeon/2f242578fd0742e713a7
The mechanism for adding a ContextHandler does work in standalone Jetty
though I can't get it to work in my example. Could it be a difference in
the
Jetty version (the one used by Camel is quite old).
And I did get other handlers (authentication) to work in camel.

Thanks
Tim



--
View this message in context:
http://camel.465427.n5.nabble.com/REST-DSL-including-documents-tp5762034p5762283.html
Sent from the Camel - Users mailing list archive at Nabble.com.





Re: REST DSL - including documents

2015-01-31 Thread Tim Dudgeon
Pinging again on this.
I looked over my attempts to add a ContextHandler to Jetty to serve up
static content and can't find what's wrong.
Here's the gist again:
https://gist.github.com/tdudgeon/2f242578fd0742e713a7
The mechanism for adding a ContextHandler does work in standalone Jetty
though I can't get it to work in my example. Could it be a difference in the
Jetty version (the one used by Camel is quite old).
And I did get other handlers (authentication) to work in camel.

Thanks
Tim



--
View this message in context: 
http://camel.465427.n5.nabble.com/REST-DSL-including-documents-tp5762034p5762283.html
Sent from the Camel - Users mailing list archive at Nabble.com.


Re: http caller's IP address

2015-01-29 Thread Tim Dudgeon
Thanks. For reference this is how it can be done (for Jetty at least, 
but probs most others too) using a simple expression:


simple("${header.CamelHttpServletRequest?.remoteAddr}")

Tim

On 29/01/2015 16:56, Claus Ibsen wrote:

Hi

Depending on which component you use, you can get access to its native
type, such as HttpRequest, and use that to get the caller ip, just as
you would have to do if you use the components without rest-dsl.

On Thu, Jan 29, 2015 at 5:41 PM, Tim Dudgeon  wrote:

When using REST DSL with jetty/restlet/etc is it possible to know the
caller's IP address?
I can't see any header property for this.

Tim







http caller's IP address

2015-01-29 Thread Tim Dudgeon
When using REST DSL with jetty/restlet/etc is it possible to know the 
caller's IP address?

I can't see any header property for this.

Tim


Re: REST DSL - including documents

2015-01-23 Thread Tim Dudgeon

Thanks, That's an interesting example.
I'll take a look over it.
In the meantime I kept bashing away at doing it the Jetty way, but don't 
quite have it working. I created this gist to try to illustrate it:

https://gist.github.com/tdudgeon/2f242578fd0742e713a7
(note I backed away slightly from what Claus suggested and and tried 
doing direct on the jetty endpoint as that seemed simpler).


Everything runs, the jetty and rest routes work fine, but the static 
content stubbornly refuses to serve.

The only thing suspicious that I see reported is this:
[main] INFO org.eclipse.jetty.server.handler.ContextHandler - stopped 
o.e.j.s.ServletContextHandler{/,null}


Anyone got any thoughts?

Tim


On 23/01/2015 15:54, scottdawson wrote:

Hello,
Here's the  JIRA ticket 
Claus referred to. It appears to be "stalled".

In the meantime you might want to use the code that the new feature is based
on, written by Tracy Snell and documented  here

.

Regards,
Scott



--
View this message in context: 
http://camel.465427.n5.nabble.com/REST-DSL-including-documents-tp5762034p5762064.html
Sent from the Camel - Users mailing list archive at Nabble.com.




Re: REST DSL - including documents

2015-01-23 Thread Tim Dudgeon

If using jetty you can also use the jetty api to add a
handler to service static files.


So I'm looking at doing this. I think I worked out how to create a Jetty 
ContextHandler and associated ResourceHandler. But I'm not totally sure how to 
set these.
I can get the JettyHttpComponent using
restConfiguration().component("jetty")
but in JettyHttpComponent the methods the deal with the handlers are protected. 
Seems like this has to be done through the endpoint (using the 
endpointProperty(String, String) method in the REST DSL, which only allows 
setting it as a comma separated list of values that are present in the registry.
Is this on the right lines, or am I missing something simpler?

Tim



Re: REST DSL - including documents

2015-01-23 Thread Tim Dudgeon
I don't think so. If I understand correctly swagger automatically 
generates documentation on a REST API.

Though that might well be useful, its not what I'm after.
I'm wanting to add additional pages - hand crafted ones, not 
automagically generated.
Essentially I'm wanting to be able to serve up pages without setting up 
a full blown web server.


Tim


On 23/01/2015 01:33, Anton Hughes wrote:

On Fri, Jan 23, 2015 at 6:58 AM, Tim Dudgeon  wrote:


I'm successfully using REST DSL to serve up some simple services and want
to include some simple HTML docs to describe and illustrate the services
provided and prefer to keep this as
simple as possible.
I just have a process started by a Main class that starts a camel context
with some routes exposed through the REST DSL. It seems to work fine with
restlet and jetty.
Now I want to include some HTML docs.
I suppose I could use the DSL to define a URL that returned some text that
was the HTML, but there must a be a better way such as defining a path
where restlet/jetty/whatever would look for html docs.


Hi Tim

It sounds like you want Swagger. See http://camel.apache.org/swagger.html
and http://swagger.io/.





REST DSL - including documents

2015-01-22 Thread Tim Dudgeon
I'm successfully using REST DSL to serve up some simple services and 
want to include some simple HTML docs to describe and illustrate the 
services provided and prefer to keep this as

simple as possible.
I just have a process started by a Main class that starts a camel 
context with some routes exposed through the REST DSL. It seems to work 
fine with restlet and jetty.

Now I want to include some HTML docs.
I suppose I could use the DSL to define a URL that returned some text 
that was the HTML, but there must a be a better way such as defining a 
path where restlet/jetty/whatever would look for html docs.

Any suggestions?
Thx
Tim


Sending route for execution

2015-01-03 Thread Tim Dudgeon
I am trying to work out best approaches to sending a route to a remote 
CamelContext for execution. e.g. I have a client that generates the 
route definition and then needs to send it to a sever for execution.


I notice that you can apply a new route to an existing context:
http://camel.apache.org/loading-routes-from-xml-files.html
Q. Is spring XML the only format supported?
Q. Is there a way to generate the route using the Java object model and 
then generate the XML from that?


I also see the ManagedCamelContextMBean.addOrUpdateRoutesFromXml() method:
http://camel.apache.org/maven/current/camel-core/apidocs/org/apache/camel/api/management/mbean/ManagedCamelContextMBean.html#addOrUpdateRoutesFromXml(java.lang.String)
Q. Presumably this is the approach to use for remote deployment?

I also seem to recall some mechanism for deploying camel "jobs" to a 
server, but can't find this right now. Is there such a thing.


And in terms of scalability, I'm assuming that the CamelContext is quite 
a heavyweight object, so its better (in general terms) to deploy 
multiple routes to one context rather than end up with having a large 
number of contexts running each with one or two routes?


Sorry for all the questions :-(

Tim


Re: streaming results using rest dsl

2015-01-03 Thread Tim Dudgeon

On 03/01/2015 09:35, Henryk Konsek wrote:

Hi Tim,


Is there a way to stream output using the Rest DSL?

I used the following to download stream of bytes from the REST API:

rest("/api").
 
get("/download").bindingMode(RestBindingMode.off).produces('application/octet-stream').route().
 setBody().constant(new ByteArrayOutputStream("foo".getBytes()));.

So I guess that setting OutputStream as the response body should do the trick.

Cheers.

Henryk, thanks for the suggestion.
So the problem I see with that is that
1. the complete byte array has to be held in memory so it doesn't scale
2. the first byte isn't sent until the last one is generated so you 
don't get an immediate response


I was thinking you need to somehow get a "forward reference" to an 
OutputStream to write to. I tried setting a 
javax.ws.rs.core.StreamingOutput in the hope that this would be handled, 
but it wasn't (just got the toString() representation).


Also, I don't understand the .constant() bit. The value is not a 
constant, so I don't see why that's needed.


Tim




streaming results using rest dsl

2015-01-02 Thread Tim Dudgeon

Is there a way to stream output using the Rest DSL?
Something like using the JAC-RS StreamingOutput class?
http://docs.oracle.com/javaee/6/api/javax/ws/rs/core/StreamingOutput.html

I have large amount of data (split into multiple Exchanges) and don't 
want to wait for all to be processed before start sending the response.


Tim



Re: general approach to streaming

2014-12-03 Thread Tim Dudgeon
Yes, I know about SEDA, and use it quite a bit, but its not really what 
I'm after here.
I'm wanting to pass an Iterable such as a Blocking Queue directly 
between processors.


Tim

On 28/11/2014 02:44, today wrote:

Tim, the SEDA component is designed to produce/consume messages quickly and
provides a queue (BlockingQueue) in between resources to buffer the flow and
provides options such as max size and blockWhenFull to limit memory usage
and slow a producer as needed, etc...

http://camel.apache.org/seda.htm


Tim Dudgeon wrote

I've got various cases where I have large number of results (POJOs) and
want to stream them so that:
1. initial results are returned immediately
2. memory utilisation is kept under control

I was expecting to use something like using a BlockingQueue [1] but
according to the Javadocs:

  > A BlockingQueue does not intrinsically support any kind of "close" or
"shutdown" operation to indicate that no more items will be added.

which seems to be essential and I can't find any obvious way to handle
this.
Am I missing something obvious here?

[1]
https://docs.oracle.com/javase/7/docs/api/java/util/concurrent/BlockingQueue.html


Tim





-
Ben O'Day
IT Consultant -http://consulting-notes.com

--
View this message in context: 
http://camel.465427.n5.nabble.com/general-approach-to-streaming-tp5759483p5759732.html
Sent from the Camel - Users mailing list archive at Nabble.com.




Re: POJO binding with the Rest DSL

2014-11-23 Thread Tim Dudgeon

Yes, I understand that, and got it working that way.
I had misunderstood where the POJO binding fitted in.
Thanks for your help.

Tim


On 22/11/2014 09:27, Claus Ibsen wrote:

Hi

The rest DSL is on the other side, eg on the server side, to exposes
Camel routes as REST services.
Not on the client side how to call another REST service.

For POJO -> Json you can use jackson to turn that into json.

On Fri, Nov 21, 2014 at 6:41 PM, Tim Dudgeon  wrote:

OK, that figures, and I got it to work.
But it seems to circumvent the whole purpose of the POJO binding with rest
DSL.
How are you supposed to send POJO to Rest DSL within Camel.
I briefly tried using restlet like this:

t.requestBody('restlet:http://$BASE_URL/foo?restletMethod=POST', p)

but that didn't work.

Thanks
Tim





On 21/11/2014 17:12, Claus Ibsen wrote:

Hi

Its the client code you write to send the Person using http4. It does
not know how to convert that to json. You need to convert it to json
first, and then send that instead of the Person java object.

On Fri, Nov 21, 2014 at 5:56 PM, Tim Dudgeon 
wrote:

I'm having problems getting POJO binding working with the Rest DSL.
I put together a simple example in Groovy, but it fails:



package com.im.examples.search

import org.apache.camel.CamelContext
import org.apache.camel.ProducerTemplate
import org.apache.camel.builder.RouteBuilder
import org.apache.camel.impl.DefaultCamelContext
import org.apache.camel.model.rest.RestBindingMode
import org.apache.camel.model.dataformat.JsonLibrary

String HOST = 'localhost'
String PORT = '43256'
String BASE_URL = "$HOST:$PORT/search"

class Person {
  String firstName
  String lastName
}

CamelContext camelContext = new DefaultCamelContext()
camelContext.addRoutes(new RouteBuilder() {
  def void configure() {

restConfiguration().component("restlet").host(HOST).port(PORT).bindingMode(RestBindingMode.json)
  rest("/search")
  .post("/foo").type(Person.class).to("direct:end")
  from('direct:end')
  .log('${body}')
  .transform().constant('Welcome')
  from('direct:testmarshal')
  .marshal().json(JsonLibrary.Jackson)
  .log('JSON: ${body}')
  }
  })
camelContext.start()

Person p = new Person(firstName: 'John', lastName: 'Doe')
ProducerTemplate t = camelContext.createProducerTemplate()
t.sendBody('direct:testmarshal', p)
def resp = t.requestBody("http4:$BASE_URL/foo", p)
println "resp: $resp"

camelContext.stop()




The error I get is:


Caused by: org.apache.camel.InvalidPayloadException: No body available of
type: java.io.InputStream but has value:
com.im.examples.search.Person@6c4b8217 of type:
com.im.examples.search.Person on: Message:
com.im.examples.search.Person@6c4b8217. Caused by: No type converter
available to convert from type: com.im.examples.search.Person to the
required type: java.io.InputStream with value
com.im.examples.search.Person@6c4b8217. Exchange[Message:
com.im.examples.search.Person@6c4b8217]. Caused by:
[org.apache.camel.NoTypeConversionAvailableException - No type converter
available to convert from type: com.im.examples.search.Person to the
required type: java.io.InputStream with value
com.im.examples.search.Person@6c4b8217]
at

org.apache.camel.impl.MessageSupport.getMandatoryBody(MessageSupport.java:101)
at

org.apache.camel.component.http4.HttpProducer.createRequestEntity(HttpProducer.java:461)
at

org.apache.camel.component.http4.HttpProducer.createMethod(HttpProducer.java:368)
at

org.apache.camel.component.http4.HttpProducer.process(HttpProducer.java:106)
at

org.apache.camel.util.AsyncProcessorConverterHelper$ProcessorToAsyncProcessorBridge.process(AsyncProcessorConverterHelper.java:61)
at

org.apache.camel.processor.CamelInternalProcessor.process(CamelInternalProcessor.java:191)
at

org.apache.camel.processor.UnitOfWorkProducer.process(UnitOfWorkProducer.java:74)
at

org.apache.camel.impl.ProducerCache$2.doInProducer(ProducerCache.java:375)
at

org.apache.camel.impl.ProducerCache$2.doInProducer(ProducerCache.java:343)
at
org.apache.camel.impl.ProducerCache.doInProducer(ProducerCache.java:233)
at
org.apache.camel.impl.ProducerCache.sendExchange(ProducerCache.java:343)
at org.apache.camel.impl.ProducerCache.send(ProducerCache.java:201)
at

org.apache.camel.impl.DefaultProducerTemplate.send(DefaultProducerTemplate.java:128)
at

org.apache.camel.impl.DefaultProducerTemplate.sendBody(DefaultProducerTemplate.java:132)
... 28 more
Caused by: org.apache.camel.NoTypeConversionAvailableException: No type
converter available to convert from type: com.im.examples.search.Person
to
the required type: java.io.InputStream with value
com.im.examples.search.Person@6c4b8217
at

org.apache.camel.impl.converter.BaseTypeConverterRegis

general approach to streaming

2014-11-21 Thread Tim Dudgeon
I've got various cases where I have large number of results (POJOs) and 
want to stream them so that:

1. initial results are returned immediately
2. memory utilisation is kept under control

I was expecting to use something like using a BlockingQueue [1] but 
according to the Javadocs:


> A BlockingQueue does not intrinsically support any kind of "close" or 
"shutdown" operation to indicate that no more items will be added.


which seems to be essential and I can't find any obvious way to handle this.
Am I missing something obvious here?

[1] 
https://docs.oracle.com/javase/7/docs/api/java/util/concurrent/BlockingQueue.html



Tim


Re: POJO binding with the Rest DSL

2014-11-21 Thread Tim Dudgeon

OK, that figures, and I got it to work.
But it seems to circumvent the whole purpose of the POJO binding with 
rest DSL.

How are you supposed to send POJO to Rest DSL within Camel.
I briefly tried using restlet like this:

t.requestBody('restlet:http://$BASE_URL/foo?restletMethod=POST', p)

but that didn't work.

Thanks
Tim




On 21/11/2014 17:12, Claus Ibsen wrote:

Hi

Its the client code you write to send the Person using http4. It does
not know how to convert that to json. You need to convert it to json
first, and then send that instead of the Person java object.

On Fri, Nov 21, 2014 at 5:56 PM, Tim Dudgeon  wrote:

I'm having problems getting POJO binding working with the Rest DSL.
I put together a simple example in Groovy, but it fails:



package com.im.examples.search

import org.apache.camel.CamelContext
import org.apache.camel.ProducerTemplate
import org.apache.camel.builder.RouteBuilder
import org.apache.camel.impl.DefaultCamelContext
import org.apache.camel.model.rest.RestBindingMode
import org.apache.camel.model.dataformat.JsonLibrary

String HOST = 'localhost'
String PORT = '43256'
String BASE_URL = "$HOST:$PORT/search"

class Person {
 String firstName
 String lastName
}

CamelContext camelContext = new DefaultCamelContext()
camelContext.addRoutes(new RouteBuilder() {
 def void configure() {
restConfiguration().component("restlet").host(HOST).port(PORT).bindingMode(RestBindingMode.json)
 rest("/search")
 .post("/foo").type(Person.class).to("direct:end")
 from('direct:end')
 .log('${body}')
 .transform().constant('Welcome')
 from('direct:testmarshal')
 .marshal().json(JsonLibrary.Jackson)
 .log('JSON: ${body}')
 }
 })
camelContext.start()

Person p = new Person(firstName: 'John', lastName: 'Doe')
ProducerTemplate t = camelContext.createProducerTemplate()
t.sendBody('direct:testmarshal', p)
def resp = t.requestBody("http4:$BASE_URL/foo", p)
println "resp: $resp"

camelContext.stop()




The error I get is:


Caused by: org.apache.camel.InvalidPayloadException: No body available of
type: java.io.InputStream but has value:
com.im.examples.search.Person@6c4b8217 of type:
com.im.examples.search.Person on: Message:
com.im.examples.search.Person@6c4b8217. Caused by: No type converter
available to convert from type: com.im.examples.search.Person to the
required type: java.io.InputStream with value
com.im.examples.search.Person@6c4b8217. Exchange[Message:
com.im.examples.search.Person@6c4b8217]. Caused by:
[org.apache.camel.NoTypeConversionAvailableException - No type converter
available to convert from type: com.im.examples.search.Person to the
required type: java.io.InputStream with value
com.im.examples.search.Person@6c4b8217]
at
org.apache.camel.impl.MessageSupport.getMandatoryBody(MessageSupport.java:101)
at
org.apache.camel.component.http4.HttpProducer.createRequestEntity(HttpProducer.java:461)
at
org.apache.camel.component.http4.HttpProducer.createMethod(HttpProducer.java:368)
at
org.apache.camel.component.http4.HttpProducer.process(HttpProducer.java:106)
at
org.apache.camel.util.AsyncProcessorConverterHelper$ProcessorToAsyncProcessorBridge.process(AsyncProcessorConverterHelper.java:61)
at
org.apache.camel.processor.CamelInternalProcessor.process(CamelInternalProcessor.java:191)
at
org.apache.camel.processor.UnitOfWorkProducer.process(UnitOfWorkProducer.java:74)
at
org.apache.camel.impl.ProducerCache$2.doInProducer(ProducerCache.java:375)
at
org.apache.camel.impl.ProducerCache$2.doInProducer(ProducerCache.java:343)
at org.apache.camel.impl.ProducerCache.doInProducer(ProducerCache.java:233)
at org.apache.camel.impl.ProducerCache.sendExchange(ProducerCache.java:343)
at org.apache.camel.impl.ProducerCache.send(ProducerCache.java:201)
at
org.apache.camel.impl.DefaultProducerTemplate.send(DefaultProducerTemplate.java:128)
at
org.apache.camel.impl.DefaultProducerTemplate.sendBody(DefaultProducerTemplate.java:132)
... 28 more
Caused by: org.apache.camel.NoTypeConversionAvailableException: No type
converter available to convert from type: com.im.examples.search.Person to
the required type: java.io.InputStream with value
com.im.examples.search.Person@6c4b8217
at
org.apache.camel.impl.converter.BaseTypeConverterRegistry.mandatoryConvertTo(BaseTypeConverterRegistry.java:182)
at
org.apache.camel.impl.MessageSupport.getMandatoryBody(MessageSupport.java:99)
... 41 more


I thought I had carefully followed the documentation :-(
Can anyone help spot what is wrong?

Thanks
Tim








POJO binding with the Rest DSL

2014-11-21 Thread Tim Dudgeon

I'm having problems getting POJO binding working with the Rest DSL.
I put together a simple example in Groovy, but it fails:



package com.im.examples.search

import org.apache.camel.CamelContext
import org.apache.camel.ProducerTemplate
import org.apache.camel.builder.RouteBuilder
import org.apache.camel.impl.DefaultCamelContext
import org.apache.camel.model.rest.RestBindingMode
import org.apache.camel.model.dataformat.JsonLibrary

String HOST = 'localhost'
String PORT = '43256'
String BASE_URL = "$HOST:$PORT/search"

class Person {
String firstName
String lastName
}

CamelContext camelContext = new DefaultCamelContext()
camelContext.addRoutes(new RouteBuilder() {
def void configure() {
restConfiguration().component("restlet").host(HOST).port(PORT).bindingMode(RestBindingMode.json)
rest("/search")
.post("/foo").type(Person.class).to("direct:end")
from('direct:end')
.log('${body}')
.transform().constant('Welcome')
from('direct:testmarshal')
.marshal().json(JsonLibrary.Jackson)
.log('JSON: ${body}')
}
})
camelContext.start()

Person p = new Person(firstName: 'John', lastName: 'Doe')
ProducerTemplate t = camelContext.createProducerTemplate()
t.sendBody('direct:testmarshal', p)
def resp = t.requestBody("http4:$BASE_URL/foo", p)
println "resp: $resp"

camelContext.stop()




The error I get is:


Caused by: org.apache.camel.InvalidPayloadException: No body available 
of type: java.io.InputStream but has value: 
com.im.examples.search.Person@6c4b8217 of type: 
com.im.examples.search.Person on: Message: 
com.im.examples.search.Person@6c4b8217. Caused by: No type converter 
available to convert from type: com.im.examples.search.Person to the 
required type: java.io.InputStream with value 
com.im.examples.search.Person@6c4b8217. Exchange[Message: 
com.im.examples.search.Person@6c4b8217]. Caused by: 
[org.apache.camel.NoTypeConversionAvailableException - No type converter 
available to convert from type: com.im.examples.search.Person to the 
required type: java.io.InputStream with value 
com.im.examples.search.Person@6c4b8217]
at 
org.apache.camel.impl.MessageSupport.getMandatoryBody(MessageSupport.java:101)
at 
org.apache.camel.component.http4.HttpProducer.createRequestEntity(HttpProducer.java:461)
at 
org.apache.camel.component.http4.HttpProducer.createMethod(HttpProducer.java:368)
at 
org.apache.camel.component.http4.HttpProducer.process(HttpProducer.java:106)
at 
org.apache.camel.util.AsyncProcessorConverterHelper$ProcessorToAsyncProcessorBridge.process(AsyncProcessorConverterHelper.java:61)
at 
org.apache.camel.processor.CamelInternalProcessor.process(CamelInternalProcessor.java:191)
at 
org.apache.camel.processor.UnitOfWorkProducer.process(UnitOfWorkProducer.java:74)
at 
org.apache.camel.impl.ProducerCache$2.doInProducer(ProducerCache.java:375)
at 
org.apache.camel.impl.ProducerCache$2.doInProducer(ProducerCache.java:343)

at org.apache.camel.impl.ProducerCache.doInProducer(ProducerCache.java:233)
at org.apache.camel.impl.ProducerCache.sendExchange(ProducerCache.java:343)
at org.apache.camel.impl.ProducerCache.send(ProducerCache.java:201)
at 
org.apache.camel.impl.DefaultProducerTemplate.send(DefaultProducerTemplate.java:128)
at 
org.apache.camel.impl.DefaultProducerTemplate.sendBody(DefaultProducerTemplate.java:132)

... 28 more
Caused by: org.apache.camel.NoTypeConversionAvailableException: No type 
converter available to convert from type: com.im.examples.search.Person 
to the required type: java.io.InputStream with value 
com.im.examples.search.Person@6c4b8217
at 
org.apache.camel.impl.converter.BaseTypeConverterRegistry.mandatoryConvertTo(BaseTypeConverterRegistry.java:182)
at 
org.apache.camel.impl.MessageSupport.getMandatoryBody(MessageSupport.java:99)

... 41 more


I thought I had carefully followed the documentation :-(
Can anyone help spot what is wrong?

Thanks
Tim



Re: Strange issue with JDBC add Postgres

2014-11-12 Thread Tim Dudgeon

I already did. Described here:
http://camel.465427.n5.nabble.com/Strange-issue-with-JDBC-add-Postgres-tp5758548p5758657.html


Tim

On 12/11/2014 19:26, Claus Ibsen wrote:

There is a resetAutoCommit option, you can try set that to false

On Mon, Nov 10, 2014 at 1:54 PM, Tim Dudgeon  wrote:

I dug a bit deeper here and I think that Camel is doing something with the
connection, possibly related to autoCommit.
I worked around the problem by writing my own Processor that sets autoCommit
to false, sets maxRows on the statement and then iterates through the
ResultSet and a cursor does seem to be used as expected.
But trying to do the same with the Camel JDBC component fails for reasons
described earlier.

Tim

On 06/11/2014 18:57, Claus Ibsen wrote:

So maybe its your maxRows=1000 that is the problem, so when you are
trying to get rows > 1000 then it throws that exception.

What is your use case? You want to select * from a table, but only the
first 1000 rows?

On Wed, Nov 5, 2014 at 10:05 PM, Tim Dudgeon 
wrote:

On 05/11/2014 19:07, Claus Ibsen wrote:

maxRowSize ??? do you mean fetchSize?


Sorry, I mean maxRows (as in the example here:
http://camel.apache.org/jdbc.html).
So something like:


.to('jdbc:myDataSoruce?outputType=StreamList&statement.fetchSize=100&statement.maxRows=1000')



Also which version of Camel do you use?


2.14

Tim










Re: Strange issue with JDBC add Postgres

2014-11-10 Thread Tim Dudgeon
I dug a bit deeper here and I think that Camel is doing something with 
the connection, possibly related to autoCommit.
I worked around the problem by writing my own Processor that sets 
autoCommit to false, sets maxRows on the statement and then iterates 
through the ResultSet and a cursor does seem to be used as expected.
But trying to do the same with the Camel JDBC component fails for 
reasons described earlier.


Tim

On 06/11/2014 18:57, Claus Ibsen wrote:

So maybe its your maxRows=1000 that is the problem, so when you are
trying to get rows > 1000 then it throws that exception.

What is your use case? You want to select * from a table, but only the
first 1000 rows?

On Wed, Nov 5, 2014 at 10:05 PM, Tim Dudgeon  wrote:

On 05/11/2014 19:07, Claus Ibsen wrote:

maxRowSize ??? do you mean fetchSize?


Sorry, I mean maxRows (as in the example here:
http://camel.apache.org/jdbc.html).
So something like:

.to('jdbc:myDataSoruce?outputType=StreamList&statement.fetchSize=100&statement.maxRows=1000')



Also which version of Camel do you use?


2.14

Tim








Re: Strange issue with JDBC add Postgres

2014-11-07 Thread Tim Dudgeon

I tracked it down a bit. Its something to do with auto commit.
There's something about it here:
http://www.postgresql.org/message-id/083dbfcc-8eac-4a5f-bd61-3a82dfc45...@visualdistortion.org

In my case I tried using the resetAutoCommit=false property on the JDBC 
component, and thought it had worked, but it seems that what happened is 
that it now runs with autoCommit=true which means the maxRows property 
is ignored and the whole ResultSet gets loaded and I then get OOM 
errors. So back to square 1 :-(


Seems like Camel is doing something with autoCommit which Postgresql is 
not liking.


Tim


On 06/11/2014 18:57, Claus Ibsen wrote:

So maybe its your maxRows=1000 that is the problem, so when you are
trying to get rows > 1000 then it throws that exception.

What is your use case? You want to select * from a table, but only the
first 1000 rows?

On Wed, Nov 5, 2014 at 10:05 PM, Tim Dudgeon  wrote:

On 05/11/2014 19:07, Claus Ibsen wrote:

maxRowSize ??? do you mean fetchSize?


Sorry, I mean maxRows (as in the example here:
http://camel.apache.org/jdbc.html).
So something like:

.to('jdbc:myDataSoruce?outputType=StreamList&statement.fetchSize=100&statement.maxRows=1000')



Also which version of Camel do you use?


2.14

Tim








Re: Strange issue with JDBC add Postgres

2014-11-06 Thread Tim Dudgeon

On 06/11/2014 18:57, Claus Ibsen wrote:

So maybe its your maxRows=1000 that is the problem, so when you are
trying to get rows > 1000 then it throws that exception.

What is your use case? You want to select * from a table, but only the
first 1000 rows?
No, it happens without maxRows. I was just experimenting with maxRows to 
confirm that the statement.XXX bit was working.
My use case is to select all rows from a  very large table and process 
them one by one. e.g. something like this:


from('direct:databasequery')
.to('jdbc:myDataSource?outputType=StreamList&statement.fetchSize=100')
.split(body()).streaming()
.log('Processing row')


Without fetchSize Postgresql tries to load the whole table into memory 
so it blows up with OOM exception.

With fetchSize in plain Java it works fine.
With fetchSize plus Camel it seems to blow up with that wierd Postgresql 
exception.


Tim


Re: Strange issue with JDBC add Postgres

2014-11-05 Thread Tim Dudgeon

On 05/11/2014 19:07, Claus Ibsen wrote:

maxRowSize ??? do you mean fetchSize?


Sorry, I mean maxRows (as in the example here: 
http://camel.apache.org/jdbc.html).

So something like:

.to('jdbc:myDataSoruce?outputType=StreamList&statement.fetchSize=100&statement.maxRows=1000')




Also which version of Camel do you use?


2.14

Tim



Strange issue with JDBC add Postgres

2014-11-05 Thread Tim Dudgeon
I'm encountering a strange problem with using the JDBC component with 
Postgresql.
Postgresql by default fetches large result sets into memory. To avoid 
this you need to use

statement.setFetchSize()
to make it use a cursor.
This works fine in a simple Java example.  But when I try to use it in 
Camel I get a strange exception thrown from deep down in Postgresql.

My route looks a bit like this:

from('direct:databasequery')
.to('jdbc:myDataSoruce?outputType=StreamList&statement.fetchSize=100')
.split(body()).streaming()
.log('Processing row')

I then send it a body containing something like:
select * from a_very_large_table

When I combine it with maxRowSize=10 its fine.
When I combine it with maxRowSize=1000 it blows up, so it looks like it 
fails when it needs to go back for a second chunk of data.

The error from Postgresql is this:

Caused by: org.postgresql.util.PSQLException: ERROR: portal "C_2" does 
not exist
at 
org.postgresql.core.v3.QueryExecutorImpl.receiveErrorResponse(QueryExecutorImpl.java:2198)
at 
org.postgresql.core.v3.QueryExecutorImpl.processResults(QueryExecutorImpl.java:1927)
at 
org.postgresql.core.v3.QueryExecutorImpl.fetch(QueryExecutorImpl.java:2130)
at 
org.postgresql.jdbc2.AbstractJdbc2ResultSet.next(AbstractJdbc2ResultSet.java:1917)
at 
org.apache.camel.component.jdbc.ResultSetIterator.loadNext(ResultSetIterator.java:117)
at 
org.apache.camel.component.jdbc.ResultSetIterator.next(ResultSetIterator.java:83)



Anyone got any idea what's going on here?

Tim



Writing Jetty response to stream.

2014-10-06 Thread Tim Dudgeon
I can see how to set the jetty response as text - just set the body to the
text.
But what if there is a large amount of data?
Don't want to build it into an in-memory String. Want to write it to a
stream.
How can I do this? I need to get a handle on an OutputStream that I can
write to?

Thx
Tim



--
View this message in context: 
http://camel.465427.n5.nabble.com/Writing-Jetty-response-to-stream-tp5757366.html
Sent from the Camel - Users mailing list archive at Nabble.com.


Can't grok event driven consumer

2014-09-24 Thread Tim Dudgeon
I'm wanting to create a Component that acts as a simple from: endpoint, 
just like, for instance, direct: does.
I want to be able to send an Exchange to it, handle it in some way, and 
send the outcomes (plural) to the downstream processor.
Most of it makes sense, but I just can't work out how to receive the 
incoming Exchange using DefaultConsumer. I see stuff on polling, but not 
how to handle the simple case of just receiving an event and handling it.

DefaultConsumer [1] seems to give me nothing to override.

Something like:

from("mycoolcomponent:test?param=foo")
.log("processing ${body}");

// then later

ProducerTemplate t = camelContext.createProducerTemplate();
t.sendBody("mycoolcomponent:test", "Hello World!");




[1] http://camel.apache.org/maven/current/camel-core/apidocs/index.html



endpoint patterns for database

2014-09-16 Thread Tim Dudgeon

Hi all!

I'm needing to write a new Camel Component for accessing a database. 
I've looked at the various database related components and see that 
there is no consistent pattern among these. I was wondering if there 
were recommendations as to what works best.


So my component would need to be much like a standard SQL database (e.g. 
the SQL or JDBC components), but needs to go beyond plain SQL. But in 
effect all operations are insert, update, delete and query operations, 
really just like SQL, but just not being executed as SQL.


Logically query operations would map to a from: endpoint and insert, 
update and delete to a to: endpoint. But its clear that from: endpoints 
can't really carry a payload that would be the query (or its params), so 
it looks like its best to handle query using a to: endpoint as well. Or 
maybe to support both where simple fixed queries can be part of the 
from: url parameters?


It looks to me like the MongoDB is the most sophisticated component, 
allowing the "action" to be defined in the URL params, and gives a lot 
of flexibility. But is the best approach?


All thoughts and experiences welcome.

Tim


Re: Return Value from Python Script Not In Message Body

2014-07-05 Thread Tim Dudgeon
I created a JIRA issue for this:
https://issues.apache.org/jira/browse/CAMEL-7582

Tim



--
View this message in context: 
http://camel.465427.n5.nabble.com/Return-Value-from-Python-Script-Not-In-Message-Body-tp5724056p5753387.html
Sent from the Camel - Users mailing list archive at Nabble.com.


  1   2   >