Solved

Concurrent Web Agents

Posted on 2003-12-10
7
376 Views
Last Modified: 2013-12-18
I have an application which has a number of web agents.

One of these web agents runs on all forms and sets a value on an external document. I am getting intermittent problems with this agent sometimes it will work othertimes it doesn't.

Now I have a feeling it may be because concurrent agents are not enabled on the server and so if two users are clicking on the button at the same time the agent is trying to run.

Can you please let me know what happens if two or more users try to run a web agent at the same time and concurrent agents are not permitted in the server document?

Thanks in advance.

0
Comment
Question by:fayeb
7 Comments
 
LVL 15

Expert Comment

by:Bozzie4
Comment Utility
If you don't enable the webagents to run concurrently, the server will try to execute them one after another.

Of course, this can cause timeouts if you have a lot of requests for the same server!  The http task will send a timeout if it can't run the agent for a certain request.
 What are the problems you are getting ?

It's best to enable this setting in the server document.

cheers,

Tom
0
 

Author Comment

by:fayeb
Comment Utility
I have a document locking system in place.  

When a user clicks on the edit button the following agent runs to check if the document has a lock, if it does it notifies the user they cannot edit the document otherwise it creates a lock document and places the user in edit mode :

-----------------------------------------------------------------------
Dim.....

Set db = sess.CurrentDatabase
Set CurrentDoc=sess.documentContext
      
unid = Trim$ ( Lcase$ ( CurrentDoc.UniversalID ) )
Set LockView = db.GetView("vwLUDocLock")    
Call LockView.refresh()
Set LockDoc = LockView.GetDocumentByKey(unid, True)
      
If LockDoc Is Nothing Then
                Set NewLockDoc = New NotesDocument(db)
                NewLockDoc.Form = "frmDLock"
                NewLockDoc.LockUNID = unid
                NewLockDoc.LockedBy = CurrentDoc.Remote_User(0)
                NewLockDoc.LockDate = Cstr(Now())
      NewLockDoc.LockExpired ="N"
      Call NewLockDoc.Save(True, False)
      Print "Content-type: text/HTML"
      Print "Pragma: no-cache" 'prevent caching on proxy servers
      Print "Cache-control: no-cache"
      Print "Expires: " + Cstr(Now)
      Print {<html><head><title>Redirect</title></head><body>}
      Print {<script language=javascript>}
      Print {location.href='?EditDocument'}
      Print {</script>}
      Print {</body></html>}
Else
      If LockDoc.LockedBy(0) = CurrentDoc.Remote_User(0) Then
                      LockDoc.LockDate = Cstr(Now())
            LockDoc.LockExpired ="N"
            Call LockDoc.Save(True, False)
            Print "Content-type: text/HTML"
            Print "Pragma: no-cache" 'prevent caching on proxy servers
            Print "Cache-control: no-cache"
            Print "Expires: " + Cstr(Now)
            Print {<html><head><title>Redirect</title></head><body>}
            Print {<script language=javascript>}
            Print {location.href='?EditDocument'}
            Print {</script>}
            Print {</body></html>}
      Else
            lockedby = LockDoc.LockedBy(0)
            Print "Content-type: text/HTML"
            Print "Pragma: no-cache" 'prevent caching on proxy servers
            Print "Cache-control: no-cache"
            Print "Expires: " + Cstr(Now)
            Print {<html><head><title>Redirect</title></head><body>}
            Print {<script language=javascript>}
            Print {alert('The document is locked by } + lockedby + {, you cannot edit the document until it is released');}
            Print {location.href='?OpenDocument'}
            Print {</script>}
            Print {</body></html>}
      End If
End If
Exit Sub
-----------------------------------------------------------------------

Here is the code which removes the lock when the document is saved:

-----------------------------------------------------------------------
Set db = sess.CurrentDatabase
Set CurrentDoc=sess.documentContext
unid$ = Trim$ ( Lcase$ ( CurrentDoc.UniversalID ) )
Set LockView = db.GetView("vwLUDocLock")    
Call LockView.refresh()
Set LockDoc = LockView.GetDocumentByKey(unid$, True)      
      
If LockDoc Is Nothing Then
                Print "Content-type: text/HTML"
      Print "Pragma: no-cache" 'prevent caching on proxy servers
      Print "Cache-control: no-cache"
      Print "Expires: " + Cstr(Now)
      Print {<html><head><title>Redirect</title></head><body>}
      Print {<script language=javascript>}
      Print {alert('The document lock has been removed so your changes could not be saved.');}
      Print {history.back(0)}
      Print {</script>}
      Print {</body></html>}
