Re: getting exception for appending option providers=#cors-filter in camel cxfrs

2015-08-27 Thread Sergey Beryozkin

Hi

There's no need to set this provider from the uri given that it is 
already registered on the rsServer bean.
However, it may be useful for simpler URI-only configurations, I'll have 
a look...


Sergey
On 27/08/15 10:26, chaituu wrote:

getting below error when i used camel 2.15.2 version .Is it required to
append cors-filter in the from endpoint from
uri=cxfrs://bean://dsServer?providers=#cors-filter/ as I have already
referenced cors-filter in cxf:providers tag in the CxfRs endpoint.

when i removed providers=#cors-filter option in cxfrs://bean://dsServer then
its working fine.


Caused by: java.lang.IllegalArgumentException: Could not find a suitable
setter for property: providers as there isn't a setter method with same
type: java.lang.String nor type conversion possible: No type converter
available to convert from type: java.lang.String to the required type:
java.util.List with value #cors-filter

  cxf:rsServer id=dsServer address=http://0.0.0.0:10089/test;
   serviceClass=com.xxx.xxx.xx.testservice
   loggingFeatureEnabled=true loggingSizeLimit=20
 cxf:providers
 ref bean=cors-filter/
 /cxf:providers
 /cxf:rsServer


camel:camelContext xmlns=http://camel.apache.org/schema/spring; 
id=
 trace=true
  route id=test
 from uri=cxfrs://bean://dsServer?providers=#cors-filter/
 setBody
 constantabcd/constant
 /setBody
 to uri=log:com.xxx?level=INFO/
 /route
 /camel:camelContext



--
View this message in context: 
http://camel.465427.n5.nabble.com/getting-exception-for-appending-option-providers-cors-filter-in-camel-cxfrs-tp5771009.html
Sent from the Camel - Users mailing list archive at Nabble.com.




--
Sergey Beryozkin

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


Re: getting exception for appending option providers=#cors-filter in camel cxfrs

2015-08-27 Thread chaituu
registered cors-filter bean id like this.

bean id=cors-filter
class=org.apache.cxf.rs.security.cors.CrossOriginResourceSharingFilter/


 cxf:rsServer id=dsServer address=http://0.0.0.0:10089/test;
  serviceClass=com.xxx.xxx.xx.testservice
  loggingFeatureEnabled=true loggingSizeLimit=20
cxf:providers
ref bean=cors-filter/
/cxf:providers
/cxf:rsServer



--
View this message in context: 
http://camel.465427.n5.nabble.com/java-lang-NumberFormatException-For-input-string-cors-filter-in-camel-cxfrs-2-15-version-tp5771009p5771019.html
Sent from the Camel - Users mailing list archive at Nabble.com.


Re: Is it safe to use ThreadLocalExchange to implement route scope for dependency injection?

2015-08-27 Thread Jan Zankowski
Just wanted to ping the thread in the hope someone will offer help.. I
think the answer may also be useful to people in other situations who
wonder how Camel works under the hood with regard to threads. Thanks!

On Mon, Aug 24, 2015 at 12:47 PM, Jan Zankowski jan.zankow...@gmail.com
wrote:

 Hi,

 My goal is to implement DB multitenancy in a Camel application using
 Hibernate and Spring. For this, I need to implement the following Hibernate
 interface, which gets called on each read/write to the DB.

 public interface CurrentTenantIdentifierResolver {
   public String resolveCurrentTenantIdentifier();
   [...]
 }

 Because the method doesn't take any parameters, it either needs to use (1)
 some static context knowing which tenant the current route execution
 belongs to, or (2) a dependency-injected manager holding such a context.

 (1) points me to using ThreadLocal holding the current Exchange as it
 travels down the route. The Exchange can have some custom field indicating
 the tenant.
 (2) requires using route scope - where each route execution gets its own
 instance of context manager injected into CurrentTenantIdentifierResolver.
 Implementing the route scope, however, seems to require the same as (1) -
 ThreadLocal referencing the Exchange.

 I found the following article ( Git repo) implementing route scope
 exactly in this way:
 https://blog.jyore.com/2015/01/spring-camel-route-bean-scoping/ It claims
 to take advantage of the fact that if a new thread starts processing the
 Exchange as it travels down the route, for example after a
 parallel-processing multicast, the new thread gets a copy of the original
 Exchange, and an ExchangeCreatedEvent is fired, allowing a listener to set
 the ThreadLocal on the new thread.

 I was able to get this to work, though clearing of the ThreadLocal on
 ExchangeCompletedEvent doesn't work as the author claims, because the event
 is fired on a different thread (I checked).

 Such issues make me wonder if it's safe to use such a solution.

 I have the following questions in particular:
 (a) Let's assume an Exchange E is travelling down a route with a segment
 ... - A - B - ... If A and B are executed by different threads, is it
 guaranteed that the new thread (or threads) executing B will each copy the
 exchange and fire ExchangeCreatedEvent before executing B?
 (b) Why is ExchangeCompletedEvent sent by a different thread than the one
 executing L, the last endpoint on the route? Can I use some other hook to
 clear the ThreadLocal on the thread executing L, after L is executed? Maybe
 a custom RoutePolicy, custom SynchronizationAdapter, or onCompletion()?
 (c) Can Asynchronous Routing Engine or AsyncProcessors cause any problems
 in this setup? (If the answer to (a) is yes, I'd assume they won't cause
 problems.)
 (d) Any other caveats?

 This thread is related:
 http://camel.465427.n5.nabble.com/Clearing-ThreadLocal-when-exchange-completes-td5729849.html

 Many thanks!
 Jan



