Friday, March 9, 2012

Monitoring & Starting Distribution Agent thru program

Do any one know how to detect a distribution agent failure thru program. Is
there any way to start it programmatically.
Any help would be great
Kumaresh,
how are you setting off the distribution agent? If it is through programming
the activeX control, you could then have a look at the replication errors
collection. This example applies to merge, but AFAIK it's much the same for
transactional.
http://www.windowsitpro.com/Files/09...Listing_01.txt
Alternatively you could look at MSdistribution_history and MSrepl_errors
tables (or the job's history directly)
HTH,
Paul Ibison SQL Server MVP, www.replicationanswers.com
(recommended sql server 2000 replication book:
http://www.nwsu.com/0974973602p.html)
|||Thanks for your valuable comments.
I have set the replication through the SQL Server Enterprise Manager.
But the client complains that they saw the replication failure only after
one day.
And then after they had to set the replication again.
Hence i thought of running a schedular program which checks for replication
and start it if it had a failure.
I also will be very happy if u could suggest or post some guide lines to
proceed
thanks once again
"Paul Ibison" wrote:

> Kumaresh,
> how are you setting off the distribution agent? If it is through programming
> the activeX control, you could then have a look at the replication errors
> collection. This example applies to merge, but AFAIK it's much the same for
> transactional.
> http://www.windowsitpro.com/Files/09...Listing_01.txt
> Alternatively you could look at MSdistribution_history and MSrepl_errors
> tables (or the job's history directly)
> HTH,
> Paul Ibison SQL Server MVP, www.replicationanswers.com
> (recommended sql server 2000 replication book:
> http://www.nwsu.com/0974973602p.html)
>
>
|||Kumaresh,
to let the client know, you could use the alert: 'Replication: agent
failure' and have an email sent from there.
Actually, what I do is send notification directly from the replication job
belonging to the distribution agent with a specific message - in my case I
only have SMTP, so I use an additional step in the distribution agent's job
which is reached only on failure of the main step but if you have MAPI
integrated, then you can just add the On Failure notification like in any
other job. HTH,
Paul Ibison SQL Server MVP, www.replicationanswers.com
(recommended sql server 2000 replication book:
http://www.nwsu.com/0974973602p.html)
|||Thanks Paul, That was very near to the solution expected.
But i also wanted to know is there any way by which i can handle it by myself,
leaving the client undisturbed. Say for example running a scheduled program
or some thing similar to that. so that i start the relpication without the
intervention of the client
Any suggestions would be great
"Paul Ibison" wrote:

> Kumaresh,
> to let the client know, you could use the alert: 'Replication: agent
> failure' and have an email sent from there.
> Actually, what I do is send notification directly from the replication job
> belonging to the distribution agent with a specific message - in my case I
> only have SMTP, so I use an additional step in the distribution agent's job
> which is reached only on failure of the main step but if you have MAPI
> integrated, then you can just add the On Failure notification like in any
> other job. HTH,
> Paul Ibison SQL Server MVP, www.replicationanswers.com
> (recommended sql server 2000 replication book:
> http://www.nwsu.com/0974973602p.html)
>
>
>
|||Kumaresh,
this will give you any replication errors in the last 24 hours for a
specific replication job. It hope it's OK for your purposes.
SELECT DISTINCT
MSdistribution_agents.name,
MSdistribution_history.runstatus, MSdistribution_history.error_id,
MSdistribution_history.start_time,
MSdistribution_history.comments
FROM MSdistribution_agents INNER JOIN
MSdistribution_history ON MSdistribution_agents.id =
MSdistribution_history.agent_id INNER JOIN
MSrepl_errors ON MSdistribution_history.error_id =
MSrepl_errors.id
WHERE (MSdistribution_agents.name =
N'PC-TEMPLATE-Northwind-PC-TEMPLATE-2') AND
(MSdistribution_history.start_time BETWEEN DATEADD(dd, - 1, GETDATE()) AND
GETDATE())
Rgds,
Paul Ibison
|||Thanks Plan
Here is the way am proceeding. First am gonna write a trigger on
MSdistribution_history table to check for errors
If any error occurs, then a COM object is called to delete MSREPL7 table
created in oracle database
Is this a reliable solution to proceed with.
Also how can a distribution agent be restarted within a trigger
Any help would be great
"Paul Ibison" wrote:

> Kumaresh,
> this will give you any replication errors in the last 24 hours for a
> specific replication job. It hope it's OK for your purposes.
> SELECT DISTINCT
> MSdistribution_agents.name,
> MSdistribution_history.runstatus, MSdistribution_history.error_id,
> MSdistribution_history.start_time,
> MSdistribution_history.comments
> FROM MSdistribution_agents INNER JOIN
> MSdistribution_history ON MSdistribution_agents.id =
> MSdistribution_history.agent_id INNER JOIN
> MSrepl_errors ON MSdistribution_history.error_id =
> MSrepl_errors.id
> WHERE (MSdistribution_agents.name =
> N'PC-TEMPLATE-Northwind-PC-TEMPLATE-2') AND
> (MSdistribution_history.start_time BETWEEN DATEADD(dd, - 1, GETDATE()) AND
> GETDATE())
> Rgds,
> Paul Ibison
>
>
|||Sorry I mean to type "Thanks Paul" but mistyped
[vbcol=seagreen]
> Thanks Plan
> Here is the way am proceeding. First am gonna write a trigger on
> MSdistribution_history table to check for errors
> If any error occurs, then a COM object is called to delete MSREPL7 table
> created in oracle database
> Is this a reliable solution to proceed with.
> Also how can a distribution agent be restarted within a trigger
> Any help would be great
>
> "Paul Ibison" wrote:
|||Kumaresh,
you won't be able to make a trigger on this system table, but you could
schedule a job to run once a minute to poll the table.
Rgds,
Paul Ibison
|||Thanks paul,
I also want to know if i could start the replication from T-Sql
Any reference articles would be very helpful
"Paul Ibison" wrote:

> Kumaresh,
> you won't be able to make a trigger on this system table, but you could
> schedule a job to run once a minute to poll the table.
> Rgds,
> Paul Ibison
>
>
>

No comments:

Post a Comment