How to use camel JPA component on the same database with multiple servers?
<p>I am currently setting up my camel project and I can't make my JPA poller to work on several concurrent servers.</p>

<p>Here is the my camel route :</p>

<pre><code>public class TicketPoller extends RouteBuilder {

    /** The uri. */
    private final String uri = "jpa://Ticket?consumeDelete=false&amp;consumeLockEntity=true&amp;consumer.SkipLockedEntity=true&amp;consumer.query=select t from Ticket t where t.state=1";

    @Override
    public void configure() {
        from(uri).to("log:input");

    }
}
</code></pre>

<p>I use @Consumed annotation to change the ticket state when polled directly in my Hibernate entity :</p>

<pre><code>@Entity
@Table(name = "TICKET", schema = "TEIKITEL")
public class Ticket implements Serializable {

    private static final long serialVersionUID = 1L;

    @Id
    @Column(name = "TICKET_ID")
    private String ticketId;

    @Column(name = "STATE")
    private int state;

    ...

    @Consumed
    public void changeTicketState() {
        this.state = 2;
    }

    @Override
    public String toString() {
        return "Ticket@ticketId=" + this.ticketId;
    }
}
</code></pre>

<p>It works fine when I launch it on one single Tomcat server (Tomcat 8) from Eclipse.</p>

<p>But when I launch 2 servers polling on the same database I have these errors when I insert some lines in my TICKET table :</p>

<p>On my first server I can see this :</p>

<pre><code>Hibernate: select TICKET_ID from TEIKITEL.TICKET where TICKET_ID =? for update nowait
2016-04-05 15:04:56,796 INFO  [Camel (camel-1) thread #0 - jpa://com.teikitel.model.entity.Ticket] input(180) - Exchange[ExchangePattern: InOnly, BodyType: com.teikitel.model.entity.Ticket, Body: Ticket@ticketId=TICKET1]
Hibernate: select TICKET_ID from TEIKITEL.TICKET where TICKET_ID =? for update nowait
2016-04-05 15:04:56,812 INFO  [Camel (camel-1) thread #0 - jpa://com.teikitel.model.entity.Ticket] input(180) - Exchange[ExchangePattern: InOnly, BodyType: com.teikitel.model.entity.Ticket, Body: Ticket@ticketId=TICKET2]
</code></pre>

<p>On my second server :</p>

<pre><code>Hibernate: select TICKET_ID from TEIKITEL.TICKET where TICKET_ID =? for update nowait
2016-04-05 15:04:56,859 WARN  [Camel (camel-1) thread #0 - jpa://com.teikitel.model.entity.Ticket] o.h.e.j.spi.SqlExceptionHelper(144) - SQL Error: 54, SQLState: 61000
2016-04-05 15:04:56,859 ERROR [Camel (camel-1) thread #0 - jpa://com.teikitel.model.entity.Ticket] o.h.e.j.spi.SqlExceptionHelper(146) - ORA-00054: resource busy and acquire with NOWAIT specified or timeout expired
Hibernate: select TICKET_ID from TEIKITEL.TICKET where TICKET_ID =? for update nowait
2016-04-05 15:04:56,874 WARN  [Camel (camel-1) thread #0 - jpa://com.teikitel.model.entity.Ticket] o.h.e.j.spi.SqlExceptionHelper(144) - SQL Error: 54, SQLState: 61000
2016-04-05 15:04:56,874 ERROR [Camel (camel-1) thread #0 - jpa://com.teikitel.model.entity.Ticket] o.h.e.j.spi.SqlExceptionHelper(146) - ORA-00054: resource busy and acquire with NOWAIT specified or timeout expired
</code></pre>

<p>Did someone run into the same problem ?</p>

<p>Loic</p>