Re: Is it safe to use ThreadLocalExchange to implement route scope for dependency injection?

2015-08-27 Thread Romain Manni-Bucau
this is what I used to implement an @ExchangeScoped but it has several
limitation, in particular when breaking the flow with .threads() or
.multicast(). All is explained on
http://camel.apache.org/threading-model.html .

Using a camel interceptor would surely allow to pass the context through
the exchange and therefor avoid this ThreadLocal but this needs few more
setup and is less magic.


Romain Manni-Bucau
@rmannibucau https://twitter.com/rmannibucau |  Blog
http://rmannibucau.wordpress.com | Github https://github.com/rmannibucau |
LinkedIn https://www.linkedin.com/in/rmannibucau | Tomitriber
http://www.tomitribe.com

2015-08-27 20:13 GMT+02:00 Jan Zankowski jan.zankow...@gmail.com:

 Just wanted to ping the thread in the hope someone will offer help.. I
 think the answer may also be useful to people in other situations who
 wonder how Camel works under the hood with regard to threads. Thanks!

 On Mon, Aug 24, 2015 at 12:47 PM, Jan Zankowski jan.zankow...@gmail.com
 wrote:

  Hi,
 
  My goal is to implement DB multitenancy in a Camel application using
  Hibernate and Spring. For this, I need to implement the following
 Hibernate
  interface, which gets called on each read/write to the DB.
 
  public interface CurrentTenantIdentifierResolver {
public String resolveCurrentTenantIdentifier();
[...]
  }
 
  Because the method doesn't take any parameters, it either needs to use
 (1)
  some static context knowing which tenant the current route execution
  belongs to, or (2) a dependency-injected manager holding such a context.
 
  (1) points me to using ThreadLocal holding the current Exchange as it
  travels down the route. The Exchange can have some custom field
 indicating
  the tenant.
  (2) requires using route scope - where each route execution gets its
 own
  instance of context manager injected into
 CurrentTenantIdentifierResolver.
  Implementing the route scope, however, seems to require the same as (1) -
  ThreadLocal referencing the Exchange.
 
  I found the following article ( Git repo) implementing route scope
  exactly in this way:
  https://blog.jyore.com/2015/01/spring-camel-route-bean-scoping/ It
 claims
  to take advantage of the fact that if a new thread starts processing the
  Exchange as it travels down the route, for example after a
  parallel-processing multicast, the new thread gets a copy of the original
  Exchange, and an ExchangeCreatedEvent is fired, allowing a listener to
 set
  the ThreadLocal on the new thread.
 
  I was able to get this to work, though clearing of the ThreadLocal on
  ExchangeCompletedEvent doesn't work as the author claims, because the
 event
  is fired on a different thread (I checked).
 
  Such issues make me wonder if it's safe to use such a solution.
 
  I have the following questions in particular:
  (a) Let's assume an Exchange E is travelling down a route with a segment
  ... - A - B - ... If A and B are executed by different threads, is it
  guaranteed that the new thread (or threads) executing B will each copy
 the
  exchange and fire ExchangeCreatedEvent before executing B?
  (b) Why is ExchangeCompletedEvent sent by a different thread than the one
  executing L, the last endpoint on the route? Can I use some other hook to
  clear the ThreadLocal on the thread executing L, after L is executed?
 Maybe
  a custom RoutePolicy, custom SynchronizationAdapter, or onCompletion()?
  (c) Can Asynchronous Routing Engine or AsyncProcessors cause any problems
  in this setup? (If the answer to (a) is yes, I'd assume they won't
 cause
  problems.)
  (d) Any other caveats?
 
  This thread is related:
 
 http://camel.465427.n5.nabble.com/Clearing-ThreadLocal-when-exchange-completes-td5729849.html
 
  Many thanks!
  Jan
 



Re: getting exception for appending option providers=#cors-filter in camel cxfrs

2015-08-27 Thread chaituu
defined like above in the config like but getting the error.do i need change
anything?its working in camel 2.9 version but not working in 2.15 version 
cxf version is 3.0.4.



--
View this message in context: 
http://camel.465427.n5.nabble.com/java-lang-NumberFormatException-For-input-string-cors-filter-in-camel-cxfrs-2-15-version-tp5771009p5771022.html
Sent from the Camel - Users mailing list archive at Nabble.com.


Camel Velocity pass ArrayList

2015-08-27 Thread Copernico
Hi!

