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#...
Reply to the post :
http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&a...