shutdown strategy is set on context level / way of route level?

2017-07-26 Thread onders
Hi,

As per my understanding, shutdown strategy is set per camelcontext.
Is there a way / other ways where we can apply shutdown strategy or custom
shutdown implementation per route(s) in a camel context?

In my use case, i have number of events stored in database already. In order
to avoid reprocessing a single event multiple times, i use onConsume option
in sql component and mark their status e.g status=1 meaning 'processing'
where initially records were in the db with status=0 meaning 'initial'. What
i want to do is that when the PID of my camel context and routes is signaled
like 'kill -9 ', i want to reset the status of records back to status=0
'initial' in order not to miss processing those records when the process is
restarted.

Or is there any other way doing what i want to achieve?

Thanks 




--
View this message in context: 
http://camel.465427.n5.nabble.com/shutdown-strategy-is-set-on-context-level-way-of-route-level-tp5808094.html
Sent from the Camel - Users mailing list archive at Nabble.com.


Re: enrich EIP with sql component

2017-07-07 Thread onders
This route is working correctly.
There is a datatype issue for date fields for sql component. but i am sure
there is not an easy way to fix it.
because sql component may be running for different vendor.
for keeping simple i converted date datatype to string representation by
using sql features.

for your information for future reference.

Regards



--
View this message in context: 
http://camel.465427.n5.nabble.com/enrich-EIP-with-sql-component-tp5806575p5806578.html
Sent from the Camel - Users mailing list archive at Nabble.com.


enrich EIP with sql component

2017-07-07 Thread onders
Hi,

I have a route as below;