I have a velocity template for send an email. In this template i send to our
clients a list of items (JPA Entities) as an arraylist (is a result of a
query which size may be diferent each time)

Dear ${headers.name}

You request ${headers.itemList.size} items

#foreach(${item} in ${headers.itemList})
 Item ${item.description} - ${item.price}  
#end

With Java DSL i put the headers

exchange.getIn().setHeader(name, client.getName());
exchange.getIn().setHeader(itemList, itemList());


But the testing email i receive, does not have the items list from the
arraylist (the foreach loop is not working) and camel is not replacing
${headers.itemList.size}

Dear George

The items

You request ${headers.itemList.size} items


Any Ideas? How i pass objects like a pojo, a jpa entity, an arraylist to the
velocity template and access to their properties?

Thanks, 







--
View this message in context: 
http://camel.465427.n5.nabble.com/Camel-Velocity-pass-ArrayList-tp5771027.html
Sent from the Camel - Users mailing list archive at Nabble.com.


Re: getting exception for appending option providers=#cors-filter in camel cxfrs

2015-08-27 Thread Sergey Beryozkin

Sorry, may be I got confused.
The whole issue is about referring to a cors-filter instance from the 
URI, right ?
You said if you remove it from the route URI then it is fine, and I also 
said you do not need if you have a cxfrs server bean where you do 
reference the same cors-filter anyway.


So, does it work for you if you remove it from the URI ?
I agree it has to work when it is linked from URI when a cxfrs server is 
not created from a bean, which is something I'll look into. If you said 
it did work then I guess there might be some regression...


Sergey



On 27/08/15 15:55, chaituu wrote:

defined like above in the config like but getting the error.do i need change
anything?its working in camel 2.9 version but not working in 2.15 version 
cxf version is 3.0.4.



--
View this message in context: 
http://camel.465427.n5.nabble.com/java-lang-NumberFormatException-For-input-string-cors-filter-in-camel-cxfrs-2-15-version-tp5771009p5771022.html
Sent from the Camel - Users mailing list archive at Nabble.com.





Re: getting exception for appending option providers=#cors-filter in camel cxfrs

2015-08-27 Thread Sergey Beryozkin
Yes this should be sufficient, however it is possible to enable a cxfrs 
server with a URI only without directly creating a bean, so in that case 
it can be handy to refer to specific instances...


Sergey
On 27/08/15 15:25, chaituu wrote:

registered cors-filter bean id like this.

bean id=cors-filter
class=org.apache.cxf.rs.security.cors.CrossOriginResourceSharingFilter/


  cxf:rsServer id=dsServer address=http://0.0.0.0:10089/test;
   serviceClass=com.xxx.xxx.xx.testservice
   loggingFeatureEnabled=true loggingSizeLimit=20
 cxf:providers
 ref bean=cors-filter/
 /cxf:providers
 /cxf:rsServer



--
View this message in context: 
http://camel.465427.n5.nabble.com/java-lang-NumberFormatException-For-input-string-cors-filter-in-camel-cxfrs-2-15-version-tp5771009p5771019.html
Sent from the Camel - Users mailing list archive at Nabble.com.




--
Sergey Beryozkin

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


Re: Loading XML Routes from local directory

2015-08-27 Thread fxthomas
hi, 

  Now sure of what exactly you want to do. As far as i understood , you want
to keep all your routes in a XML file or multiple XML file 8specific for
each route).  I think the only option is currently is to use the
loadRoutesDefinition which you have mentioned already.  I have used it it
works fine. And I am getting my route Definitions from a DB and streaming it
as XML to the method.  (Dont ask why .))



--
View this message in context: 
http://camel.465427.n5.nabble.com/Loading-XML-Routes-from-local-directory-tp5771018p5771024.html
Sent from the Camel - Users mailing list archive at Nabble.com.


JSON to XML Conversion

2015-08-27 Thread anish.somadevan
Am trying to convert a JSON message to XML format as given below,

 dataFormats
xmljson id=xmljson/
xmljson id=xmljsonWithOptions forceTopLevelObject=true
trimSpaces=true rootName=newRoot skipNamespaces=true
 removeNamespacePrefixes=true/

route id=parseJSON
from uri=direct:inter2 /
unmarshal ref=xmljsonWithOptions/

to uri=direct:inter3 /

Am using. Camel-XmlJSON 2.10.3 JAR. 
When i execute my route, i get the following error,

