I have an application running camel on spring-boot. I want to pass a parameter retriesAllowed to a namedQuery from a camel route.
namedQuery:
@NamedQuery(name = "findFailedMessages", query = RawMessageTx.HQL_FIND_FAILED_MESSAGES)
public class RawMessageTx extends BaseEntityWithTransmitStatus implements Serializable {
public static final String HQL_FIND_FAILED_MESSAGES = "SELECT x from RawMessageTx x WHERE x.status = 'FAILED' and x.tryAgain = 1 and x.retriesAttempted <= :retriesAllowed ORDER BY x.created ";
Route:
from("seda:retry_poll_failed_messages").routeId("retry_poll_failed_messages")
.setHeader("retriesAllowed", constant(retriesAllowed))
.toF("jpa:%s?namedQuery=findFailedMessages&maximumResults=%d", RawMessageTx.class.getName(),
maxMessagesPerPollAttempt)
.split(body())
.to("direct:anotherEndpoint");
I tried different things and it does not work and I can't find a good example online on this.
This is explained in the doc of JPA component:
This means that you have to do something like:
Where "myMap" is the name of a bean of type 'java.util.Map' that is available in Camel registry.
One possible way (among others) to register such bean could be a Camel
Processor(to invoke before the jpa endpoint of course)