Else            
      lockedby = LockDoc.LockedBy(0)
      currentuser = CurrentDoc.Remote_User(0)
      If lockedby = currentuser Then
            LockDoc.LockExpired = "Y"
            LockDoc.LockExpiredBy = currentuser
            LockDoc.LockExpiredDate = Cstr(Now)
            CurrentDoc.Save True, True
            LockDoc.Save True,True
            vPath = Evaluate({@ReplaceSubstring(@Subset(@DbName;-1) ; "\\" ; "/")})
            strURL = "[/" + vPath(0) +   "/vwAll/" + CurrentDoc.UniversalID + "?OpenDocument]"
            Print strURL            
      Else
            Print "Content-type: text/HTML"
            Print "Pragma: no-cache" 'prevent caching on proxy servers
            Print "Cache-control: no-cache"
            Print "Expires: " + Cstr(Now)
            Print {<html><head><title>Redirect</title></head><body>}                  Print {<script language=javascript>}
            Print {alert('The document lock has been removed so your changes could not be saved.');}
            Print {history.back(0)}
            Print {</script>}
            Print {</body></html>}
      End If      
End If
      
Exit Sub

-----------------------------------------------------------------------

The problem I have is that documents seem to be getting left in a locked state.  I am unsure why this is occuring as I am not getting any errors produced.  

We have multiple users on the system and we are currently unable to have the concurrent agents enabled in  the server document.  I was wondering if this could be causing  the problem as then I would be able to put in a case for having this option enabled.  

The problem I have is this is intermittent which is what is causing me concern and plenty of headaches!!!!

Any ideas?

0
 
LVL 46

Accepted Solution

by:
Sjef Bosman earned 43 total points
Comment Utility
You only seem to remove the lock when the document is saved, but if the users doesn't save the document? What happens if the users clicks Back? The lock will remain, won't it? Anyhow, locking based on a user's name will never be the best solution, since he can easily create a duplicate browserscreen and create situations you never dreamt of.

Is multiple simultaneous updates of a Notes-document such a problem? It's just standard Notes behaviour, because that's what Replication Conflicts are for. I can imagine that you try to avoid them, but this is not the way. A plausible way is to use a session-oriented approach, or did you already parametrise your system in that way? I don't know the exact implementation, nor if it will be a viable solution, but you need to know what the user is doing. Another idea: a small applet that constantly informs you what the user's doing...
0
 
LVL 15

Assisted Solution

by:Bozzie4
Bozzie4 earned 41 total points
Comment Utility
It's not concurrent running agents that will get you in trouble.

You need to weigh the chances for 2 people trying to create a lock at exactly the same time against the 'blocking' effect of disabling concurrent agents.
I would say the chances are pretty slim, albeit not non-existing.

BTW , in your situation, you will definitely need an Unlock Agent running on the server, to remove older locks.

cheers,

Tom
0
 
LVL 24

Assisted Solution

by:HemanthaKumar
HemanthaKumar earned 41 total points
Comment Utility
Instead of unlocking the document.. Create a new releaseLock document.

Then let scheduled agent do its job of releasing by looking at releaseLock document.. This agent should run when doc is created or modified.. so it is instantaneous.

But anyway like sjef as mentioned if the user just exits out of the web page by closing the browser.. no querysave event is fired and thus leaving the lock stub obsolete.. To avoid you can take two approaches..

1. Setup time expiration like 10-15 mins and it depends upon the form and how the user interacts.
2. Create a msg that shows that the document has lock and was locked by a user for xx hrs yy mins and ask if they want to override..

That is the best I can think of

~Hemanth
0

Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

IBM Notes offer Encryption feature using which the user can secure its NSF emails or entire database easily. In this section we will discuss about the process to Encrypt Incoming and Outgoing Mails in depth.
This article covers general Notes 8.5 troubleshooting information including recreating the Notes\Data folder.
It is a freely distributed piece of software for such tasks as photo retouching, image composition and image authoring. It works on many operating systems, in many languages.
You have products, that come in variants and want to set different prices for them? Watch this micro tutorial that describes how to configure prices for Magento super attributes. Assigning simple products to configurable: We assigned simple products…

728 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now