JmsConsumer[ISEEOutboundQueue]) CamelOutboundAdapter exception: Failed to
create route parseJSON at:  Unmarshal[ref:xmljsonWithOptions]  in
route: Route[[From[direct:inter2]] - [Unmarshal[ref:xmljsonWithOpt...
because of Cannot find data format in registry with ref: xmljsonWithOptions

Can anyone please let me know how to resolve this?

Thanks,
Anish



--
View this message in context: 
http://camel.465427.n5.nabble.com/JSON-to-XML-Conversion-tp5771031.html
Sent from the Camel - Users mailing list archive at Nabble.com.


Re: Is it safe to use ThreadLocalExchange to implement route scope for dependency injection?

2015-08-27 Thread Jan Zankowski
Right - I just found your code. The limitation you mention - async
processors, threads(), multicast() - is exactly what the approach I
describe is meant to overcome.

When a situation like that happens, i.e. a new thread takes over, it gets a
copy of the original exchange, and an ExchangeCreateEvent is fired in it,
allowing a listener to set the copy of exchange on the new thread's
ThreadLocal. This should provide continuity of route scope.

This is what the author of the code I point to claims, and it seems to
work. My main question is: is this guaranteed to work? I.e., if adjacent
components A and B on the same route are executed by different threads, can
I always be sure that the new thread (or threads) executing B will each
copy the exchange and fire ExchangeCreatedEvent before executing B?

On Thu, Aug 27, 2015 at 8:19 PM, Romain Manni-Bucau rmannibu...@gmail.com
wrote:

 this is what I used to implement an @ExchangeScoped but it has several
 limitation, in particular when breaking the flow with .threads() or
 .multicast(). All is explained on
 http://camel.apache.org/threading-model.html .

 Using a camel interceptor would surely allow to pass the context through
 the exchange and therefor avoid this ThreadLocal but this needs few more
 setup and is less magic.


 Romain Manni-Bucau
 @rmannibucau https://twitter.com/rmannibucau |  Blog
 http://rmannibucau.wordpress.com | Github 
 https://github.com/rmannibucau |
 LinkedIn https://www.linkedin.com/in/rmannibucau | Tomitriber
 http://www.tomitribe.com

 2015-08-27 20:13 GMT+02:00 Jan Zankowski jan.zankow...@gmail.com:

  Just wanted to ping the thread in the hope someone will offer help.. I
  think the answer may also be useful to people in other situations who
  wonder how Camel works under the hood with regard to threads. Thanks!
 
  On Mon, Aug 24, 2015 at 12:47 PM, Jan Zankowski jan.zankow...@gmail.com
 
  wrote:
 
   Hi,
  
   My goal is to implement DB multitenancy in a Camel application using
   Hibernate and Spring. For this, I need to implement the following
  Hibernate
   interface, which gets called on each read/write to the DB.
  
   public interface CurrentTenantIdentifierResolver {
 public String resolveCurrentTenantIdentifier();
 [...]
   }
  
   Because the method doesn't take any parameters, it either needs to use
  (1)
   some static context knowing which tenant the current route execution
   belongs to, or (2) a dependency-injected manager holding such a
 context.
  
   (1) points me to using ThreadLocal holding the current Exchange as it
   travels down the route. The Exchange can have some custom field
  indicating
   the tenant.
   (2) requires using route scope - where each route execution gets its
  own
   instance of context manager injected into
  CurrentTenantIdentifierResolver.
   Implementing the route scope, however, seems to require the same as
 (1) -
   ThreadLocal referencing the Exchange.
  
   I found the following article ( Git repo) implementing route scope
   exactly in this way:
   https://blog.jyore.com/2015/01/spring-camel-route-bean-scoping/ It
  claims
   to take advantage of the fact that if a new thread starts processing
 the
   Exchange as it travels down the route, for example after a
   parallel-processing multicast, the new thread gets a copy of the
 original
   Exchange, and an ExchangeCreatedEvent is fired, allowing a listener to
  set
   the ThreadLocal on the new thread.
  
   I was able to get this to work, though clearing of the ThreadLocal on
   ExchangeCompletedEvent doesn't work as the author claims, because the
  event
   is fired on a different thread (I checked).
  
   Such issues make me wonder if it's safe to use such a solution.
  
   I have the following questions in particular:
   (a) Let's assume an Exchange E is travelling down a route with a
 segment
   ... - A - B - ... If A and B are executed by different threads, is
 it
   guaranteed that the new thread (or threads) executing B will each copy
  the
   exchange and fire ExchangeCreatedEvent before executing B?
   (b) Why is ExchangeCompletedEvent sent by a different thread than the
 one
   executing L, the last endpoint on the route? Can I use some other hook
 to
   clear the ThreadLocal on the thread executing L, after L is executed?
  Maybe
   a custom RoutePolicy, custom SynchronizationAdapter, or onCompletion()?
   (c) Can Asynchronous Routing Engine or AsyncProcessors cause any
 problems
   in this setup? (If the answer to (a) is yes, I'd assume they won't
  cause
   problems.)
   (d) Any other caveats?
  
   This thread is related:
  
 
 http://camel.465427.n5.nabble.com/Clearing-ThreadLocal-when-exchange-completes-td5729849.html
  
   Many thanks!
   Jan
  
 



JSON to XML Conversion

2015-08-27 Thread anish.somadevan
Am trying to convert a JSON message to XML format as given below,

 dataFormats
xmljson id=xmljson/
xmljson id=xmljsonWithOptions forceTopLevelObject=true
trimSpaces=true rootName=newRoot skipNamespaces=true
 removeNamespacePrefixes=true/

route id=parseJSON
from uri=direct:inter2 /
unmarshal ref=xmljsonWithOptions/

to uri=direct:inter3 /

Am using. Camel-XmlJSON 2.10.3 JAR. 
When i execute my route, i get the following error,

JmsConsumer[ISEEOutboundQueue]) CamelOutboundAdapter exception: Failed to
create route parseJSON at:  Unmarshal[ref:xmljsonWithOptions]  in
route: Route[[From[direct:inter2]] - [Unmarshal[ref:xmljsonWithOpt...
because of Cannot find data format in registry with ref: xmljsonWithOptions

Can anyone please let me know how to resolve this?

Thanks,
Anish



--
View this message in context: 
http://camel.465427.n5.nabble.com/JSON-to-XML-Conversion-tp5771032.html
Sent from the Camel - Users mailing list archive at Nabble.com.


Re: http4 ignoring CamelHttpPath

2015-08-27 Thread Raul Kripalani
I don't think it's expected behaviour. Normally I configure timeouts and
the like in the AsyncHttpClientConfig directly. Doing that, the
CamelHttpPath header works properly.

I will check what you said, but it definitely sounds like a bug.

Raúl.
On 27 Aug 2015 04:17, Minh Tran darth.minhs...@gmail.com wrote:

 Hi

 I've come across a strange behaviour with the http4 component on 2.15.2.
 If I have the following in my route

 setHeader headerName=CamelHttpPath
 constant/my/path/constant
 /setHeader
 to uri=http4:myhost:80/

 then it works just fine hitting http://myhost:80/my/path


 However I now have a need to set the connect and read timeouts on this so
 I've done the following

 setHeader headerName=CamelHttpPath
 constant/my/path/constant
 /setHeader
 to
 uri=http4:myhost:80?httpclient.connectTimeout=1amp;httpclient.socketTimeout=12/


 Now it ignores the CamelHttpPath header and hits http://myhost:80. I can
 verify this by enabling logging in httpclient.

 If I then change it to the following where I add the path directly to the
 uri and skip the setHeader element

 to
 uri=http4:myhost:80/my/path?httpclient.connectTimeout=1amp;httpclient.socketTimeout=12
 /

 It hits the correct link. So it looks like the CamelHttpPath gets ignored
 if I add any options to the http4 uri. Is this expected behaviour?

 Thanks
 Minh


Re: Is it safe to use ThreadLocalExchange to implement route scope for dependency injection?

2015-08-27 Thread Raul Kripalani
Typically what you would do is store the object you want to propagate in an
Exchange property, eg. just before a threads() DSL.

On the other side of the concurrency threshold, you would unwrap the object
back into its thread-bound structure from the Exchange property.

If you have a look at the feature/camel-hystrix branch, I'm implementing
something similar to propagate the HystrixRequestContext, which is
otherwise thread-bound.

Raúl.
On 27 Aug 2015 21:16, Jan Zankowski jan.zankow...@gmail.com wrote:

 Right - I just found your code. The limitation you mention - async
 processors, threads(), multicast() - is exactly what the approach I
 describe is meant to overcome.

 When a situation like that happens, i.e. a new thread takes over, it gets a
 copy of the original exchange, and an ExchangeCreateEvent is fired in it,
 allowing a listener to set the copy of exchange on the new thread's
 ThreadLocal. This should provide continuity of route scope.

 This is what the author of the code I point to claims, and it seems to
 work. My main question is: is this guaranteed to work? I.e., if adjacent
 components A and B on the same route are executed by different threads, can
 I always be sure that the new thread (or threads) executing B will each
 copy the exchange and fire ExchangeCreatedEvent before executing B?

 On Thu, Aug 27, 2015 at 8:19 PM, Romain Manni-Bucau rmannibu...@gmail.com
 
 wrote:

  this is what I used to implement an @ExchangeScoped but it has several
  limitation, in particular when breaking the flow with .threads() or
  .multicast(). All is explained on
  http://camel.apache.org/threading-model.html .
 
  Using a camel interceptor would surely allow to pass the context through
  the exchange and therefor avoid this ThreadLocal but this needs few more
  setup and is less magic.
 
 
  Romain Manni-Bucau
  @rmannibucau https://twitter.com/rmannibucau |  Blog
  http://rmannibucau.wordpress.com | Github 
  https://github.com/rmannibucau |
  LinkedIn https://www.linkedin.com/in/rmannibucau | Tomitriber
  http://www.tomitribe.com
 
  2015-08-27 20:13 GMT+02:00 Jan Zankowski jan.zankow...@gmail.com:
 
   Just wanted to ping the thread in the hope someone will offer help.. I
   think the answer may also be useful to people in other situations who
   wonder how Camel works under the hood with regard to threads. Thanks!
  
   On Mon, Aug 24, 2015 at 12:47 PM, Jan Zankowski 
 jan.zankow...@gmail.com
  
   wrote:
  
Hi,
   
My goal is to implement DB multitenancy in a Camel application using
Hibernate and Spring. For this, I need to implement the following
   Hibernate
interface, which gets called on each read/write to the DB.
   
public interface CurrentTenantIdentifierResolver {
  public String resolveCurrentTenantIdentifier();
  [...]
}
   
Because the method doesn't take any parameters, it either needs to
 use
   (1)
some static context knowing which tenant the current route execution
belongs to, or (2) a dependency-injected manager holding such a
  context.
   
(1) points me to using ThreadLocal holding the current Exchange as it
travels down the route. The Exchange can have some custom field
   indicating
the tenant.
(2) requires using route scope - where each route execution gets
 its
   own
instance of context manager injected into
   CurrentTenantIdentifierResolver.
Implementing the route scope, however, seems to require the same as
  (1) -
ThreadLocal referencing the Exchange.
   
I found the following article ( Git repo) implementing route scope
exactly in this way:
https://blog.jyore.com/2015/01/spring-camel-route-bean-scoping/ It
   claims
to take advantage of the fact that if a new thread starts processing
  the
Exchange as it travels down the route, for example after a
parallel-processing multicast, the new thread gets a copy of the
  original
Exchange, and an ExchangeCreatedEvent is fired, allowing a listener
 to
   set
the ThreadLocal on the new thread.
   
I was able to get this to work, though clearing of the ThreadLocal on
ExchangeCompletedEvent doesn't work as the author claims, because the
   event
is fired on a different thread (I checked).
   
Such issues make me wonder if it's safe to use such a solution.
   
I have the following questions in particular:
(a) Let's assume an Exchange E is travelling down a route with a
  segment
... - A - B - ... If A and B are executed by different threads, is
  it
guaranteed that the new thread (or threads) executing B will each
 copy
   the
exchange and fire ExchangeCreatedEvent before executing B?
(b) Why is ExchangeCompletedEvent sent by a different thread than the
  one
executing L, the last endpoint on the route? Can I use some other
 hook
  to
clear the ThreadLocal on the thread executing L, after L is executed?
   Maybe
a custom RoutePolicy, custom SynchronizationAdapter, or
 

Re: Camel Velocity pass ArrayList

2015-08-27 Thread Raul Kripalani
Could you please paste the itemList() function?

Thanks.
On 27 Aug 2015 18:17, Copernico engcopern...@gmail.com wrote:

 Hi!

 I have a velocity template for send an email. In this template i send to
 our
 clients a list of items (JPA Entities) as an arraylist (is a result of a
 query which size may be diferent each time)

 Dear ${headers.name}

 You request ${headers.itemList.size} items

 #foreach(${item} in ${headers.itemList})
  Item ${item.description} - ${item.price}
 #end

 With Java DSL i put the headers

 exchange.getIn().setHeader(name, client.getName());
 exchange.getIn().setHeader(itemList, itemList());


 But the testing email i receive, does not have the items list from the
 arraylist (the foreach loop is not working) and camel is not replacing
 ${headers.itemList.size}

 Dear George

 The items

 You request ${headers.itemList.size} items


 Any Ideas? How i pass objects like a pojo, a jpa entity, an arraylist to
 the
 velocity template and access to their properties?

 Thanks,







 --
 View this message in context:
 http://camel.465427.n5.nabble.com/Camel-Velocity-pass-ArrayList-tp5771027.html
 Sent from the Camel - Users mailing list archive at Nabble.com.



Re: http4 ignoring CamelHttpPath

2015-08-27 Thread Raul Kripalani
On Thu, Aug 27, 2015 at 4:16 AM, Minh Tran darth.minhs...@gmail.com wrote:

 to
 uri=http4:myhost:80?httpclient.connectTimeout=1amp;httpclient.socketTimeout=12/


You have a typo related to casing. The option prefixes are httpClient
(capital C, using lowerCamelCase).

Nevertheless, we do have a bug because your options are being interpreted
as query parameters, so Camel should really be invoking this URL:

http://myhost:80/my/path?httpclient.connectTimeout=1httpclient.socketTimeout=12

But is instead using this URL:

http://myhost:80?httpclient.connectTimeout=1httpclient.socketTimeout=12/my/path

(path and query parameters are concatenated in the wrong order).

Working on that: CAMEL-9104

Regards,

*Raúl Kripalani*
Apache Camel PMC Member  Committer | Enterprise Architect, Open Source
Integration specialist
http://about.me/raulkripalani | http://www.linkedin.com/in/raulkripalani
http://blog.raulkr.net | twitter: @raulvk


Re: http4 ignoring CamelHttpPath

2015-08-27 Thread Minh Tran
Oh I didn't notice the incorrect case. Thanks for looking into this, much 
appreciated!

On 28/08/2015, at 7:53 AM, Raul Kripalani r...@evosent.com wrote:

 On Thu, Aug 27, 2015 at 4:16 AM, Minh Tran darth.minhs...@gmail.com wrote:
 
 to
 uri=http4:myhost:80?httpclient.connectTimeout=1amp;httpclient.socketTimeout=12/
 
 
 You have a typo related to casing. The option prefixes are httpClient
 (capital C, using lowerCamelCase).
 
 Nevertheless, we do have a bug because your options are being interpreted
 as query parameters, so Camel should really be invoking this URL:
 
 http://myhost:80/my/path?httpclient.connectTimeout=1httpclient.socketTimeout=12
 
 But is instead using this URL:
 
 http://myhost:80?httpclient.connectTimeout=1httpclient.socketTimeout=12/my/path
 
 (path and query parameters are concatenated in the wrong order).
 
 Working on that: CAMEL-9104
 
 Regards,
 
 *Raúl Kripalani*
 Apache Camel PMC Member  Committer | Enterprise Architect, Open Source
 Integration specialist
 http://about.me/raulkripalani | http://www.linkedin.com/in/raulkripalani
 http://blog.raulkr.net | twitter: @raulvk



Re: CXF SOAP Message Sent from a Camel Client Twice When No HTTP Response Received

2015-08-27 Thread Raul Kripalani
Are you sure the first request was not an HTTP request that ended with an
401 Unauthorized?

Are you using some kind of HTTP auth? If that's the case and you don't set
up preemptive auth (for HTTP Basic), it is expected for the server to see 2
wire requests.

Could you please try enabling the CXF Logging interceptors, or the Logging
feature? (same thing)

Also, it would help to see your code and configuration.

Thanks!
On 27 Aug 2015 12:11, segev soa@gmail.com wrote:

 We came across the following issue when using the Camel CXF component to
 invoke a SOAP request with Payload mode over HTTPS on a third party
 service.

 The third party server provides two endpoints primary and secondary.

 As part of certifying our system with this service (fail over test), we
 were
 required to invoke a test request on the primary (which failed with No HTTP
 Response error).
 The Camel client sent one message (as observed on our Camel Trace log) but
 the server received two requests.
 We used soapUI client to invoke the same test server just to confirm that
 the server register one request only.

 Note that the 'Redelivery Policies' were configured with
 'maximumRedeliveries' of 0.

 We ended up replacing the cxf://.. endpoint with a 'processor' with
 Apache
 HTTPClient and this solve the duplicate message being sent.

 We couldn't find any obvious setting on the cxf configuration or the HTTP
 Conduit to prevent this from happening.
 Any suggestions on what may cause a 'NoHttpResponse' error to trigger
 sending a second message will be appreciated.



 --
 View this message in context:
 http://camel.465427.n5.nabble.com/CXF-SOAP-Message-Sent-from-a-Camel-Client-Twice-When-No-HTTP-Response-Received-tp5771010.html
 Sent from the Camel - Users mailing list archive at Nabble.com.



Re: getting exception for appending option providers=#cors-filter in camel cxfrs

2015-08-27 Thread chaituu
even if i remove it from the route URI also its not working.can you check
from your side once.as per doc

http://camel.apache.org/cxfrs.html

providers Since Camel 2.12.2 set custom JAX-RS providers list to the CxfRs
endpoint.
providers=#MyProviders

initially i didn't checked the logs properly so thought its working even if
i removed from the route URI.





--
View this message in context: 
http://camel.465427.n5.nabble.com/java-lang-NumberFormatException-For-input-string-cors-filter-in-camel-cxfrs-2-15-version-tp5771009p5771046.html
Sent from the Camel - Users mailing list archive at Nabble.com.


CXF SOAP Message Sent from a Camel Client Twice When No HTTP Response Received

2015-08-27 Thread segev
We came across the following issue when using the Camel CXF component to
invoke a SOAP request with Payload mode over HTTPS on a third party service.

The third party server provides two endpoints primary and secondary.

As part of certifying our system with this service (fail over test), we were
required to invoke a test request on the primary (which failed with No HTTP
Response error). 
The Camel client sent one message (as observed on our Camel Trace log) but
the server received two requests.
We used soapUI client to invoke the same test server just to confirm that
the server register one request only.

Note that the 'Redelivery Policies' were configured with
'maximumRedeliveries' of 0.

We ended up replacing the cxf://.. endpoint with a 'processor' with Apache
HTTPClient and this solve the duplicate message being sent.

We couldn't find any obvious setting on the cxf configuration or the HTTP
Conduit to prevent this from happening. 
Any suggestions on what may cause a 'NoHttpResponse' error to trigger
sending a second message will be appreciated.



--
View this message in context: 
http://camel.465427.n5.nabble.com/CXF-SOAP-Message-Sent-from-a-Camel-Client-Twice-When-No-HTTP-Response-Received-tp5771010.html
Sent from the Camel - Users mailing list archive at Nabble.com.


getting exception for appending option providers=#cors-filter in camel cxfrs

2015-08-27 Thread chaituu
getting below error when i used camel 2.15.2 version .Is it required to
append cors-filter in the from endpoint from
uri=cxfrs://bean://dsServer?providers=#cors-filter/ as I have already
referenced cors-filter in cxf:providers tag in the CxfRs endpoint.

when i removed providers=#cors-filter option in cxfrs://bean://dsServer then
its working fine.


Caused by: java.lang.IllegalArgumentException: Could not find a suitable
setter for property: providers as there isn't a setter method with same
type: java.lang.String nor type conversion possible: No type converter
available to convert from type: java.lang.String to the required type:
java.util.List with value #cors-filter

 cxf:rsServer id=dsServer address=http://0.0.0.0:10089/test;
  serviceClass=com.xxx.xxx.xx.testservice
  loggingFeatureEnabled=true loggingSizeLimit=20
cxf:providers
ref bean=cors-filter/
/cxf:providers
/cxf:rsServer


camel:camelContext xmlns=http://camel.apache.org/schema/spring; 
id=
trace=true
 route id=test
from uri=cxfrs://bean://dsServer?providers=#cors-filter/
setBody
constantabcd/constant
/setBody
to uri=log:com.xxx?level=INFO/
/route
/camel:camelContext



--
View this message in context: 
http://camel.465427.n5.nabble.com/getting-exception-for-appending-option-providers-cors-filter-in-camel-cxfrs-tp5771009.html
Sent from the Camel - Users mailing list archive at Nabble.com.


Re: Camel CXF Transport works within Blueprint only when XSD validation is disabled

2015-08-27 Thread metatech
Hello Aki,

Thanks for your reply.
I understand from your explanation that this limitation might stay for some
time.

To avoid disabling Blueprint XSD validation entirely, I patched the
Blueprint core XSD to allow id attributes starting with *..  This is of
course not an elegant solution, but it is less ugly to relax validation for
a single attribute than for the entire XML.

Regards,

metatech

---
blueprint-core/src/main/resources/org/apache/aries/blueprint/blueprint.xsd  
 
2015-08-27 10:38:55.329361900 +0200
+++
blueprint-core/src/main/resources/org/apache/aries/blueprint/blueprint.xsd
2015-08-27 10:43:14.818203800 +0200
@@ -41,6 +41,13 @@



+   xsd:simpleType name=IDwithWildcard id=IDwithWildcard
+   xsd:restriction base=xsd:string
+   xsd:pattern value=([*][.])?[\i-[:]][\c-[:]]*
id=IDwithWildcard.pattern
+   /xsd:pattern
+   /xsd:restriction
+   /xsd:simpleType
+
xsd:complexType name=Tcomponent abstract=true
xsd:annotation
xsd:documentation
@@ -56,7 +63,7 @@
/xsd:documentation
/xsd:annotation

-   xsd:attribute name=id type=xsd:ID /
+   xsd:attribute name=id type=IDwithWildcard /

xsd:attribute name=activation type=Tactivation
xsd:annotation




Aki Yoshida-3 wrote
 I think I suggested
 adding another option of only disabling the primitive-type check some
 years ago at the aries mailing list.
 
 http://mail-archives.apache.org/mod_mbox/aries-user/201212.mbox/%

 3CCAF8t5Xud7Q+jYHUcX-pm6YN5z9hMOPsXgbmKyAxUirXRUznjWg@.gmail

 %3E
 
 but I think there is no such option and I also didn't pursue this issue.





--
View this message in context: 
http://camel.465427.n5.nabble.com/Camel-CXF-Transport-works-within-Blueprint-only-when-XSD-validation-is-disabled-tp5770593p5771007.html
Sent from the Camel - Users mailing list archive at Nabble.com.


RE: Idempotent consumer query

2015-08-27 Thread Hans Orbaan
Hi,

You might want to consider implementing your own IdempotentRepository. You can 
increment a counter when add or confirm is called.
Then the contains method should only return true when you have reached 5.

With kind regards,

Hans Orbaan

-Oorspronkelijk bericht-
Van: gilboy [mailto:josephoto...@gmail.com] 
Verzonden: Thursday 27 August 2015 9:26
Aan: users@camel.apache.org
Onderwerp: Idempotent consumer query

Hi

I have a use case were I want to process the same message on my route up to a 
maximum of 5 times. I understand the idempotent consumer can be used to ensure 
we don't process the same messages twice. Just wondering if there exists 
already something similar to the idempotent consumer were you can specify the 
max number of times you want to attempt to process the same message on a route

Thanks
Joe 



--
View this message in context: 
http://camel.465427.n5.nabble.com/Idempotent-consumer-query-tp5771004.html
Sent from the Camel - Users mailing list archive at Nabble.com.


Idempotent consumer query

2015-08-27 Thread gilboy
Hi

I have a use case were I want to process the same message on my route up to
a maximum of 5 times. I understand the idempotent consumer can be used to
ensure we don't process the same messages twice. Just wondering if there
exists already something similar to the idempotent consumer were you can
specify the max number of times you want to attempt to process the same
message on a route

Thanks
Joe 



--
View this message in context: 
http://camel.465427.n5.nabble.com/Idempotent-consumer-query-tp5771004.html
Sent from the Camel - Users mailing list archive at Nabble.com.