from("seda:A?concurrentConsumers=2")
 .enrich("sql:select X from test_table where id =
:#${body.getId}?outputClass="
+ MyX.class.getName()", new 
AggregationStrategy() {

@Override
public Exchange aggregate(Exchange oldExchange, Exchange newExchange) {
if( newExchange == null) {
return oldExchange;
}

MyX x = newExchange.getIn().getBody(MyX.class);

SimplePojo sPojo = 
oldExchange.getIn().getBody(SimplePojo.class);

sPojo.setX(x.getX());

oldExchange.getIn().setBody(sPojo);

return oldExchange;
}
}).
.to("sql:update PojoTable set status = :#${body.getStatus} where id =
:#${body.getId}");


I am not sure why but during aggregation
newExchange.getIn().getBody(MyX.class) ends up with null resultset like
enrich has not run at all.

Am i missing something? Or enrich EIP does not work with sql component like
this?

Cheers





--
View this message in context: 
http://camel.465427.n5.nabble.com/enrich-EIP-with-sql-component-tp5806575.html
Sent from the Camel - Users mailing list archive at Nabble.com.


SQL component - comparing consumer against database

2017-07-07 Thread onders
Hello,

I want to ask you question about a design choice. (maybe there is an
existing EIP / composite EIPS together out of box, which i am not already
familiar ) 

Think of you have X number of rows in a table. (which will continuosly get
new rows)
And you want to consume every row in that table and decide which message
really needs to processed based on a certain column.
(This requires filtering) and save in a another table. 
Additionally you want to make sure in the second table (where you keep rows
to be further processed) where you always  have the (let's say the latest
row which is based on its timestamp column) latest row.

I would guess i need to implement something like idempotent consumer EIP in
which i need to insert & update (which is like merge in PLSQL - assuming we
have Oracle backend) for the records in the second table(which is my
repository and final table holding all the latest records).

I can see 
- Idempotent Consumer EIP
- Selective Consumer EIP 

which are not i can use directly out of box.

Is there an EIP or composite EIPs to achieve something similar (like
Comparing Consumer Against Repository which i named it bogusly)?

And could you think of a way not doing too many queries or updates to second
table considering performance?

Thanks in advance.  



--
View this message in context: 
http://camel.465427.n5.nabble.com/SQL-component-comparing-consumer-against-database-tp5806564.html
Sent from the Camel - Users mailing list archive at Nabble.com.


Re: Camel CXF Simple Frontend warning

2017-07-03 Thread onders
please see the methods 

createClientFactory[1], in CxfEndpoint or CxfSpringEndpoint classes.

I think based on your client stubs, Camel creates instances of client stub
objects, so i suppose this depends and client stub classes and your
configuration.

[1] 
https://github.com/apache/camel/blob/master/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/CxfEndpoint.java#L393

  




--
View this message in context: 
http://camel.465427.n5.nabble.com/Camel-CXF-Simple-Frontend-warning-tp5805214p5805689.html
Sent from the Camel - Users mailing list archive at Nabble.com.


split by byte chunks

2017-05-30 Thread onders
Hi,

Split eip supports tokenizing by a delimiter and grouping as below;

from("file:inbox")
  .split().tokenize("\n", 1000).streaming()
 .to("activemq:queue:order");

Is there a specific reason why we don't have such like.

from("file:inbox")
  .split().tokenizeByByteSize(1024, 1000).streaming()
 .to("activemq:queue:order");

where 1024 is a length of byte to read from input stream?

Cheers
Onder



--
View this message in context: 
http://camel.465427.n5.nabble.com/split-by-byte-chunks-tp5801398.html
Sent from the Camel - Users mailing list archive at Nabble.com.


Re: Aggregator + (LevelDB or HawtDB for persistency) incorrect behavior

2016-11-07 Thread onders
btw, i tried both leveldb and hawtdb as aggregationrepository.

  
  






  


or














--
View this message in context: 
http://camel.465427.n5.nabble.com/Aggregator-LevelDB-or-HawtDB-for-persistency-incorrect-behavior-tp5765524p5789837.html
Sent from the Camel - Users mailing list archive at Nabble.com.


Re: Aggregator + (LevelDB or HawtDB for persistency) incorrect behavior

2016-11-07 Thread onders
Hi,

I am usign all camel core and components as of 2.17.3.
This issue seems to be still up.

Under examples/camel-example-aggregator i can test it is working.

as of route below; aggregation is not completed and not output file is
getting generated. (btw, if i do aggregate without persistence, it is
working.)

from("amq:queue:jms.myqueue")
.startupOrder(initialStartupOrder)
.shutdownRoute(ShutdownRoute.Defer)

.aggregate(simple(myId.toString()),
new AggregationStrategy() {

@Override
public Exchange 
aggregate(Exchange oldExchange, Exchange
newExchange) {
if (oldExchange 
== null) {

newExchange.getIn().setBody(new
StringBuilder(newExchange.getIn().getBody(MyObject.class).asLine("|")));
return 
newExchange;
}

oldExchange.getIn().getBody(StringBuilder.class).append(newExchange.getIn().getBody(MyObject.class).asLine("|"));
return 
oldExchange;
}
})
.eagerCheckCompletion()
.forceCompletionOnStop()
.completeAllOnStop()
.completionSize(500)
.completionInterval(6)
.parallelProcessing(true)
.aggregationRepository(myRepo)
.to("file:myfile");



--
View this message in context: 
http://camel.465427.n5.nabble.com/Aggregator-LevelDB-or-HawtDB-for-persistency-incorrect-behavior-tp5765524p5789810.html
Sent from the Camel - Users mailing list archive at Nabble.com.


Re: CacheProducer requiring the same config params in java dsl

2016-08-08 Thread onders
any idea?



--
View this message in context: 
http://camel.465427.n5.nabble.com/CacheProducer-requiring-the-same-config-params-in-java-dsl-tp5786061p5786180.html
Sent from the Camel - Users mailing list archive at Nabble.com.


CacheProducer requiring the same config params in java dsl

2016-08-05 Thread onders
One of my friend is having such an issue as stated on stackoverflow.

Does anyone have an idea?

http://stackoverflow.com/questions/37488705/apache-camel-cache-configuration-is-not-working/38728611#38728611

Thx



--
View this message in context: 
http://camel.465427.n5.nabble.com/CacheProducer-requiring-the-same-config-params-in-java-dsl-tp5786061.html
Sent from the Camel - Users mailing list archive at Nabble.com.


Re: Camel FTP design issue

2016-06-19 Thread onders
i would expect the latter one as far i understand. 
test routes of these 3 steps would make it  more clear



--
View this message in context: 
http://camel.465427.n5.nabble.com/Camel-FTP-design-issue-tp5784192p5784193.html
Sent from the Camel - Users mailing list archive at Nabble.com.


Re: ConcurrentModificationException during route listing

2016-05-18 Thread onders
ConcurrentModificationException happens to be due the fact that you are
trying to modify the collection whereas you are traversing it.
It's hard to help you unless we know some details of design of your route.
If you can provide details, we can give it a shot..



--
View this message in context: 
http://camel.465427.n5.nabble.com/ConcurrentModificationException-during-route-listing-tp5782525p5782737.html
Sent from the Camel - Users mailing list archive at Nabble.com.


Re: DefaultSqlPrepareStatementStrategy lookupParameter when onConsume used in SQL component

2016-04-07 Thread onders
thanks for the guidance.



--
View this message in context: 
http://camel.465427.n5.nabble.com/DefaultSqlPrepareStatementStrategy-lookupParameter-when-onConsume-used-in-SQL-component-tp5780437p5780671.html
Sent from the Camel - Users mailing list archive at Nabble.com.


Re: DefaultSqlPrepareStatementStrategy lookupParameter when onConsume used in SQL component

2016-04-07 Thread onders
Hmm.. I think i misunderstood the route conceptually.

What i thought was that below is a single route;

from("sql:select rowid vrowid from myTable where nstatus = 0?outputClass=" +
MyBean.class.getName() 
+ "=update myTable set nstatus = 1 where rowid =
:#${body.getVrowid()}") 
   
.routeId("mySimpleRoute").threads(5).to("direct:generateLine").end(); 


and the exchange becomes complete when we do 

...
...
// piece of code above
.to("direct:generateLine").end();

and another route is 

from("direct:generateLine").process(new
LineGenerator()).to("amq:queue:jms.simpleQueue");

So i expected onConsume receives MyBean as the body of exchange;
But you are saying that exhange is complete after this line

>> from("direct:generateLine").process(new
>> LineGenerator()).to("amq:queue:jms.simpleQueue");

so onConsume receives whatever is set as the body of exchange in the
instance of LineGenerator.

I think i am confused?

Could you please help me understand what makes up the route?

Regards
Önder








--
View this message in context: 
http://camel.465427.n5.nabble.com/DefaultSqlPrepareStatementStrategy-lookupParameter-when-onConsume-used-in-SQL-component-tp5780437p5780663.html
Sent from the Camel - Users mailing list archive at Nabble.com.


Re: DefaultSqlPrepareStatementStrategy lookupParameter when onConsume used in SQL component

2016-04-07 Thread onders
no, this does not help :(

when i debug, interestingly i can see onConsume gets exhange's body as the
output of bean bound on from("direct:generateLine"...) route which is
LineGenerator..

from("sql:select rowid vrowid from myTable where nstatus = 0?outputClass=" +
MyBean.class.getName() 
+ "=update myTable set nstatus = 1 where rowid =
:#${body.getVrowid()}") 
   
.routeId("mySimpleRoute").threads(5).to("direct:generateLine").end(); 

from("direct:generateLine").process(new
LineGenerator()).to("amq:queue:jms.simpleQueue");

org.apache.camel.language.bean.RuntimeBeanExpressionException: Failed to
invoke method: getVrowid() on null due to:
org.apache.camel.component.bean.MethodNotFoundException: Method with name:
getVrowid() not found on bean: testField1|textField2|
 of type: java.lang.String. Exchange[]
at
org.apache.camel.language.bean.BeanExpression$OgnlInvokeProcessor.process(BeanExpression.java:321)
at
org.apache.camel.language.bean.BeanExpression.evaluate(BeanExpression.java:114)
at
org.apache.camel.language.bean.BeanExpression.evaluate(BeanExpression.java:138)
at
org.apache.camel.model.language.ExpressionDefinition.evaluate(ExpressionDefinition.java:126)
at
org.apache.camel.model.language.ExpressionDefinition.evaluate(ExpressionDefinition.java:118)
at
org.apache.camel.builder.ExpressionBuilder$34.evaluate(ExpressionBuilder.java:852)
at
org.apache.camel.support.ExpressionAdapter.evaluate(ExpressionAdapter.java:36)
at
org.apache.camel.component.sql.DefaultSqlPrepareStatementStrategy.lookupParameter(DefaultSqlPrepareStatementStrategy.java:200)
at
org.apache.camel.component.sql.DefaultSqlPrepareStatementStrategy$PopulateIterator.next(DefaultSqlPrepareStatementStrategy.java:267)
at
org.apache.camel.component.sql.DefaultSqlPrepareStatementStrategy.populateStatement(DefaultSqlPrepareStatementStrategy.java:129)
at
org.apache.camel.component.sql.DefaultSqlProcessingStrategy$1.doInPreparedStatement(DefaultSqlProcessingStrategy.java:52)
at
org.apache.camel.component.sql.DefaultSqlProcessingStrategy$1.doInPreparedStatement(DefaultSqlProcessingStrategy.java:46)
at
org.springframework.jdbc.core.JdbcTemplate.execute(JdbcTemplate.java:629)
at
org.springframework.jdbc.core.JdbcTemplate.execute(JdbcTemplate.java:658)
at
org.apache.camel.component.sql.DefaultSqlProcessingStrategy.commit(DefaultSqlProcessingStrategy.java:46)
at
org.apache.camel.component.sql.SqlConsumer.processBatch(SqlConsumer.java:240)
at
org.apache.camel.component.sql.SqlConsumer$1.doInPreparedStatement(SqlConsumer.java:137)
at
org.apache.camel.component.sql.SqlConsumer$1.doInPreparedStatement(SqlConsumer.java:110)
at
org.springframework.jdbc.core.JdbcTemplate.execute(JdbcTemplate.java:629)
at
org.springframework.jdbc.core.JdbcTemplate.execute(JdbcTemplate.java:658)
at
org.apache.camel.component.sql.SqlConsumer.poll(SqlConsumer.java:149)
at
org.apache.camel.impl.ScheduledPollConsumer.doRun(ScheduledPollConsumer.java:175)
at
org.apache.camel.impl.ScheduledPollConsumer.run(ScheduledPollConsumer.java:102)
at
java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:471)
at java.util.concurrent.FutureTask.runAndReset(FutureTask.java:304)
at
java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$301(ScheduledThreadPoolExecutor.java:178)
at
java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:293)
at
java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
at
java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
at java.lang.Thread.run(Thread.java:744)
Caused by: org.apache.camel.component.bean.MethodNotFoundException: Method
with name: getVrowid() not found on bean: testField1|textField2|
 of type: java.lang.String. Exchange[]
at
org.apache.camel.component.bean.BeanInfo.createInvocation(BeanInfo.java:271)
at
org.apache.camel.component.bean.BeanInfo.createInvocation(BeanInfo.java:185)
at
org.apache.camel.component.bean.BeanProcessor.process(BeanProcessor.java:159)
at
org.apache.camel.util.AsyncProcessorHelper.process(AsyncProcessorHelper.java:109)
at
org.apache.camel.component.bean.BeanProcessor.process(BeanProcessor.java:68)
at
org.apache.camel.language.bean.BeanExpression$InvokeProcessor.process(BeanExpression.java:211)
at
org.apache.camel.language.bean.BeanExpression$OgnlInvokeProcessor.process(BeanExpression.java:317)



--
View this message in context: 
http://camel.465427.n5.nabble.com/DefaultSqlPrepareStatementStrategy-lookupParameter-when-onConsume-used-in-SQL-component-tp5780437p5780645.html
Sent from the Camel - Users mailing list archive at Nabble.com.


Re: DefaultSqlPrepareStatementStrategy lookupParameter when onConsume used in SQL component

2016-04-06 Thread onders
Here it is;

import java.io.Serializable;

public class MyBean implements Serializable {

/**
 * 
 */
private static final long serialVersionUID = 1L;
private String vrow_id;

public String getVrow_id() {
return vrow_id;
}
public void setVrow_id(String vrow_id) {
this.vrow_id = vrow_id;
}

}




--
View this message in context: 
http://camel.465427.n5.nabble.com/DefaultSqlPrepareStatementStrategy-lookupParameter-when-onConsume-used-in-SQL-component-tp5780437p5780629.html
Sent from the Camel - Users mailing list archive at Nabble.com.


Re: DefaultSqlPrepareStatementStrategy lookupParameter when onConsume used in SQL component

2016-04-06 Thread onders
I think the code snippet i sent earlier had outputClass option missing.
(I was playing it around).

So what i meant to describe was as the following...

from("sql:select rowid vrow_id from myTable where nstatus =
0?*outputClass=" + MyBean.class.getName() 
+ "*=update myTable set nstatus = 1 where VROW_ID
= :#${body.vrow_id}") 
   
.routeId("mySimpleRoute").threads(5).to("direct:generateLine").end(); 




--
View this message in context: 
http://camel.465427.n5.nabble.com/DefaultSqlPrepareStatementStrategy-lookupParameter-when-onConsume-used-in-SQL-component-tp5780437p5780627.html
Sent from the Camel - Users mailing list archive at Nabble.com.


Re: DefaultSqlPrepareStatementStrategy lookupParameter when onConsume used in SQL component

2016-04-06 Thread onders
Hi,

This is the route code.

from("sql:select rowid vrow_id from myTable where nstatus = 0" +
MyBean.class.getName()
+ "=update myTable set nstatus = 1 
where VROW_ID =
:#${body.vrow_id}")

.routeId("mySimpleRoute").threads(5).to("direct:generateLine").end();


In the following from("direct:generateLine"), I apply bean-binding and send
myBean.toString() to a file...

Thanks again 



--
View this message in context: 
http://camel.465427.n5.nabble.com/DefaultSqlPrepareStatementStrategy-lookupParameter-when-onConsume-used-in-SQL-component-tp5780437p5780624.html
Sent from the Camel - Users mailing list archive at Nabble.com.


Re: DefaultSqlPrepareStatementStrategy lookupParameter when onConsume used in SQL component

2016-04-06 Thread onders
Did anybody have a chance to look at it?

Regards
Önder



--
View this message in context: 
http://camel.465427.n5.nabble.com/DefaultSqlPrepareStatementStrategy-lookupParameter-when-onConsume-used-in-SQL-component-tp5780437p5780585.html
Sent from the Camel - Users mailing list archive at Nabble.com.


DefaultSqlPrepareStatementStrategy lookupParameter when onConsume used in SQL component

2016-04-04 Thread onders
Hi,

I have a simple route as the following;

from("sql:select rowid vrow_id from myTable where nstatus = 0" +
MyBean.class.getName()
+ "=update myTable set nstatus = 1 
where VROW_ID =
:#${body.vrow_id}")
.routeId("mySimpleRoute")

.threads(5).to("direct:generateLine")
.end();

When i run such route, onConsume fails to update the row by giving the
stacktrace below;

(Please note that MyBean has the right attributes and setters and getters..)

org.apache.camel.language.bean.RuntimeBeanExpressionException: Failed to
invoke method: vrow_id on null due to:
org.apache.camel.component.bean.MethodNotFoundException: Method with name:
vrow_id not found on bean: MyBean[vrow_id=AAAGsJAAEAAApayAAE]
 of type: java.lang.String. Exchange[]
at
org.apache.camel.language.bean.BeanExpression$OgnlInvokeProcessor.process(BeanExpression.java:321)
at
org.apache.camel.language.bean.BeanExpression.evaluate(BeanExpression.java:114)
at
org.apache.camel.language.bean.BeanExpression.evaluate(BeanExpression.java:138)
at
org.apache.camel.model.language.ExpressionDefinition.evaluate(ExpressionDefinition.java:126)
at
org.apache.camel.model.language.ExpressionDefinition.evaluate(ExpressionDefinition.java:118)
at
org.apache.camel.builder.ExpressionBuilder$34.evaluate(ExpressionBuilder.java:852)
at
org.apache.camel.support.ExpressionAdapter.evaluate(ExpressionAdapter.java:36)
at
org.apache.camel.component.sql.DefaultSqlPrepareStatementStrategy.lookupParameter(DefaultSqlPrepareStatementStrategy.java:200)
at
org.apache.camel.component.sql.DefaultSqlPrepareStatementStrategy$PopulateIterator.next(DefaultSqlPrepareStatementStrategy.java:267)
at
org.apache.camel.component.sql.DefaultSqlPrepareStatementStrategy.populateStatement(DefaultSqlPrepareStatementStrategy.java:129)
at
org.apache.camel.component.sql.DefaultSqlProcessingStrategy$1.doInPreparedStatement(DefaultSqlProcessingStrategy.java:52)
at
org.apache.camel.component.sql.DefaultSqlProcessingStrategy$1.doInPreparedStatement(DefaultSqlProcessingStrategy.java:46)
at
org.springframework.jdbc.core.JdbcTemplate.execute(JdbcTemplate.java:629)
at
org.springframework.jdbc.core.JdbcTemplate.execute(JdbcTemplate.java:658)
at
org.apache.camel.component.sql.DefaultSqlProcessingStrategy.commit(DefaultSqlProcessingStrategy.java:46)
at
org.apache.camel.component.sql.SqlConsumer.processBatch(SqlConsumer.java:240)
at
org.apache.camel.component.sql.SqlConsumer$1.doInPreparedStatement(SqlConsumer.java:137)
at
org.apache.camel.component.sql.SqlConsumer$1.doInPreparedStatement(SqlConsumer.java:110)
at
org.springframework.jdbc.core.JdbcTemplate.execute(JdbcTemplate.java:629)
at
org.springframework.jdbc.core.JdbcTemplate.execute(JdbcTemplate.java:658)
at
org.apache.camel.component.sql.SqlConsumer.poll(SqlConsumer.java:149)
at
org.apache.camel.impl.ScheduledPollConsumer.doRun(ScheduledPollConsumer.java:175)
at
org.apache.camel.impl.ScheduledPollConsumer.run(ScheduledPollConsumer.java:102)
at
java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:471)
at java.util.concurrent.FutureTask.runAndReset(FutureTask.java:304)
at
java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$301(ScheduledThreadPoolExecutor.java:178)
at
java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:293)
at
java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
at
java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
at java.lang.Thread.run(Thread.java:744)
Caused by: org.apache.camel.component.bean.MethodNotFoundException: Method
with name: vrow_id not found on bean: MyBean [vrow_id=AAAGsJAAEAAApayAAE]
 of type: java.lang.String. Exchange[]
at
org.apache.camel.component.bean.BeanInfo.createInvocation(BeanInfo.java:271)
at
org.apache.camel.component.bean.BeanInfo.createInvocation(BeanInfo.java:185)
at
org.apache.camel.component.bean.BeanProcessor.process(BeanProcessor.java:159)
at
org.apache.camel.util.AsyncProcessorHelper.process(AsyncProcessorHelper.java:109)
at
org.apache.camel.component.bean.BeanProcessor.process(BeanProcessor.java:68)
at
org.apache.camel.language.bean.BeanExpression$InvokeProcessor.process(BeanExpression.java:211)
at
org.apache.camel.language.bean.BeanExpression$OgnlInvokeProcessor.process(BeanExpression.java:317)
... 29 more

I tracked down the issue and found out that 

in DefaultSqlPrepareStatementStrategy class the implementation on the
following method

protected static Object lookupParameter(String