Jetty banner & stacktrace while using cxf component: camel 3.0.1

2020-03-25 Thread Vikas Jaiswal
Hi
   I have a issue with the Jetty banner that comes up while a 404 error 
occurs. This is what I did to fix it:

1)  Extended org.eclipse.jetty.server.handler.ContextHandler to create a 
custom contexhandler.

2)  This custom context handler is configured in camel-config.xml (I am 
using spring dsl).

3)  This custom context handler calls a custom error handler in which the 
Jetty banner is removed.

I am using cxfEndpoint and have a uri configured in address property of the 
cxfEndpoint. I assume that if there is any http error i.e '404' it should be 
handled by the custom error handler that  I have configured, but in turn it 
displays the default error handler and the banner.

Regards,
Vikas


RE: KafkaComponent: Authentication failed

2020-03-25 Thread Klug Andreas (CI/OSI3)
Hi Pasquale,

Thanks for the quick answer - you spotted that well, but the port answers with 
0x15 0x03 0x03 0x00 0x02 0x02 0x50 - TLSv1.2. Seems to be a specialty in the 
Confluent Cloud offering. They're generating the configuration automatically 
anyhow, thus I assume the port is correct.

I would have been very surprised, too, as everything works fine with providing 
the Jaas configuration via "-Djava.security.auth.login.config". Do you think 
there might be an issue with passing the sasl.jaas.config via URI to the Kafka 
component? 

Unfortunately the approach by using the Java system property has a lot of 
disadvantages, e. g. just able to address one Kafka cluster, not able to use 
the Spring Azure Key Vault integration, ...

Cheers,
Andreas

-Original Message-
From: Pasquale Congiusti  
Sent: Dienstag, 24. März 2020 16:30
To: users@camel.apache.org
Subject: Re: KafkaComponent: Authentication failed

Hey Andreas,
Could it be possible you're trying to use TLS over a PLAINTEXT broker?

I can see your broker is running PLAINTEXT default port (9092), while typically 
the SSL is run over 9093.



Cheers,
Pasquale.



On Tue, Mar 24, 2020 at 11:23 AM Klug Andreas (CI/OSI3) 
 wrote:

> Hello everybody,
>
> I'm facing an issue with Camel 2.25.0 and Spring Boot 2.2.5 (as well 
> with Camel 2.22.1 with Spring Boot 2.0.7) running on OpenJDK 8u242 
> within Docker (Azure container instances).
>
> Utilizing the Kafka component I'm producing messages with the 
> following statement
>
> .recipientList(simple(route.getDestination()+"${header.KafkaTopic}?"+r
> oute.getDestinationOptions())) where route.getDestination() names a 
> bean defined as
>  class="org.apache.camel.component.kafka.KafkaComponent" primary="true">
>  value="somehost.azure.confluent.cloud:9092"/>
> 
> and route.getDestinationOptions() resolves from a YAML file to
>
> "saslMechanism=PLAIN=TLSv1.2=SASL_SSL
> EndpointAlgorithm=https=TLSv1.2=org
> .apache.kafka.common.security.plain.PlainLoginModule
> required username=\"username\" password=\"password\";"
>
> Even though the initial login seems to work ("JmsConsumer[testqueue] 
> [0;39m org.apache.kafka.common.security.authenticator.AbstractLogin - 
> Successfully logged in") sending the first message results in
> 2020-03-24 10:54:40,994 [1;31mERROR  [0;39m [35mer-network-thread |
> producer-1 [0;39m org.apache.kafka.clients.NetworkClient - [Producer 
> clientId=producer-1] Connection to node -1 
> (somehost.azure.confluent.cloud/
> 255.255.255.255:9092) failed authentication due to: Authentication
> failed: Invalid username or password
>
> The producer logs that it got the Jaas config:
> org.apache.kafka.clients.producer.ProducerConfig - ProducerConfig values:
>  ...
>  sasl.jaas.config = [hidden]
>
> The strange thing now is that if I remove the sasljaasConfig from the 
> URI and copy it to a Jaas config file, wrapped with "KafkaClient { ... 
> }", referenced via "-Djava.security.auth.login.config=...", everything 
> works fine.
>
> Apparently, user2966021 seems to have at least a very similar issue 
> according to a comment on StackOverflow:
>
> https://stackoverflow.com/questions/50090226/how-to-implement-camel-ka
> fka-producer-and-consumer-which-is-using-kafka-brokers
>
> The password contains characters + and /, but as I'm using double 
> quoted YAML strings, I don't expect this to be an issue.
>
> Anybody having any hints for me?
>
> Thanks in advance!
>
> Best Regards
> Andreas
>
>
> Robert Bosch GmbH | Postfach 30 02 20 | 70442 Stuttgart | GERMANY | 
> www.bosch.com
>
> Registered Office: Stuttgart, Registration Court: Amtsgericht 
> Stuttgart, HRB 14000; Chairman of the Supervisory Board: Franz 
> Fehrenbach; Managing Directors:
> Dr. Volkmar Denner,
> Prof. Dr. Stefan Asenkerschbaumer, Dr. Michael Bolle, Dr. Christian 
> Fischer, Dr. Stefan Hartung, Dr. Markus Heyn, Harald Kröger, Christoph 
> Kübel, Rolf Najork, Uwe Raschke, Peter Tyroller
>
>


Re: Testing Route in camel-quarkus

2020-03-25 Thread Dennis Holunder
thanks, works fine except logging:

quarkus.log.file.enable = true
quarkus.log.file.path = log/myquarkus.log
quarkus.log.console.enable = true

When running tests from IDE there is no console log and empty
target/quarkus.log file is created instead of log/myquarkus.log as in
defined in config.
When running tests from command line there is console log and
target/quarkus.log file is populated with logs.
When running the application, the config from
src/main/resources/application.properties is picked up, but stored in
target/log/ directory.

In summary, log configuration in
src/test/resources/application.properties is ignored and working dir
is apparently target

Am Mi., 25. März 2020 um 09:19 Uhr schrieb Alex Dettinger [via Camel]
:
>
> Hi Dennis,
>
>   Interesting idea, this may work in jvm mode and would need to be excluded
> when executing @NativeImageTest.
> You may also be able to inject a ProducerTemplate in the test to feed the
> route directly.
>
> Alex
>
> On Wed, Mar 25, 2020 at 7:55 AM Dennis Holunder <[hidden email]>
> wrote:
>
> > I could create a quarkus test where the route is injected and external
> > endpoint is mocked with quarkus mock support.
> >
> > Am Fr., 20. März 2020 um 11:52 Uhr schrieb Dennis Holunder
> > <[hidden email]>:
> > >
> > > Hello,
> > >
> > > is it possible to test a non-http route in camel-quarkus like we do
> > > with CamelTestSupport in camel?
> > >
> > > Thanks!
> >
>
>
> 
> If you reply to this email, your message will be added to the discussion 
> below:
> https://camel.465427.n5.nabble.com/Testing-Route-in-camel-quarkus-tp5860291p5861032.html
> To unsubscribe from Camel, click here.
> NAML


Re: Aggregation mystery - ClassCastException on same class

2020-03-25 Thread Mikael Andersson Wigander
Hi, all

I think I found the problem.

When running with a LevelDB repository it fails but switching to a JDBC 
Repository it works.

So somewhere deep in LevelDB then…

M

> On 25 Mar 2020, at 10:16, Mikael Andersson Wigander 
>  wrote:
> 
> Hi
> 
> Yes, I tried that but maybe I implement4d it wrong:
> 
> final List body = exchange.getIn().getBody(List.class);
> final Class aClass = body.get(0).getClass();
> final CodeSource codeSource = aClass.getProtectionDomain().getCodeSource();
> log.info("* onCompletion **");
> log.info("Class: " +aClass.getName());
> log.info("Code source: " + codeSource.getLocation());
> M
> 
> 
> 
>> On 25 Mar 2020, at 10:12, Zoran Regvart > > wrote:
>> 
>> Hi Mikael,
>> in the output you provided you're printing the name of the class, my
>> remark was about the fact that in Java you can have the same named
>> class loaded by two classloaders result in a ClassCastException. I
>> also provided a way to check for that.
>> 
>> zoran
>> 
>> On Wed, Mar 25, 2020 at 9:59 AM Mikael Andersson Wigander
>> mailto:mikael.grevs...@gmail.com>> wrote:
>>> 
>>> 
>>> 
 On 25 Mar 2020, at 09:28, Zoran Regvart >>> > wrote:
 Thx
>>> 
>>> I have tried this and they are the same
>>> 
>>> 
>>> * onCompletion **
>>> 2020-03-25 09:57:16.747  INFO 77480 --- [nio-8080-exec-9] 
>>> s.t.m.u.ArrayListAggregationStrategy : Class: 
>>> se.tradechannel.mifid.gateway.model.Gateway
>>> 2020-03-25 09:57:16.747  INFO 77480 --- [nio-8080-exec-9] 
>>> s.t.m.u.ArrayListAggregationStrategy : Code source: 
>>> file:/Users/mgr/IdeaProjects/mifid/target/classes/
>>> 2020-03-25 09:57:16.748 DEBUG 77480 --- [nio-8080-exec-9] 
>>> o.a.c.p.aggregate.AggregateProcessor : Processing aggregated exchange: 
>>> Exchange[ID-MAW-MacBook-Space-local-1585126611320-0-2]
>>> 2020-03-25 09:57:16.751  INFO 77480 --- [nio-8080-exec-9] SHUTTLE   
>>>: Aggregation state: 1
>>> 2020-03-25 09:57:16.751  INFO 77480 --- [nio-8080-exec-9] SHUTTLE   
>>>: Aggregation completed by: force
>>> 2020-03-25 09:57:20.709 DEBUG 77480 --- [eRecoverChecker] 
>>> o.a.c.c.l.LevelDBAggregationRepository   : Scanned and found 1 exchange(s) 
>>> to recover (note some of them may already be in progress).
>>> 2020-03-25 09:57:24.563  INFO 77480 --- [nio-8080-exec-9] 
>>> s.t.m.gateway.routes.ShuttleIntegration  : * 
>>> direct:investmentFirm **
>>> 2020-03-25 09:57:25.090  INFO 77480 --- [nio-8080-exec-9] 
>>> s.t.m.gateway.routes.ShuttleIntegration  : Class: 
>>> se.tradechannel.mifid.gateway.model.Gateway
>>> 2020-03-25 09:57:25.795  INFO 77480 --- [nio-8080-exec-9] 
>>> s.t.m.gateway.routes.ShuttleIntegration  : Code source: 
>>> file:/Users/mgr/IdeaProjects/mifid/target/classes/
>>> 2020-03-25 09:57:42.410 ERROR 77480 --- [nio-8080-exec-9] 
>>> s.t.m.gateway.routes.ShuttleIntegration  : Error occurred in 
>>> ShuttleIntegration
>>> 
>>> 
>>> 
 Hi Mikael,
 ClassCastException with SameClass cannot be cast to SameClass means
 that there is an object passed from one classloader and being cast to
 a type loaded from another classloader.
 
 Look at the difference between obj.getClass() and SameClass.class, I
 usually check with getProtectionDomain().getCodeSource() on those
 class objects.
 
 zoran
 
 
 On Wed, Mar 25, 2020 at 8:23 AM Mikael Andersson Wigander
 mailto:mikael.grevs...@gmail.com>> wrote:
> 
> TL;DR
> 
> We have a very interesting mystery in one of our Camel applications.
> 
> We have a route where we aggregate incoming messages.
> The messages are first unmarshalled from a JSON String to a Map Object> and then processed thru a model ending up with a POJO of “Gateway 
> objects".
> This POJO is then aggregated in a List. The POJO implements 
> Serializable and has equals() and hash.
> 
> The aggregationStrategy is from the example in documentation when wanting 
> to aggregate a List…
> 
> LevelDB is used for persistance Repository
> 
> When flushed we process the Exchange and starts looping using a for-loop
> 
> final List body=exchange.getIn().getBody(List.class);
>   boolean hasObject=false;
>   for(Gateway s:body){
>   final InvestmentFirm investmentFirm=s.getInvestmentFirm();
>   if(null!=investmentFirm){
>   if(StringUtils.isNoneBlank(investmentFirm.getExternalId())){
>   hasObject=true;
>   break;
>   }
>   }
>   }
> 
> 
> The thing is where we get an Exception at the start of the for-loop, 
> saying :
> 
> java.lang.ClassCastException: se.tradechannel.mifid.gateway.model.Gateway 
> cannot be cast to se.tradechannel.mifid.gateway.model.Gateway
> 

Re: Aggregation mystery - ClassCastException on same class

2020-03-25 Thread Mikael Andersson Wigander
Hi

Yes, I tried that but maybe I implement4d it wrong:

final List body = exchange.getIn().getBody(List.class);
final Class aClass = body.get(0).getClass();
final CodeSource codeSource = aClass.getProtectionDomain().getCodeSource();
log.info("* onCompletion **");
log.info("Class: " +aClass.getName());
log.info("Code source: " + codeSource.getLocation());
M



> On 25 Mar 2020, at 10:12, Zoran Regvart  wrote:
> 
> Hi Mikael,
> in the output you provided you're printing the name of the class, my
> remark was about the fact that in Java you can have the same named
> class loaded by two classloaders result in a ClassCastException. I
> also provided a way to check for that.
> 
> zoran
> 
> On Wed, Mar 25, 2020 at 9:59 AM Mikael Andersson Wigander
>  wrote:
>> 
>> 
>> 
>>> On 25 Mar 2020, at 09:28, Zoran Regvart  wrote:
>>> Thx
>> 
>> I have tried this and they are the same
>> 
>> 
>> * onCompletion **
>> 2020-03-25 09:57:16.747  INFO 77480 --- [nio-8080-exec-9] 
>> s.t.m.u.ArrayListAggregationStrategy : Class: 
>> se.tradechannel.mifid.gateway.model.Gateway
>> 2020-03-25 09:57:16.747  INFO 77480 --- [nio-8080-exec-9] 
>> s.t.m.u.ArrayListAggregationStrategy : Code source: 
>> file:/Users/mgr/IdeaProjects/mifid/target/classes/
>> 2020-03-25 09:57:16.748 DEBUG 77480 --- [nio-8080-exec-9] 
>> o.a.c.p.aggregate.AggregateProcessor : Processing aggregated exchange: 
>> Exchange[ID-MAW-MacBook-Space-local-1585126611320-0-2]
>> 2020-03-25 09:57:16.751  INFO 77480 --- [nio-8080-exec-9] SHUTTLE
>>   : Aggregation state: 1
>> 2020-03-25 09:57:16.751  INFO 77480 --- [nio-8080-exec-9] SHUTTLE
>>   : Aggregation completed by: force
>> 2020-03-25 09:57:20.709 DEBUG 77480 --- [eRecoverChecker] 
>> o.a.c.c.l.LevelDBAggregationRepository   : Scanned and found 1 exchange(s) 
>> to recover (note some of them may already be in progress).
>> 2020-03-25 09:57:24.563  INFO 77480 --- [nio-8080-exec-9] 
>> s.t.m.gateway.routes.ShuttleIntegration  : * 
>> direct:investmentFirm **
>> 2020-03-25 09:57:25.090  INFO 77480 --- [nio-8080-exec-9] 
>> s.t.m.gateway.routes.ShuttleIntegration  : Class: 
>> se.tradechannel.mifid.gateway.model.Gateway
>> 2020-03-25 09:57:25.795  INFO 77480 --- [nio-8080-exec-9] 
>> s.t.m.gateway.routes.ShuttleIntegration  : Code source: 
>> file:/Users/mgr/IdeaProjects/mifid/target/classes/
>> 2020-03-25 09:57:42.410 ERROR 77480 --- [nio-8080-exec-9] 
>> s.t.m.gateway.routes.ShuttleIntegration  : Error occurred in 
>> ShuttleIntegration
>> 
>> 
>> 
>>> Hi Mikael,
>>> ClassCastException with SameClass cannot be cast to SameClass means
>>> that there is an object passed from one classloader and being cast to
>>> a type loaded from another classloader.
>>> 
>>> Look at the difference between obj.getClass() and SameClass.class, I
>>> usually check with getProtectionDomain().getCodeSource() on those
>>> class objects.
>>> 
>>> zoran
>>> 
>>> 
>>> On Wed, Mar 25, 2020 at 8:23 AM Mikael Andersson Wigander
>>>  wrote:
 
 TL;DR
 
 We have a very interesting mystery in one of our Camel applications.
 
 We have a route where we aggregate incoming messages.
 The messages are first unmarshalled from a JSON String to a Map>>> Object> and then processed thru a model ending up with a POJO of “Gateway 
 objects".
 This POJO is then aggregated in a List. The POJO implements 
 Serializable and has equals() and hash.
 
 The aggregationStrategy is from the example in documentation when wanting 
 to aggregate a List…
 
 LevelDB is used for persistance Repository
 
 When flushed we process the Exchange and starts looping using a for-loop
 
 final List body=exchange.getIn().getBody(List.class);
   boolean hasObject=false;
   for(Gateway s:body){
   final InvestmentFirm investmentFirm=s.getInvestmentFirm();
   if(null!=investmentFirm){
   if(StringUtils.isNoneBlank(investmentFirm.getExternalId())){
   hasObject=true;
   break;
   }
   }
   }
 
 
 The thing is where we get an Exception at the start of the for-loop, 
 saying :
 
 java.lang.ClassCastException: se.tradechannel.mifid.gateway.model.Gateway 
 cannot be cast to se.tradechannel.mifid.gateway.model.Gateway
 
 I have debugged the code and the outcome of the aggregation is a 
 List but when starting to loop we get the exception
 
 
 And if we step here it will crash.
 
 We have refactored the aggregation for this route; previously we 
 unmarshalled the incoming JSON string to a Map and 
 aggregated this in a List but here we use Object as the datatype. After 
 flushing we execute the same logic with the for-loop and it runs fine…
 
 Below is a snippet of 

Re: Aggregation mystery - ClassCastException on same class

2020-03-25 Thread Mikael Andersson Wigander
Running inside IDE and also from a maven run, same issue

M

> On 25 Mar 2020, at 10:12, Maria Arias de Reyna Dominguez 
>  wrote:
> 
> Hi,
> 
> So when debugging it fails and when not debugging it doesn't?
> 
> Did you compile and run the test everything inside IntellijIDEA or are you
> maybe compiling outside with plain maven and running on the IDE? I had this
> weird thing happening to me on eclipse several years ago and it was because
> when debugging and showing the source code, it was using a different class
> than when running *even when in theory they were both using the same target
> folder*. Not sure why or how, couldn't really understand what happened, but
> a good clean and running everything inside the IDE did the trick. Check
> java versions when compiling and running (both external and internal maven,
> Idea, etc...) and such.
> 
> On Wed, Mar 25, 2020 at 10:06 AM Mikael Andersson Wigander <
> mikael.grevs...@gmail.com> wrote:
> 
>> 
>> 
>>> On 25 Mar 2020, at 09:28, Zoran Regvart  wrote:
>>> Thx
>> 
>> I have tried this and they are the same
>> 
>> 
>> * onCompletion **
>> 2020-03-25 09:57:16.747  INFO 77480 --- [nio-8080-exec-9]
>> s.t.m.u.ArrayListAggregationStrategy : Class:
>> se.tradechannel.mifid.gateway.model.Gateway
>> 2020-03-25 09:57:16.747  INFO 77480 --- [nio-8080-exec-9]
>> s.t.m.u.ArrayListAggregationStrategy : Code source:
>> file:/Users/mgr/IdeaProjects/mifid/target/classes/
>> 2020-03-25 09:57:16.748 DEBUG 77480 --- [nio-8080-exec-9]
>> o.a.c.p.aggregate.AggregateProcessor : Processing aggregated exchange:
>> Exchange[ID-MAW-MacBook-Space-local-1585126611320-0-2]
>> 2020-03-25 09:57:16.751  INFO 77480 --- [nio-8080-exec-9] SHUTTLE
>>: Aggregation state: 1
>> 2020-03-25 09:57:16.751  INFO 77480 --- [nio-8080-exec-9] SHUTTLE
>>: Aggregation completed by: force
>> 2020-03-25 09:57:20.709 DEBUG 77480 --- [eRecoverChecker]
>> o.a.c.c.l.LevelDBAggregationRepository   : Scanned and found 1 exchange(s)
>> to recover (note some of them may already be in progress).
>> 2020-03-25 09:57:24.563  INFO 77480 --- [nio-8080-exec-9]
>> s.t.m.gateway.routes.ShuttleIntegration  : *
>> direct:investmentFirm **
>> 2020-03-25 09:57:25.090  INFO 77480 --- [nio-8080-exec-9]
>> s.t.m.gateway.routes.ShuttleIntegration  : Class:
>> se.tradechannel.mifid.gateway.model.Gateway
>> 2020-03-25 09:57:25.795  INFO 77480 --- [nio-8080-exec-9]
>> s.t.m.gateway.routes.ShuttleIntegration  : Code source:
>> file:/Users/mgr/IdeaProjects/mifid/target/classes/
>> 2020-03-25 09:57:42.410 ERROR 77480 --- [nio-8080-exec-9]
>> s.t.m.gateway.routes.ShuttleIntegration  : Error occurred in
>> ShuttleIntegration
>> 
>> 
>> 
>>> Hi Mikael,
>>> ClassCastException with SameClass cannot be cast to SameClass means
>>> that there is an object passed from one classloader and being cast to
>>> a type loaded from another classloader.
>>> 
>>> Look at the difference between obj.getClass() and SameClass.class, I
>>> usually check with getProtectionDomain().getCodeSource() on those
>>> class objects.
>>> 
>>> zoran
>>> 
>>> 
>>> On Wed, Mar 25, 2020 at 8:23 AM Mikael Andersson Wigander
>>>  wrote:
 
 TL;DR
 
 We have a very interesting mystery in one of our Camel applications.
 
 We have a route where we aggregate incoming messages.
 The messages are first unmarshalled from a JSON String to a Map> Object> and then processed thru a model ending up with a POJO of “Gateway
>> objects".
 This POJO is then aggregated in a List. The POJO implements
>> Serializable and has equals() and hash.
 
 The aggregationStrategy is from the example in documentation when
>> wanting to aggregate a List…
 
 LevelDB is used for persistance Repository
 
 When flushed we process the Exchange and starts looping using a for-loop
 
 final List body=exchange.getIn().getBody(List.class);
   boolean hasObject=false;
   for(Gateway s:body){
   final InvestmentFirm investmentFirm=s.getInvestmentFirm();
   if(null!=investmentFirm){
 
>> if(StringUtils.isNoneBlank(investmentFirm.getExternalId())){
   hasObject=true;
   break;
   }
   }
   }
 
 
 The thing is where we get an Exception at the start of the for-loop,
>> saying :
 
 java.lang.ClassCastException:
>> se.tradechannel.mifid.gateway.model.Gateway cannot be cast to
>> se.tradechannel.mifid.gateway.model.Gateway
 
 I have debugged the code and the outcome of the aggregation is a
>> List but when starting to loop we get the exception
 
 
 And if we step here it will crash.
 
 We have refactored the aggregation for this route; previously we
>> unmarshalled the incoming JSON string to a Map and
>> aggregated this in a List but here we use Object as the datatype. After
>> flushing we 

Re: Aggregation mystery - ClassCastException on same class

2020-03-25 Thread Maria Arias de Reyna Dominguez
Hi,

So when debugging it fails and when not debugging it doesn't?

Did you compile and run the test everything inside IntellijIDEA or are you
maybe compiling outside with plain maven and running on the IDE? I had this
weird thing happening to me on eclipse several years ago and it was because
when debugging and showing the source code, it was using a different class
than when running *even when in theory they were both using the same target
folder*. Not sure why or how, couldn't really understand what happened, but
a good clean and running everything inside the IDE did the trick. Check
java versions when compiling and running (both external and internal maven,
Idea, etc...) and such.

On Wed, Mar 25, 2020 at 10:06 AM Mikael Andersson Wigander <
mikael.grevs...@gmail.com> wrote:

>
>
> > On 25 Mar 2020, at 09:28, Zoran Regvart  wrote:
> > Thx
>
> I have tried this and they are the same
>
>
> * onCompletion **
> 2020-03-25 09:57:16.747  INFO 77480 --- [nio-8080-exec-9]
> s.t.m.u.ArrayListAggregationStrategy : Class:
> se.tradechannel.mifid.gateway.model.Gateway
> 2020-03-25 09:57:16.747  INFO 77480 --- [nio-8080-exec-9]
> s.t.m.u.ArrayListAggregationStrategy : Code source:
> file:/Users/mgr/IdeaProjects/mifid/target/classes/
> 2020-03-25 09:57:16.748 DEBUG 77480 --- [nio-8080-exec-9]
> o.a.c.p.aggregate.AggregateProcessor : Processing aggregated exchange:
> Exchange[ID-MAW-MacBook-Space-local-1585126611320-0-2]
> 2020-03-25 09:57:16.751  INFO 77480 --- [nio-8080-exec-9] SHUTTLE
> : Aggregation state: 1
> 2020-03-25 09:57:16.751  INFO 77480 --- [nio-8080-exec-9] SHUTTLE
> : Aggregation completed by: force
> 2020-03-25 09:57:20.709 DEBUG 77480 --- [eRecoverChecker]
> o.a.c.c.l.LevelDBAggregationRepository   : Scanned and found 1 exchange(s)
> to recover (note some of them may already be in progress).
> 2020-03-25 09:57:24.563  INFO 77480 --- [nio-8080-exec-9]
> s.t.m.gateway.routes.ShuttleIntegration  : *
> direct:investmentFirm **
> 2020-03-25 09:57:25.090  INFO 77480 --- [nio-8080-exec-9]
> s.t.m.gateway.routes.ShuttleIntegration  : Class:
> se.tradechannel.mifid.gateway.model.Gateway
> 2020-03-25 09:57:25.795  INFO 77480 --- [nio-8080-exec-9]
> s.t.m.gateway.routes.ShuttleIntegration  : Code source:
> file:/Users/mgr/IdeaProjects/mifid/target/classes/
> 2020-03-25 09:57:42.410 ERROR 77480 --- [nio-8080-exec-9]
> s.t.m.gateway.routes.ShuttleIntegration  : Error occurred in
> ShuttleIntegration
>
>
>
> > Hi Mikael,
> > ClassCastException with SameClass cannot be cast to SameClass means
> > that there is an object passed from one classloader and being cast to
> > a type loaded from another classloader.
> >
> > Look at the difference between obj.getClass() and SameClass.class, I
> > usually check with getProtectionDomain().getCodeSource() on those
> > class objects.
> >
> > zoran
> >
> >
> > On Wed, Mar 25, 2020 at 8:23 AM Mikael Andersson Wigander
> >  wrote:
> >>
> >> TL;DR
> >>
> >> We have a very interesting mystery in one of our Camel applications.
> >>
> >> We have a route where we aggregate incoming messages.
> >> The messages are first unmarshalled from a JSON String to a Map Object> and then processed thru a model ending up with a POJO of “Gateway
> objects".
> >> This POJO is then aggregated in a List. The POJO implements
> Serializable and has equals() and hash.
> >>
> >> The aggregationStrategy is from the example in documentation when
> wanting to aggregate a List…
> >>
> >> LevelDB is used for persistance Repository
> >>
> >> When flushed we process the Exchange and starts looping using a for-loop
> >>
> >> final List body=exchange.getIn().getBody(List.class);
> >>boolean hasObject=false;
> >>for(Gateway s:body){
> >>final InvestmentFirm investmentFirm=s.getInvestmentFirm();
> >>if(null!=investmentFirm){
> >>
> if(StringUtils.isNoneBlank(investmentFirm.getExternalId())){
> >>hasObject=true;
> >>break;
> >>}
> >>}
> >>}
> >>
> >>
> >> The thing is where we get an Exception at the start of the for-loop,
> saying :
> >>
> >> java.lang.ClassCastException:
> se.tradechannel.mifid.gateway.model.Gateway cannot be cast to
> se.tradechannel.mifid.gateway.model.Gateway
> >>
> >> I have debugged the code and the outcome of the aggregation is a
> List but when starting to loop we get the exception
> >>
> >>
> >> And if we step here it will crash.
> >>
> >> We have refactored the aggregation for this route; previously we
> unmarshalled the incoming JSON string to a Map and
> aggregated this in a List but here we use Object as the datatype. After
> flushing we execute the same logic with the for-loop and it runs fine…
> >>
> >> Below is a snippet of the code
> >>
> >> public void configure() throws Exception {
> >>final DefaultAggregateController defaultAggregateController = new
> 

Re: Aggregation mystery - ClassCastException on same class

2020-03-25 Thread Zoran Regvart
Hi Mikael,
in the output you provided you're printing the name of the class, my
remark was about the fact that in Java you can have the same named
class loaded by two classloaders result in a ClassCastException. I
also provided a way to check for that.

zoran

On Wed, Mar 25, 2020 at 9:59 AM Mikael Andersson Wigander
 wrote:
>
>
>
> > On 25 Mar 2020, at 09:28, Zoran Regvart  wrote:
> > Thx
>
> I have tried this and they are the same
>
>
> * onCompletion **
> 2020-03-25 09:57:16.747  INFO 77480 --- [nio-8080-exec-9] 
> s.t.m.u.ArrayListAggregationStrategy : Class: 
> se.tradechannel.mifid.gateway.model.Gateway
> 2020-03-25 09:57:16.747  INFO 77480 --- [nio-8080-exec-9] 
> s.t.m.u.ArrayListAggregationStrategy : Code source: 
> file:/Users/mgr/IdeaProjects/mifid/target/classes/
> 2020-03-25 09:57:16.748 DEBUG 77480 --- [nio-8080-exec-9] 
> o.a.c.p.aggregate.AggregateProcessor : Processing aggregated exchange: 
> Exchange[ID-MAW-MacBook-Space-local-1585126611320-0-2]
> 2020-03-25 09:57:16.751  INFO 77480 --- [nio-8080-exec-9] SHUTTLE 
>  : Aggregation state: 1
> 2020-03-25 09:57:16.751  INFO 77480 --- [nio-8080-exec-9] SHUTTLE 
>  : Aggregation completed by: force
> 2020-03-25 09:57:20.709 DEBUG 77480 --- [eRecoverChecker] 
> o.a.c.c.l.LevelDBAggregationRepository   : Scanned and found 1 exchange(s) to 
> recover (note some of them may already be in progress).
> 2020-03-25 09:57:24.563  INFO 77480 --- [nio-8080-exec-9] 
> s.t.m.gateway.routes.ShuttleIntegration  : * 
> direct:investmentFirm **
> 2020-03-25 09:57:25.090  INFO 77480 --- [nio-8080-exec-9] 
> s.t.m.gateway.routes.ShuttleIntegration  : Class: 
> se.tradechannel.mifid.gateway.model.Gateway
> 2020-03-25 09:57:25.795  INFO 77480 --- [nio-8080-exec-9] 
> s.t.m.gateway.routes.ShuttleIntegration  : Code source: 
> file:/Users/mgr/IdeaProjects/mifid/target/classes/
> 2020-03-25 09:57:42.410 ERROR 77480 --- [nio-8080-exec-9] 
> s.t.m.gateway.routes.ShuttleIntegration  : Error occurred in 
> ShuttleIntegration
>
>
>
> > Hi Mikael,
> > ClassCastException with SameClass cannot be cast to SameClass means
> > that there is an object passed from one classloader and being cast to
> > a type loaded from another classloader.
> >
> > Look at the difference between obj.getClass() and SameClass.class, I
> > usually check with getProtectionDomain().getCodeSource() on those
> > class objects.
> >
> > zoran
> >
> >
> > On Wed, Mar 25, 2020 at 8:23 AM Mikael Andersson Wigander
> >  wrote:
> >>
> >> TL;DR
> >>
> >> We have a very interesting mystery in one of our Camel applications.
> >>
> >> We have a route where we aggregate incoming messages.
> >> The messages are first unmarshalled from a JSON String to a Map >> Object> and then processed thru a model ending up with a POJO of “Gateway 
> >> objects".
> >> This POJO is then aggregated in a List. The POJO implements 
> >> Serializable and has equals() and hash.
> >>
> >> The aggregationStrategy is from the example in documentation when wanting 
> >> to aggregate a List…
> >>
> >> LevelDB is used for persistance Repository
> >>
> >> When flushed we process the Exchange and starts looping using a for-loop
> >>
> >> final List body=exchange.getIn().getBody(List.class);
> >>boolean hasObject=false;
> >>for(Gateway s:body){
> >>final InvestmentFirm investmentFirm=s.getInvestmentFirm();
> >>if(null!=investmentFirm){
> >>if(StringUtils.isNoneBlank(investmentFirm.getExternalId())){
> >>hasObject=true;
> >>break;
> >>}
> >>}
> >>}
> >>
> >>
> >> The thing is where we get an Exception at the start of the for-loop, 
> >> saying :
> >>
> >> java.lang.ClassCastException: se.tradechannel.mifid.gateway.model.Gateway 
> >> cannot be cast to se.tradechannel.mifid.gateway.model.Gateway
> >>
> >> I have debugged the code and the outcome of the aggregation is a 
> >> List but when starting to loop we get the exception
> >>
> >>
> >> And if we step here it will crash.
> >>
> >> We have refactored the aggregation for this route; previously we 
> >> unmarshalled the incoming JSON string to a Map and 
> >> aggregated this in a List but here we use Object as the datatype. After 
> >> flushing we execute the same logic with the for-loop and it runs fine…
> >>
> >> Below is a snippet of the code
> >>
> >> public void configure() throws Exception {
> >>final DefaultAggregateController defaultAggregateController = new 
> >> DefaultAggregateController();
> >>
> >>final LevelDBAggregationRepository shuttleRepo = new 
> >> LevelDBAggregationRepository("shuttleArt26",
> >>"mifir/data/shuttle/article26.dat");
> >>
> >>
> >>//tag::route[]
> >>from("{{shuttle.jms.incoming}}")
> >>.unmarshal().json(JsonLibrary.Jackson, true)
> >>

Re: Aggregation mystery - ClassCastException on same class

2020-03-25 Thread Mikael Andersson Wigander
I implemented CompletionAwareAggregationStrategy
and in onCompletion() I checked the class but it crashes with an Ex eption in 
there as well…



> On 25 Mar 2020, at 09:59, Mikael Andersson Wigander 
>  wrote:
> 
> 
> 
>> On 25 Mar 2020, at 09:28, Zoran Regvart  wrote:
>> Thx
> 
> I have tried this and they are the same 
> 
> 
> * onCompletion **
> 2020-03-25 09:57:16.747  INFO 77480 --- [nio-8080-exec-9] 
> s.t.m.u.ArrayListAggregationStrategy : Class: 
> se.tradechannel.mifid.gateway.model.Gateway
> 2020-03-25 09:57:16.747  INFO 77480 --- [nio-8080-exec-9] 
> s.t.m.u.ArrayListAggregationStrategy : Code source: 
> file:/Users/mgr/IdeaProjects/mifid/target/classes/
> 2020-03-25 09:57:16.748 DEBUG 77480 --- [nio-8080-exec-9] 
> o.a.c.p.aggregate.AggregateProcessor : Processing aggregated exchange: 
> Exchange[ID-MAW-MacBook-Space-local-1585126611320-0-2]
> 2020-03-25 09:57:16.751  INFO 77480 --- [nio-8080-exec-9] SHUTTLE 
>  : Aggregation state: 1
> 2020-03-25 09:57:16.751  INFO 77480 --- [nio-8080-exec-9] SHUTTLE 
>  : Aggregation completed by: force
> 2020-03-25 09:57:20.709 DEBUG 77480 --- [eRecoverChecker] 
> o.a.c.c.l.LevelDBAggregationRepository   : Scanned and found 1 exchange(s) to 
> recover (note some of them may already be in progress).
> 2020-03-25 09:57:24.563  INFO 77480 --- [nio-8080-exec-9] 
> s.t.m.gateway.routes.ShuttleIntegration  : * 
> direct:investmentFirm **
> 2020-03-25 09:57:25.090  INFO 77480 --- [nio-8080-exec-9] 
> s.t.m.gateway.routes.ShuttleIntegration  : Class: 
> se.tradechannel.mifid.gateway.model.Gateway
> 2020-03-25 09:57:25.795  INFO 77480 --- [nio-8080-exec-9] 
> s.t.m.gateway.routes.ShuttleIntegration  : Code source: 
> file:/Users/mgr/IdeaProjects/mifid/target/classes/
> 2020-03-25 09:57:42.410 ERROR 77480 --- [nio-8080-exec-9] 
> s.t.m.gateway.routes.ShuttleIntegration  : Error occurred in 
> ShuttleIntegration
> 
> 
> 
>> Hi Mikael,
>> ClassCastException with SameClass cannot be cast to SameClass means
>> that there is an object passed from one classloader and being cast to
>> a type loaded from another classloader.
>> 
>> Look at the difference between obj.getClass() and SameClass.class, I
>> usually check with getProtectionDomain().getCodeSource() on those
>> class objects.
>> 
>> zoran
>> 
>> 
>> On Wed, Mar 25, 2020 at 8:23 AM Mikael Andersson Wigander
>>  wrote:
>>> 
>>> TL;DR
>>> 
>>> We have a very interesting mystery in one of our Camel applications.
>>> 
>>> We have a route where we aggregate incoming messages.
>>> The messages are first unmarshalled from a JSON String to a Map>> Object> and then processed thru a model ending up with a POJO of “Gateway 
>>> objects".
>>> This POJO is then aggregated in a List. The POJO implements 
>>> Serializable and has equals() and hash.
>>> 
>>> The aggregationStrategy is from the example in documentation when wanting 
>>> to aggregate a List…
>>> 
>>> LevelDB is used for persistance Repository
>>> 
>>> When flushed we process the Exchange and starts looping using a for-loop
>>> 
>>> final List body=exchange.getIn().getBody(List.class);
>>>   boolean hasObject=false;
>>>   for(Gateway s:body){
>>>   final InvestmentFirm investmentFirm=s.getInvestmentFirm();
>>>   if(null!=investmentFirm){
>>>   if(StringUtils.isNoneBlank(investmentFirm.getExternalId())){
>>>   hasObject=true;
>>>   break;
>>>   }
>>>   }
>>>   }
>>> 
>>> 
>>> The thing is where we get an Exception at the start of the for-loop, saying 
>>> :
>>> 
>>> java.lang.ClassCastException: se.tradechannel.mifid.gateway.model.Gateway 
>>> cannot be cast to se.tradechannel.mifid.gateway.model.Gateway
>>> 
>>> I have debugged the code and the outcome of the aggregation is a 
>>> List but when starting to loop we get the exception
>>> 
>>> 
>>> And if we step here it will crash.
>>> 
>>> We have refactored the aggregation for this route; previously we 
>>> unmarshalled the incoming JSON string to a Map and 
>>> aggregated this in a List but here we use Object as the datatype. After 
>>> flushing we execute the same logic with the for-loop and it runs fine…
>>> 
>>> Below is a snippet of the code
>>> 
>>> public void configure() throws Exception {
>>>   final DefaultAggregateController defaultAggregateController = new 
>>> DefaultAggregateController();
>>> 
>>>   final LevelDBAggregationRepository shuttleRepo = new 
>>> LevelDBAggregationRepository("shuttleArt26",
>>>   "mifir/data/shuttle/article26.dat");
>>> 
>>> 
>>>   //tag::route[]
>>>   from("{{shuttle.jms.incoming}}")
>>>   .unmarshal().json(JsonLibrary.Jackson, true)
>>>   .process(this::createShuttleObject)
>>>   .aggregate(constant(true), new ArrayListAggregationStrategy())
>>>   .aggregateController(defaultAggregateController)
>>>   

Re: Aggregation mystery - ClassCastException on same class

2020-03-25 Thread Mikael Andersson Wigander



> On 25 Mar 2020, at 09:28, Zoran Regvart  wrote:
> Thx

I have tried this and they are the same 


* onCompletion **
2020-03-25 09:57:16.747  INFO 77480 --- [nio-8080-exec-9] 
s.t.m.u.ArrayListAggregationStrategy : Class: 
se.tradechannel.mifid.gateway.model.Gateway
2020-03-25 09:57:16.747  INFO 77480 --- [nio-8080-exec-9] 
s.t.m.u.ArrayListAggregationStrategy : Code source: 
file:/Users/mgr/IdeaProjects/mifid/target/classes/
2020-03-25 09:57:16.748 DEBUG 77480 --- [nio-8080-exec-9] 
o.a.c.p.aggregate.AggregateProcessor : Processing aggregated exchange: 
Exchange[ID-MAW-MacBook-Space-local-1585126611320-0-2]
2020-03-25 09:57:16.751  INFO 77480 --- [nio-8080-exec-9] SHUTTLE   
   : Aggregation state: 1
2020-03-25 09:57:16.751  INFO 77480 --- [nio-8080-exec-9] SHUTTLE   
   : Aggregation completed by: force
2020-03-25 09:57:20.709 DEBUG 77480 --- [eRecoverChecker] 
o.a.c.c.l.LevelDBAggregationRepository   : Scanned and found 1 exchange(s) to 
recover (note some of them may already be in progress).
2020-03-25 09:57:24.563  INFO 77480 --- [nio-8080-exec-9] 
s.t.m.gateway.routes.ShuttleIntegration  : * direct:investmentFirm 
**
2020-03-25 09:57:25.090  INFO 77480 --- [nio-8080-exec-9] 
s.t.m.gateway.routes.ShuttleIntegration  : Class: 
se.tradechannel.mifid.gateway.model.Gateway
2020-03-25 09:57:25.795  INFO 77480 --- [nio-8080-exec-9] 
s.t.m.gateway.routes.ShuttleIntegration  : Code source: 
file:/Users/mgr/IdeaProjects/mifid/target/classes/
2020-03-25 09:57:42.410 ERROR 77480 --- [nio-8080-exec-9] 
s.t.m.gateway.routes.ShuttleIntegration  : Error occurred in ShuttleIntegration



> Hi Mikael,
> ClassCastException with SameClass cannot be cast to SameClass means
> that there is an object passed from one classloader and being cast to
> a type loaded from another classloader.
> 
> Look at the difference between obj.getClass() and SameClass.class, I
> usually check with getProtectionDomain().getCodeSource() on those
> class objects.
> 
> zoran
> 
> 
> On Wed, Mar 25, 2020 at 8:23 AM Mikael Andersson Wigander
>  wrote:
>> 
>> TL;DR
>> 
>> We have a very interesting mystery in one of our Camel applications.
>> 
>> We have a route where we aggregate incoming messages.
>> The messages are first unmarshalled from a JSON String to a Map> Object> and then processed thru a model ending up with a POJO of “Gateway 
>> objects".
>> This POJO is then aggregated in a List. The POJO implements 
>> Serializable and has equals() and hash.
>> 
>> The aggregationStrategy is from the example in documentation when wanting to 
>> aggregate a List…
>> 
>> LevelDB is used for persistance Repository
>> 
>> When flushed we process the Exchange and starts looping using a for-loop
>> 
>> final List body=exchange.getIn().getBody(List.class);
>>boolean hasObject=false;
>>for(Gateway s:body){
>>final InvestmentFirm investmentFirm=s.getInvestmentFirm();
>>if(null!=investmentFirm){
>>if(StringUtils.isNoneBlank(investmentFirm.getExternalId())){
>>hasObject=true;
>>break;
>>}
>>}
>>}
>> 
>> 
>> The thing is where we get an Exception at the start of the for-loop, saying :
>> 
>> java.lang.ClassCastException: se.tradechannel.mifid.gateway.model.Gateway 
>> cannot be cast to se.tradechannel.mifid.gateway.model.Gateway
>> 
>> I have debugged the code and the outcome of the aggregation is a 
>> List but when starting to loop we get the exception
>> 
>> 
>> And if we step here it will crash.
>> 
>> We have refactored the aggregation for this route; previously we 
>> unmarshalled the incoming JSON string to a Map and 
>> aggregated this in a List but here we use Object as the datatype. After 
>> flushing we execute the same logic with the for-loop and it runs fine…
>> 
>> Below is a snippet of the code
>> 
>> public void configure() throws Exception {
>>final DefaultAggregateController defaultAggregateController = new 
>> DefaultAggregateController();
>> 
>>final LevelDBAggregationRepository shuttleRepo = new 
>> LevelDBAggregationRepository("shuttleArt26",
>>"mifir/data/shuttle/article26.dat");
>> 
>> 
>>//tag::route[]
>>from("{{shuttle.jms.incoming}}")
>>.unmarshal().json(JsonLibrary.Jackson, true)
>>.process(this::createShuttleObject)
>>.aggregate(constant(true), new ArrayListAggregationStrategy())
>>.aggregateController(defaultAggregateController)
>>.aggregationRepository(shuttleRepo)
>>.parallelProcessing(false)
>>.completionSize(aggregation_size)
>>.stopOnException()
>>.to("direct:investmentFirm")
>> 
>>.end();
>> 
>> 
>>from("direct:investmentFirm")
>>.choice()
>>.when(exchange -> { //<.>
>>final List body = 

Re: Some questions on CamelK

2020-03-25 Thread Zoran Regvart
Hi Raymond,

On Mon, Mar 23, 2020 at 7:38 PM ski n  wrote:
> The code for every example could be added in a tab for every support
> language (so all examples are supported languages are treated equally). A
> little bit like vert.x does on it website (See polyglot -->
> https://vertx.io/)

I think this is good feedback, can you provide the full link to the
example on the vert.x website, I have trouble finding this "polyglot"
documentation on vert.x.

zoran
-- 
Zoran Regvart


Re: XML routes config problem

2020-03-25 Thread Zoran Regvart
Hi Joe,
also have a look at this FAQ entry:

https://camel.apache.org/manual/latest/faq/how-do-i-use-uris-with-parameters-in-xml.html

zoran

On Mon, Mar 23, 2020 at 8:04 PM Gagnon, Joseph - 0553 - MITLL
 wrote:
>
> Oh, that's ugly. But, it works. Thanks.
>
> -Original Message-
> From: Alisson Gomes 
> Sent: Monday, March 23, 2020 2:54 PM
> To: users@camel.apache.org
> Subject: Re: XML routes config problem
>
> Change & for 
>
> 
>uri="ftp://{{host-name}}/{{source-dir}}?fileExist=Ignoredisconnect=true;
> />
>   
> 
>
>
> On Mon, Mar 23, 2020 at 3:49 PM Gagnon, Joseph - 0553 - MITLL < 
> joseph.gag...@ll.mit.edu> wrote:
>
> > Hello,
> >
> > I’m very new with Camel and still trying to figure it out. I have a
> > simple application that configures routing via XML and I’m getting a
> > strange error (from eclipse) when I attempt to do the following:
> >
> > 
> >> uri="ftp://{{host-name}}/{{source-dir}}?fileExist=Ignore=true;
> > />
> >   
> > 
> >
> > Eclipse indicates an error on the “from” line stating:
> >
> > The reference to entity “disconnect” must end with the “;” delimiter.
> >
> > I don’t understand the complaint. The component documentation says
> > that the URI is as follows:
> >
> > ftp://[username@]hostname[:port]/directoryname[?options]
> > where: ?option=value=value&…
> >
> > What am I doing wrong?
> >
> > Thanks,
> > Joe
> >



-- 
Zoran Regvart


Re: rest-swagger. Request swagger spec with auth by http

2020-03-25 Thread Zoran Regvart
Hi Mikhail,
for Swagger support in Camel we use swagger-parser[1] which
transparently supports loading both JSON and YAML. I would encourage
you to try the OpenAPI support we have, that uses
apicurio-data-models[2] which I find to be much more reliable and
easier to use. You also get OpenAPI 3 support with it.

zoran

[1] https://github.com/swagger-api/swagger-parser
[2] https://github.com/Apicurio/apicurio-data-models

On Tue, Mar 24, 2020 at 2:58 PM Mikhail Lukyanov  wrote:
>
> Thank you, Zoran. I understand auth doesn't need in this case.
>
> Can you answer another question?
>
> Is rest-swagger component supports only JSON swagger spec and doesn't
> support YAML?
>
> пн, 23 мар. 2020 г. в 13:57, Zoran Regvart :
>
> > Hi Mikhail,
> > I must say that that's a very strange requirement. Authentication is
> > just one of the ways this would fail; it could also fail if the
> > service hosting the OpenAPI document is unavailable. I'd approach this
> > problem differently by downloading the OpenAPI document and bundling
> > it within the Camel application.
> >
> > zoran
> >
> > On Fri, Mar 20, 2020 at 9:27 AM Mikhail Lukyanov 
> > wrote:
> > >
> > > Hello, everyone
> > >
> > > Is it possible to somehow get the swagger specification by a HTTP request
> > > from a resource that requires authorization? Now when I start the route I
> > > get an error
> > >
> > > Caused by: org.apache.camel.FailedToCreateProducerException: Failed to
> > > create Producer for endpoint: rest-swagger://
> > >
> > http://192.168.58.241:8181/manager/v2/api-docs%23getUsingGET?componentName=http-swagger
> > .
> > > Reason: java.lang.IllegalArgumentException: The given Swagger
> > specification
> > > could not be loaded from `
> > http://192.168.58.241:8181/manager/v2/api-docs`
> > .
> > > Tried loading using Camel's resource resolution and using Swagger's own
> > > resource resolution. Swagger tends to swallow exceptions while parsing,
> > try
> > > specifying Java system property `debugParser` (e.g.
> > `-DdebugParser=true`),
> > > the exception that occured when loading using Camel's resource loader
> > > follows at
> > > org.apache.camel.impl.ProducerCache.doGetProducer(ProducerCache.java:578)
> > > at
> > >
> > org.apache.camel.impl.ProducerCache.acquireProducer(ProducerCache.java:168)
> > >
> > >
> > >
> > > I thought I can set header with auth in the rout, by the rout didn't
> > start
> > >
> > > Camel version 2.20.2
> > >
> > >
> > >
> > > --
> > > *With best regards, Lukyanov Mikhail*
> > > *Tel: **+7-909-69-71-547*
> >
> >
> >
> > --
> > Zoran Regvart
> >
>
>
> --
> *With best regards, Lukyanov Mikhail*
> *Tel: **+7-909-69-71-547*



-- 
Zoran Regvart


Re: Aggregation mystery - ClassCastException on same class

2020-03-25 Thread Zoran Regvart
Hi Mikael,
ClassCastException with SameClass cannot be cast to SameClass means
that there is an object passed from one classloader and being cast to
a type loaded from another classloader.

Look at the difference between obj.getClass() and SameClass.class, I
usually check with getProtectionDomain().getCodeSource() on those
class objects.

zoran


On Wed, Mar 25, 2020 at 8:23 AM Mikael Andersson Wigander
 wrote:
>
> TL;DR
>
> We have a very interesting mystery in one of our Camel applications.
>
> We have a route where we aggregate incoming messages.
> The messages are first unmarshalled from a JSON String to a Map Object> and then processed thru a model ending up with a POJO of “Gateway 
> objects".
> This POJO is then aggregated in a List. The POJO implements 
> Serializable and has equals() and hash.
>
> The aggregationStrategy is from the example in documentation when wanting to 
> aggregate a List…
>
> LevelDB is used for persistance Repository
>
> When flushed we process the Exchange and starts looping using a for-loop
>
> final List body=exchange.getIn().getBody(List.class);
> boolean hasObject=false;
> for(Gateway s:body){
> final InvestmentFirm investmentFirm=s.getInvestmentFirm();
> if(null!=investmentFirm){
> if(StringUtils.isNoneBlank(investmentFirm.getExternalId())){
> hasObject=true;
> break;
> }
> }
> }
>
>
> The thing is where we get an Exception at the start of the for-loop, saying :
>
> java.lang.ClassCastException: se.tradechannel.mifid.gateway.model.Gateway 
> cannot be cast to se.tradechannel.mifid.gateway.model.Gateway
>
> I have debugged the code and the outcome of the aggregation is a 
> List but when starting to loop we get the exception
>
>
> And if we step here it will crash.
>
> We have refactored the aggregation for this route; previously we unmarshalled 
> the incoming JSON string to a Map and aggregated this in a 
> List but here we use Object as the datatype. After flushing we execute the 
> same logic with the for-loop and it runs fine…
>
> Below is a snippet of the code
>
> public void configure() throws Exception {
> final DefaultAggregateController defaultAggregateController = new 
> DefaultAggregateController();
>
> final LevelDBAggregationRepository shuttleRepo = new 
> LevelDBAggregationRepository("shuttleArt26",
> "mifir/data/shuttle/article26.dat");
>
>
> //tag::route[]
> from("{{shuttle.jms.incoming}}")
> .unmarshal().json(JsonLibrary.Jackson, true)
> .process(this::createShuttleObject)
> .aggregate(constant(true), new ArrayListAggregationStrategy())
> .aggregateController(defaultAggregateController)
> .aggregationRepository(shuttleRepo)
> .parallelProcessing(false)
> .completionSize(aggregation_size)
> .stopOnException()
> .to("direct:investmentFirm")
>
> .end();
>
>
> from("direct:investmentFirm")
> .choice()
> .when(exchange -> { //<.>
> final List body = 
> exchange.getIn().getBody(List.class);
> boolean hasObject = false;
> for (Gateway s : body) {
> final InvestmentFirm investmentFirm = 
> s.getInvestmentFirm();
> if (null != investmentFirm) {
> if 
> (StringUtils.isNoneBlank(investmentFirm.getExternalId())) {
> hasObject = true;
> break;
> }
> }
> }
> log.debug("InvestmentFirms = " + hasObject);
> return hasObject;
> })
> .end();
>
> }
>
> public class ArrayListAggregationStrategy implements AggregationStrategy {
> public Exchange aggregate(Exchange oldExchange, Exchange newExchange) {
> List newBody = newExchange.getIn().getBody(ArrayList.class);
> List list;
>
>
> //Ignore Exception here
> if (null != newExchange.getException()) {
> return oldExchange;
> }
>
> //First Exchange to aggregate
> if (null == oldExchange) {
> list = new ArrayList<>(newBody);
> newExchange.getIn().setBody(list);
> return newExchange;
> } else {
> list = oldExchange.getIn().getBody(ArrayList.class);
> list.addAll(newBody);
> oldExchange.getIn().setBody(list);
> return oldExchange;
> }
> }
> }
>
>
>
>
>
> We really can’t see what the heck is going on, it seems OK everything but 
> "the computer says No!”
>
> Anyone?
>
> Thx
>
> M



-- 
Zoran Regvart


Re: Testing Route in camel-quarkus

2020-03-25 Thread Alex Dettinger
Hi Dennis,

  Interesting idea, this may work in jvm mode and would need to be excluded
when executing @NativeImageTest.
You may also be able to inject a ProducerTemplate in the test to feed the
route directly.

Alex

On Wed, Mar 25, 2020 at 7:55 AM Dennis Holunder 
wrote:

> I could create a quarkus test where the route is injected and external
> endpoint is mocked with quarkus mock support.
>
> Am Fr., 20. März 2020 um 11:52 Uhr schrieb Dennis Holunder
> :
> >
> > Hello,
> >
> > is it possible to test a non-http route in camel-quarkus like we do
> > with CamelTestSupport in camel?
> >
> > Thanks!
>


Re: Aggregation mystery - ClassCastException on same class

2020-03-25 Thread Mikael Andersson Wigander
Well the computer never lies but when I revert to normal execution the code 
executes.

I have tried to use the generics as in our production mode using aggregation 
with List but that gives me the same error…

M

> On 25 Mar 2020, at 08:50, Maria Arias de Reyna Dominguez 
>  wrote:
> 
> Hi,
> 
> A very very wild guess: could it be a problem with dependencies so you have 
> on your classpath two versions of the same class? The JVM should choose only 
> one of them and use it, but to me it is clear it doesn't think that the first 
> "se.tradechannel.mifid.gateway.model.Gateway" is the same as the latter 
> "se.tradechannel.mifid.gateway.model.Gateway". So there must be two versions 
> of it somewhere.
> 
> On Wed, Mar 25, 2020 at 8:30 AM Mikael Andersson Wigander 
> mailto:mikael.grevs...@gmail.com>> wrote:
> TL;DR
> 
> We have a very interesting mystery in one of our Camel applications.
> 
> We have a route where we aggregate incoming messages.
> The messages are first unmarshalled from a JSON String to a Map Object> and then processed thru a model ending up with a POJO of “Gateway 
> objects".
> This POJO is then aggregated in a List. The POJO implements 
> Serializable and has equals() and hash.
> 
> The aggregationStrategy is from the example in documentation when wanting to 
> aggregate a List…
> 
> LevelDB is used for persistance Repository
> 
> When flushed we process the Exchange and starts looping using a for-loop 
> 
> final List body=exchange.getIn().getBody(List.class);
> boolean hasObject=false;
> for(Gateway s:body){
> final InvestmentFirm investmentFirm=s.getInvestmentFirm();
> if(null!=investmentFirm){
> if(StringUtils.isNoneBlank(investmentFirm.getExternalId())){
> hasObject=true;
> break;
> }
> }
> }
> 
> The thing is where we get an Exception at the start of the for-loop, saying :
> 
> java.lang.ClassCastException: se.tradechannel.mifid.gateway.model.Gateway 
> cannot be cast to se.tradechannel.mifid.gateway.model.Gateway
> 
> I have debugged the code and the outcome of the aggregation is a 
> List but when starting to loop we get the exception
> 
> 
> 
> And if we step here it will crash.
> 
> We have refactored the aggregation for this route; previously we unmarshalled 
> the incoming JSON string to a Map and aggregated this in a 
> List but here we use Object as the datatype. After flushing we execute the 
> same logic with the for-loop and it runs fine…
> 
> Below is a snippet of the code 
> 
> public void configure() throws Exception {
> final DefaultAggregateController defaultAggregateController = new 
> DefaultAggregateController();
> 
> final LevelDBAggregationRepository shuttleRepo = new 
> LevelDBAggregationRepository("shuttleArt26",
> "mifir/data/shuttle/article26.dat");
> 
> 
> //tag::route[]
> from("{{shuttle.jms.incoming}}")
> .unmarshal().json(JsonLibrary.Jackson, true)
> .process(this::createShuttleObject)
> .aggregate(constant(true), new ArrayListAggregationStrategy())
> .aggregateController(defaultAggregateController)
> .aggregationRepository(shuttleRepo)
> .parallelProcessing(false)
> .completionSize(aggregation_size)
> .stopOnException()
> .to("direct:investmentFirm")
> 
> .end();
> 
> 
> from("direct:investmentFirm")
> .choice()
> .when(exchange -> { //<.>
> final List body = 
> exchange.getIn().getBody(List.class);
> boolean hasObject = false;
> for (Gateway s : body) {
> final InvestmentFirm investmentFirm = 
> s.getInvestmentFirm();
> if (null != investmentFirm) {
> if 
> (StringUtils.isNoneBlank(investmentFirm.getExternalId())) {
> hasObject = true;
> break;
> }
> }
> }
> log.debug("InvestmentFirms = " + hasObject);
> return hasObject;
> })
> .end();
> 
> }
> public class ArrayListAggregationStrategy implements AggregationStrategy {
> public Exchange aggregate(Exchange oldExchange, Exchange newExchange) {
> List newBody = newExchange.getIn().getBody(ArrayList.class);
> List list;
> 
> 
> //Ignore Exception here
> if (null != newExchange.getException()) {
> return oldExchange;
> }
> 
> //First Exchange to aggregate
> if (null == oldExchange) {
> list = new ArrayList<>(newBody);
> newExchange.getIn().setBody(list);
> return newExchange;
> } else {
> list = oldExchange.getIn().getBody(ArrayList.class);
> list.addAll(newBody);
> 

Re: Aggregation mystery - ClassCastException on same class

2020-03-25 Thread Mikael Andersson Wigander
Sorry

Camel 2.25.0
Spring Boot 2.1.9.RELEASE


M

> On 25 Mar 2020, at 08:47, Claus Ibsen  wrote:
> 
> Hi
> 
> What Camel version are you using? And what runtime do you use, karaf, spring 
> boot or something else?
> 
> 
> On Wed, Mar 25, 2020 at 8:23 AM Mikael Andersson Wigander 
> mailto:mikael.grevs...@gmail.com>> wrote:
> TL;DR
> 
> We have a very interesting mystery in one of our Camel applications.
> 
> We have a route where we aggregate incoming messages.
> The messages are first unmarshalled from a JSON String to a Map Object> and then processed thru a model ending up with a POJO of “Gateway 
> objects".
> This POJO is then aggregated in a List. The POJO implements 
> Serializable and has equals() and hash.
> 
> The aggregationStrategy is from the example in documentation when wanting to 
> aggregate a List…
> 
> LevelDB is used for persistance Repository
> 
> When flushed we process the Exchange and starts looping using a for-loop 
> 
> final List body=exchange.getIn().getBody(List.class);
> boolean hasObject=false;
> for(Gateway s:body){
> final InvestmentFirm investmentFirm=s.getInvestmentFirm();
> if(null!=investmentFirm){
> if(StringUtils.isNoneBlank(investmentFirm.getExternalId())){
> hasObject=true;
> break;
> }
> }
> }
> 
> The thing is where we get an Exception at the start of the for-loop, saying :
> 
> java.lang.ClassCastException: se.tradechannel.mifid.gateway.model.Gateway 
> cannot be cast to se.tradechannel.mifid.gateway.model.Gateway
> 
> I have debugged the code and the outcome of the aggregation is a 
> List but when starting to loop we get the exception
> 
> 
> 
> And if we step here it will crash.
> 
> We have refactored the aggregation for this route; previously we unmarshalled 
> the incoming JSON string to a Map and aggregated this in a 
> List but here we use Object as the datatype. After flushing we execute the 
> same logic with the for-loop and it runs fine…
> 
> Below is a snippet of the code 
> 
> public void configure() throws Exception {
> final DefaultAggregateController defaultAggregateController = new 
> DefaultAggregateController();
> 
> final LevelDBAggregationRepository shuttleRepo = new 
> LevelDBAggregationRepository("shuttleArt26",
> "mifir/data/shuttle/article26.dat");
> 
> 
> //tag::route[]
> from("{{shuttle.jms.incoming}}")
> .unmarshal().json(JsonLibrary.Jackson, true)
> .process(this::createShuttleObject)
> .aggregate(constant(true), new ArrayListAggregationStrategy())
> .aggregateController(defaultAggregateController)
> .aggregationRepository(shuttleRepo)
> .parallelProcessing(false)
> .completionSize(aggregation_size)
> .stopOnException()
> .to("direct:investmentFirm")
> 
> .end();
> 
> 
> from("direct:investmentFirm")
> .choice()
> .when(exchange -> { //<.>
> final List body = 
> exchange.getIn().getBody(List.class);
> boolean hasObject = false;
> for (Gateway s : body) {
> final InvestmentFirm investmentFirm = 
> s.getInvestmentFirm();
> if (null != investmentFirm) {
> if 
> (StringUtils.isNoneBlank(investmentFirm.getExternalId())) {
> hasObject = true;
> break;
> }
> }
> }
> log.debug("InvestmentFirms = " + hasObject);
> return hasObject;
> })
> .end();
> 
> }
> public class ArrayListAggregationStrategy implements AggregationStrategy {
> public Exchange aggregate(Exchange oldExchange, Exchange newExchange) {
> List newBody = newExchange.getIn().getBody(ArrayList.class);
> List list;
> 
> 
> //Ignore Exception here
> if (null != newExchange.getException()) {
> return oldExchange;
> }
> 
> //First Exchange to aggregate
> if (null == oldExchange) {
> list = new ArrayList<>(newBody);
> newExchange.getIn().setBody(list);
> return newExchange;
> } else {
> list = oldExchange.getIn().getBody(ArrayList.class);
> list.addAll(newBody);
> oldExchange.getIn().setBody(list);
> return oldExchange;
> }
> }
> }
> 
> 
> 
> 
> We really can’t see what the heck is going on, it seems OK everything but 
> "the computer says No!”
> 
> Anyone?
> 
> Thx
> 
> M
> 
> 
> -- 
> Claus Ibsen
> -
> http://davsclaus.com  @davsclaus
> Camel in Action 2: https://www.manning.com/ibsen2 
> 


Re: Aggregation mystery - ClassCastException on same class

2020-03-25 Thread Maria Arias de Reyna Dominguez
Hi,

A very very wild guess: could it be a problem with dependencies so you have
on your classpath two versions of the same class? The JVM should choose
only one of them and use it, but to me it is clear it doesn't think that
the first "se.tradechannel.mifid.gateway.model.Gateway" is the same as the
latter "se.tradechannel.mifid.gateway.model.Gateway". So there must be two
versions of it somewhere.

On Wed, Mar 25, 2020 at 8:30 AM Mikael Andersson Wigander <
mikael.grevs...@gmail.com> wrote:

> TL;DR
>
> We have a very interesting mystery in one of our Camel applications.
>
> We have a route where we aggregate incoming messages.
> The messages are first unmarshalled from a JSON String to a Map Object> and then processed thru a model ending up with a POJO of “Gateway
> objects".
> This POJO is then aggregated in a List. The POJO implements
> Serializable and has equals() and hash.
>
> The aggregationStrategy is from the example in documentation when wanting
> to aggregate a List…
>
> LevelDB is used for persistance Repository
>
> When flushed we process the Exchange and starts looping using a for-loop
>
> final List body=exchange.getIn().getBody(List.class);
> boolean hasObject=false;
> for(Gateway s:body){
> final InvestmentFirm investmentFirm=s.getInvestmentFirm();
> if(null!=investmentFirm){
> if(StringUtils.isNoneBlank(investmentFirm.getExternalId())){
> hasObject=true;
> break;
> }
> }
> }
>
>
> The thing is where we get an Exception at the start of the for-loop,
> saying :
>
> java.lang.ClassCastException: se.tradechannel.mifid.gateway.model.Gateway
> cannot be cast to se.tradechannel.mifid.gateway.model.Gateway
>
> I have debugged the code and the outcome of the aggregation is a
> List but when starting to loop we get the exception
>
>
> And if we step here it will crash.
>
> We have refactored the aggregation for this route; previously we
> unmarshalled the incoming JSON string to a Map and
> aggregated this in a List but here we use Object as the datatype. After
> flushing we execute the same logic with the for-loop and it runs fine…
>
> Below is a snippet of the code
>
> public void configure() throws Exception {
> final DefaultAggregateController defaultAggregateController = new 
> DefaultAggregateController();
>
> final LevelDBAggregationRepository shuttleRepo = new 
> LevelDBAggregationRepository("shuttleArt26",
> "mifir/data/shuttle/article26.dat");
>
>
> //tag::route[]
> from("{{shuttle.jms.incoming}}")
> .unmarshal().json(JsonLibrary.Jackson, true)
> .process(this::createShuttleObject)
> .aggregate(constant(true), new ArrayListAggregationStrategy())
> .aggregateController(defaultAggregateController)
> .aggregationRepository(shuttleRepo)
> .parallelProcessing(false)
> .completionSize(aggregation_size)
> .stopOnException()
> .to("direct:investmentFirm")
>
> .end();
>
>
> from("direct:investmentFirm")
> .choice()
> .when(exchange -> { //<.>
> final List body = 
> exchange.getIn().getBody(List.class);
> boolean hasObject = false;
> for (Gateway s : body) {
> final InvestmentFirm investmentFirm = 
> s.getInvestmentFirm();
> if (null != investmentFirm) {
> if 
> (StringUtils.isNoneBlank(investmentFirm.getExternalId())) {
> hasObject = true;
> break;
> }
> }
> }
> log.debug("InvestmentFirms = " + hasObject);
> return hasObject;
> })
> .end();
>
> }
>
> public class ArrayListAggregationStrategy implements AggregationStrategy {
> public Exchange aggregate(Exchange oldExchange, Exchange newExchange) {
> List newBody = newExchange.getIn().getBody(ArrayList.class);
> List list;
>
>
> //Ignore Exception here
> if (null != newExchange.getException()) {
> return oldExchange;
> }
>
> //First Exchange to aggregate
> if (null == oldExchange) {
> list = new ArrayList<>(newBody);
> newExchange.getIn().setBody(list);
> return newExchange;
> } else {
> list = oldExchange.getIn().getBody(ArrayList.class);
> list.addAll(newBody);
> oldExchange.getIn().setBody(list);
> return oldExchange;
> }
> }
> }
>
>
>
>
>
> We really can’t see what the heck is going on, it seems OK everything but
> "the computer says No!”
>
> Anyone?
>
> Thx
>
> M
>


Re: Aggregation mystery - ClassCastException on same class

2020-03-25 Thread Claus Ibsen
Hi

What Camel version are you using? And what runtime do you use, karaf,
spring boot or something else?


On Wed, Mar 25, 2020 at 8:23 AM Mikael Andersson Wigander <
mikael.grevs...@gmail.com> wrote:

> TL;DR
>
> We have a very interesting mystery in one of our Camel applications.
>
> We have a route where we aggregate incoming messages.
> The messages are first unmarshalled from a JSON String to a Map Object> and then processed thru a model ending up with a POJO of “Gateway
> objects".
> This POJO is then aggregated in a List. The POJO implements
> Serializable and has equals() and hash.
>
> The aggregationStrategy is from the example in documentation when wanting
> to aggregate a List…
>
> LevelDB is used for persistance Repository
>
> When flushed we process the Exchange and starts looping using a for-loop
>
> final List body=exchange.getIn().getBody(List.class);
> boolean hasObject=false;
> for(Gateway s:body){
> final InvestmentFirm investmentFirm=s.getInvestmentFirm();
> if(null!=investmentFirm){
> if(StringUtils.isNoneBlank(investmentFirm.getExternalId())){
> hasObject=true;
> break;
> }
> }
> }
>
>
> The thing is where we get an Exception at the start of the for-loop,
> saying :
>
> java.lang.ClassCastException: se.tradechannel.mifid.gateway.model.Gateway
> cannot be cast to se.tradechannel.mifid.gateway.model.Gateway
>
> I have debugged the code and the outcome of the aggregation is a
> List but when starting to loop we get the exception
>
>
> And if we step here it will crash.
>
> We have refactored the aggregation for this route; previously we
> unmarshalled the incoming JSON string to a Map and
> aggregated this in a List but here we use Object as the datatype. After
> flushing we execute the same logic with the for-loop and it runs fine…
>
> Below is a snippet of the code
>
> public void configure() throws Exception {
> final DefaultAggregateController defaultAggregateController = new 
> DefaultAggregateController();
>
> final LevelDBAggregationRepository shuttleRepo = new 
> LevelDBAggregationRepository("shuttleArt26",
> "mifir/data/shuttle/article26.dat");
>
>
> //tag::route[]
> from("{{shuttle.jms.incoming}}")
> .unmarshal().json(JsonLibrary.Jackson, true)
> .process(this::createShuttleObject)
> .aggregate(constant(true), new ArrayListAggregationStrategy())
> .aggregateController(defaultAggregateController)
> .aggregationRepository(shuttleRepo)
> .parallelProcessing(false)
> .completionSize(aggregation_size)
> .stopOnException()
> .to("direct:investmentFirm")
>
> .end();
>
>
> from("direct:investmentFirm")
> .choice()
> .when(exchange -> { //<.>
> final List body = 
> exchange.getIn().getBody(List.class);
> boolean hasObject = false;
> for (Gateway s : body) {
> final InvestmentFirm investmentFirm = 
> s.getInvestmentFirm();
> if (null != investmentFirm) {
> if 
> (StringUtils.isNoneBlank(investmentFirm.getExternalId())) {
> hasObject = true;
> break;
> }
> }
> }
> log.debug("InvestmentFirms = " + hasObject);
> return hasObject;
> })
> .end();
>
> }
>
> public class ArrayListAggregationStrategy implements AggregationStrategy {
> public Exchange aggregate(Exchange oldExchange, Exchange newExchange) {
> List newBody = newExchange.getIn().getBody(ArrayList.class);
> List list;
>
>
> //Ignore Exception here
> if (null != newExchange.getException()) {
> return oldExchange;
> }
>
> //First Exchange to aggregate
> if (null == oldExchange) {
> list = new ArrayList<>(newBody);
> newExchange.getIn().setBody(list);
> return newExchange;
> } else {
> list = oldExchange.getIn().getBody(ArrayList.class);
> list.addAll(newBody);
> oldExchange.getIn().setBody(list);
> return oldExchange;
> }
> }
> }
>
>
>
>
>
> We really can’t see what the heck is going on, it seems OK everything but
> "the computer says No!”
>
> Anyone?
>
> Thx
>
> M
>


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


Aggregation mystery - ClassCastException on same class

2020-03-25 Thread Mikael Andersson Wigander
TL;DR

We have a very interesting mystery in one of our Camel applications.

We have a route where we aggregate incoming messages.
The messages are first unmarshalled from a JSON String to a Map 
and then processed thru a model ending up with a POJO of “Gateway objects".
This POJO is then aggregated in a List. The POJO implements 
Serializable and has equals() and hash.

The aggregationStrategy is from the example in documentation when wanting to 
aggregate a List…

LevelDB is used for persistance Repository

When flushed we process the Exchange and starts looping using a for-loop 

final List body=exchange.getIn().getBody(List.class);
boolean hasObject=false;
for(Gateway s:body){
final InvestmentFirm investmentFirm=s.getInvestmentFirm();
if(null!=investmentFirm){
if(StringUtils.isNoneBlank(investmentFirm.getExternalId())){
hasObject=true;
break;
}
}
}

The thing is where we get an Exception at the start of the for-loop, saying :

java.lang.ClassCastException: se.tradechannel.mifid.gateway.model.Gateway 
cannot be cast to se.tradechannel.mifid.gateway.model.Gateway

I have debugged the code and the outcome of the aggregation is a List 
but when starting to loop we get the exception



And if we step here it will crash.

We have refactored the aggregation for this route; previously we unmarshalled 
the incoming JSON string to a Map and aggregated this in a List 
but here we use Object as the datatype. After flushing we execute the same 
logic with the for-loop and it runs fine…

Below is a snippet of the code 

public void configure() throws Exception {
final DefaultAggregateController defaultAggregateController = new 
DefaultAggregateController();

final LevelDBAggregationRepository shuttleRepo = new 
LevelDBAggregationRepository("shuttleArt26",
"mifir/data/shuttle/article26.dat");


//tag::route[]
from("{{shuttle.jms.incoming}}")
.unmarshal().json(JsonLibrary.Jackson, true)
.process(this::createShuttleObject)
.aggregate(constant(true), new ArrayListAggregationStrategy())
.aggregateController(defaultAggregateController)
.aggregationRepository(shuttleRepo)
.parallelProcessing(false)
.completionSize(aggregation_size)
.stopOnException()
.to("direct:investmentFirm")

.end();


from("direct:investmentFirm")
.choice()
.when(exchange -> { //<.>
final List body = exchange.getIn().getBody(List.class);
boolean hasObject = false;
for (Gateway s : body) {
final InvestmentFirm investmentFirm = s.getInvestmentFirm();
if (null != investmentFirm) {
if 
(StringUtils.isNoneBlank(investmentFirm.getExternalId())) {
hasObject = true;
break;
}
}
}
log.debug("InvestmentFirms = " + hasObject);
return hasObject;
})
.end();

}
public class ArrayListAggregationStrategy implements AggregationStrategy {
public Exchange aggregate(Exchange oldExchange, Exchange newExchange) {
List newBody = newExchange.getIn().getBody(ArrayList.class);
List list;


//Ignore Exception here
if (null != newExchange.getException()) {
return oldExchange;
}

//First Exchange to aggregate
if (null == oldExchange) {
list = new ArrayList<>(newBody);
newExchange.getIn().setBody(list);
return newExchange;
} else {
list = oldExchange.getIn().getBody(ArrayList.class);
list.addAll(newBody);
oldExchange.getIn().setBody(list);
return oldExchange;
}
}
}




We really can’t see what the heck is going on, it seems OK everything but "the 
computer says No!”

Anyone?

Thx

M

Re: Testing Route in camel-quarkus

2020-03-25 Thread Dennis Holunder
I could create a quarkus test where the route is injected and external
endpoint is mocked with quarkus mock support.

Am Fr., 20. März 2020 um 11:52 Uhr schrieb Dennis Holunder
:
>
> Hello,
>
> is it possible to test a non-http route in camel-quarkus like we do
> with CamelTestSupport in camel?
>
> Thanks!