[JBoss jBPM] - Re: CommandExecutor in a clustered environment
by mgommeringer
Thanks for the reply, t-dome. Your solution has the advantage, that i only need to re-implement three classes: DBMessageService, DBMessageServiceFactory (for jbpm.cfg) and CommandExecutor. I my eyes, the only thing that is missing for clustering is the exception handling for the line
| jbpmContext.getSession().lock(message, LockMode.UPGRADE);
|
When a LockAcquisitionException is thrown here, we must try to get the next message and skip the one we could not lock.
CommandExecutor.executeCommand():
| ...
| message = getAndLockNextMessage(dbMessageService, destination, jbpmContext.getSession());
| // message = dbMessageService.receiveNoWait(destination);
|
| // If we got a message here, we own the lock
| if (message != null) {
| checkForMoreMessages = true;
| Command command = (Command) message;
| log.trace("executing command '" + command + "'");
| command.execute();
| // Because our DBMessageService does not delete the
| // message, we must delete it here
| jbpmContext.getSession().delete(message);
| }
| ...
|
| private Message getAndLockNextMessage(DbMessageService dbMessageService, String destination, Session session) {
| Message message = dbMessageService.receiveNoWait(destination);
| if (message != null) {
| try {
| // try to lock the message
| session.lock(message, LockMode.WRITE);
| // Successfully locked
| return message;
| } catch (HibernateException e) {
| if (e.getCause() instanceof LockAcquisitionException) {
| // Failed to acquire the lock - try to get next
| return getAndLockNextMessage(dbMessageService, destination, session);
| } else {
| throw e;
| }
| }
| } else {
| return null;
| }
| }
|
>From the OO-Point-of-view, this is not the best solution (for me). I think that the MessageService itself, regardless of which implementation is used, should ensure, that the method "nextMessage()" or "receiveNoWait()" only returns Message objects, that have successfully been locked.
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=3960288#3960288
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=3960288
19 years, 9 months
[Persistence, JBoss/CMP, Hibernate, Database] - Hibernate 3.2CR3 in a Cluster for SFSB
by MarcReis
I have more or less posted about this already, but not hibernate specific (I was not sure about the cause, and am still not). From what I saw and read, I guess it is related to EJB3.0-SFSB, JBoss-Cache(1.4) and hibernate interaction.
I have set up a Cluster of two JBoss 4.0.4.GA (modification: server uses host name rather than IP) with JBossCache 1.4.0GA. I have two similar EJB3 Beans one SLSB and one SFSB (the diff is just that one is SF the other SL). When I invoke multiple times on the SLSB all is fine (the invokation gets Loadbalanced via RoundRobin on bothe maschines). When I do the same with the SF Bean then I get a
| 17:28:11,984 WARN [SessionFactoryObjectFactory] Not found: 2c9096b20c91acb4010c
| 91ae85a50002
|
This can happen on node one or two, depending where the first call has gone. So this happens when the SFSB allready exists. This then causes a failover to the node where the bean was created.
I'm glad for any hints and tipps!
Thanks ahead !
Marc
I'll gladly post details again, since the other threads are rather verbose, but first of still just want to reference those here:
JBoss.com -> JBoss User -> JBossCache
http://www.jboss.com/index.html?module=bb&op=viewtopic&t=83655
JBoss.com -> JBoss User -> Clustering/JBoss
http://www.jboss.com/index.html?module=bb&op=viewtopic&t=84650
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=3960284#3960284
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=3960284
19 years, 9 months