Search code examples
javascriptlotus-noteslotus-dominolotusscriptlotus

Lotus Notes Connector run the agent from replica after IIOP connection


I do have the following situation:

  • "ScheduledJobs.nsf" with the agent "Worker"
  • The "ScheduledJobs.nsf" is replicated on three domino server: DominoServer1, DominoServer2, DominoServer3
  • With the Lotus Notes Connector im able to establish a connections over IIOP to the Notes Database "ScheduledJobs.nsf" on DominoServer1. This connections is static configured.
  • Because there is connections to the Notes database, im able to run the agent "Worker" on the Notes Database "ScheduledJobs.nsf" on DominoServer1 over Javascript.

What I would like to do is this:

Sometimes, depending on the situation, I would like to run the Agent "Worker" from the replica. For example I would like to run the agent "Worker" on DominoServer2 or DominoServer3.

Problem:

Due to the connection to the Notes Database over IIOP is static, im always connecting to the database "ScheduledJobs.nsf" on the DominoServer1.

Question:

Am I able to run the agent "Worker" after this IIOP connection on the replica?


EDITED

My code for "RunWorkerOn2"

Dim agent As NotesAgent
Dim sess As New NotesSession    
Dim db As NotesDatabase
Dim doc As NotesDocument    
Dim item As NotesItem

Set db = sess.CurrentDatabase   
Set agent = sess.CurrentAgent

Call db.Open( "DominoServer2/ORGANIZATION", "ScheduledJobs.nsf" )
Set agent = db.GetAgent("Worker")

// Reason why im using 'run' insted of RunOnServer:
// https://www-01.ibm.com/support/docview.wss?uid=swg1LO42549
If agent.Run() = 0 Then
    Print "SUCCESS"
Else
    Print "FAILED"
End If

Solution

  • You can do this indireclty.

    In the ScheduledJobs database that contains "Worker", add two new agents: "RunWorkerOn2" and "RunWorkerOn3".

    In the code of the RunWorkerOn2 agent, add code to open ScheduledJobs.nsf on DominoServer2 and use NotesDatabase.GetAgent("Worker"). Then call NotesAgent.RunOnServer to run Worker on Dominoserver2.

    Similarly, in the code of the RunWorkerOn3 agent, open ScheduledJobs.nsf on DominoServer3 and use NotesDatabas.GetAgent("Worker"). Then call NotesAgent.RunOnserver to run Worker on DominoServer3.

    So this way, your connector still connects to DominoServer1, and it runs all of its agaengs on DominoServer1, but those agents in turn will run agents on DominoServer2 and DominoServer3.