You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@camel.apache.org by Christian Jacob <cj...@aol.com> on 2013/04/23 23:10:32 UTC
Re: JPA Component Behavior
Hi Claus,I'm very eager to get that feature, too. My requirements for a new
project are:
run on every 1st of a month (or some other Quartz clause) and then select
all objects with status = 0
have a user interface for an administrator in which he/she can customize
some search arguments such as a time range in which a JPA object was
created, different values for the status field, and so on. I'm surely fit
enough to deliver such a UI, e.g. as JEE2. From that UI, I can produce a
route with customized query criteria. But the point is: how do I make the
JPA consumer run on a button click?
In my opinion, scheduled poll consuming is not the only sceanrio in which
database or JPA retrieval is required. Do you see a way with which I can
achieve that? Or do I have to wait?
--
View this message in context: http://camel.465427.n5.nabble.com/JPA-Component-Behavior-tp5725781p5731377.html
Sent from the Camel - Users mailing list archive at Nabble.com.
Re: JPA Component Behavior
Posted by Chris Wolf <cw...@gmail.com>.
If you look back at the entire thread:
http://camel.465427.n5.nabble.com/JPA-Component-Behavior-td5725781.html#a5731377
You can see that I solved this requirement by implementing a custom
PollingConsumerPollStrategy
called you use that plus configure the JPA consumer with "startScheduler=false"
Then, from your actionPerformed button code, or whatever code needs to trigger
the JPA poll, call a function with this code:
JpaConsumer jpaConsumer = null;
Route route = ctx.getRoute(routeId);
if (route == null) {
log.error("No route found with id \"{}\"", routeId);
return;
}
if ( ! (route.getConsumer() instanceof JpaConsumer)) {
log.error("Consumer must be of type JpaConsumer, the
configured consumer is of type {}",
route.getConsumer().getClass().getName());
return;
}
try {
if (jpaConsumer.isSuspended() || jpaConsumer.isSuspending()) {
jpaConsumer.resume();
} else {
// first time here - need to start scheduler
// why is startScheduler() "protected" - can't it be "public"?
Class<?> superClass = jpaConsumer.getClass().getSuperclass();
superClass = superClass.getSuperclass();
Method m = superClass.getDeclaredMethod("startScheduler",
(Class<?>[]) null);
m.setAccessible(true);
m.invoke(jpaConsumer, (Object[]) null);
}
} catch (Exception e1) {
e1.printStackTrace();
}
This is working fine for my use-case which is the same as yours...
Regards,
Chris
On Tue, Apr 23, 2013 at 5:10 PM, Christian Jacob <cj...@aol.com> wrote:
> Hi Claus,I'm very eager to get that feature, too. My requirements for a new
> project are:
> run on every 1st of a month (or some other Quartz clause) and then select
> all objects with status = 0
> have a user interface for an administrator in which he/she can customize
> some search arguments such as a time range in which a JPA object was
> created, different values for the status field, and so on. I'm surely fit
> enough to deliver such a UI, e.g. as JEE2. From that UI, I can produce a
> route with customized query criteria. But the point is: how do I make the
> JPA consumer run on a button click?
> In my opinion, scheduled poll consuming is not the only sceanrio in which
> database or JPA retrieval is required. Do you see a way with which I can
> achieve that? Or do I have to wait?
>
>
>
> --
> View this message in context: http://camel.465427.n5.nabble.com/JPA-Component-Behavior-tp5725781p5731377.html
> Sent from the Camel - Users mailing list archive at Nabble.com.