Wednesday, March 28, 2012

RMO: getting the agentid for AssignToAgent

Hello,

I'd like to assign a custom profile to a merge replication agent. The AssignToAgent() method takes the distribution db name and the agentID as an integer. Which method is used to get at this agentID? All I can find is the job ID in the subscription class.

Thanks!

Scott

You could try something like this

string distServerName = "mydistributionserver";
ServerConnection distServerConn = new ServerConnection(distServerName);
distServerConn.Connect();
AgentProfile logReaderAgentProfile = new AgentProfile("MyLogReader", distServerConn);
logReaderAgentProfile.Description = "My New LogReader Profile";
logReaderAgentProfile.AgentType = AgentType.LogReaderAgents; // change this to MergeAgents
logReaderAgentProfile.Create();
logReaderAgentProfile.CachePropertyChanges = true;
logReaderAgentProfile.MakeDefault();

// Set parameter values
logReaderAgentProfile.ChangeParameter("historyverboselevel", "1");
logReaderAgentProfile.ChangeParameter("logintimeout", "15");
logReaderAgentProfile.ChangeParameter("pollinginterval", "10");
logReaderAgentProfile.ChangeParameter("querytimeout", "1200");
logReaderAgentProfile.ChangeParameter("readbatchsize", "250");
logReaderAgentProfile.CommitPropertyChanges();

Hope this helps

Cheers

sql

No comments:

Post a Comment