[jboss-user] [JBoss jBPM] - Re: CommandExecutor in aclustered environment
mgommeringer
do-not-reply at jboss.com
Mon Jul 24 03:14:21 EDT 2006
Hi,
I would also like to use the CommandExecutor in an cluster (starting it multiple times on different machines). It sounds as if the DBMessageService will not be cluster-ready in the future. Am i right?
If I am not fully wrong it is no big effort to make the DBMessageService cluster-ready.
I looked at the sources and think that the right place (at least in the current CVS) to ensure that a single message is only processed by one CommandExecutor is org.jbpm.db.MessagingSession. The method "nextMessage(String destination)" should return only Message objects that are not locked by another transaction.
Here my -untested- proposal:
| public Message nextMessage(String destination) {
| Message message = null;
| if (nextMessage!=null) {
| message = nextMessage;
| nextMessage = null;
| } else {
| Iterator messageIterator = getMessageIterator(destination);
| if (messageIterator.hasNext()) {
| // Get the next message that was not locked on DB and lock it
| message = getNextUnlockedMessage(messageIterator);
| }
| if (messageIterator.hasNext()) {
| // Get the next message that was not locked on DB and lock it
| nextMessage = getNextUnlockedMessage(messageIterator);
| }
| }
| return message;
| }
|
| private Message getNextUnlockedMessage(Iterator messageIterator) {
| Message message = (Message) messageIterator.next();
| 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 getNextUnlockedMessage(messageIterator);
| }
| else {
| throw e;
| }
| }
| }
|
Is this code okay for this purpose?
I only recognized that several JBPM classes (also the PersistenceService which creates the MessagingSession) must be modified/overridden in order to plug in a custom implementation here and I would dislike to do this within my project.
Thanks,
Matthias
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=3960244#3960244
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=3960244
More information about the jboss-user
mailing list