Okay, so here is my EnlistmentNotif ication class - this is the class that
implements both ISinglePhaseNot ification and IEnlistmentNoti fication (for
non distri and distributed transactions involving non durable or more than
one RM).
Funny thing though, while in a single RM scenario, public void
SinglePhaseComm it(SinglePhaseE nlistment singlePhaseEnli stment) does get
called, in a multi RM scenario, public void Commit(Enlistme nt enlistment)
doesn't get called. (Prepare does get called though).
Can anyone help? Here's the code for my EnlistmentNotif ication class.
public class EnlistmentNotif ication : IEnlistmentNoti fication,
ISinglePhaseNot ification
{
private StreamReader sr;
private StreamWriter sw;
private string toFile = "";
public EnlistmentNotif ication(String From, string To)
{
sr = new StreamReader(Fr om);
sw = new StreamWriter(To );
toFile = To;
}
#region IEnlistmentNoti fication Members
public void Commit(Enlistme nt enlistment)
{
sw.Close();
sr.Close();
enlistment.Done ();
}
public void InDoubt(Enlistm ent enlistment) { ;}
public void Prepare(Prepari ngEnlistment preparingEnlist ment)
{
Prepare(((Enlis tment)preparing Enlistment));
}
public void Rollback(Enlist ment enlistment)
{
sw.Flush();
sr.Close();
sw.Close();
File.Delete(toF ile);
}
#endregion
#region ISinglePhaseNot ification Members
public void SinglePhaseComm it(SinglePhaseE nlistment
singlePhaseEnli stment)
{
Prepare(singleP haseEnlistment) ;
Commit(singlePh aseEnlistment);
}
#endregion
private void Prepare(Enlistm ent enlistment)
{
sw.Write(sr.Rea dToEnd());
}
}
- Sahil Malik [MVP]
implements both ISinglePhaseNot ification and IEnlistmentNoti fication (for
non distri and distributed transactions involving non durable or more than
one RM).
Funny thing though, while in a single RM scenario, public void
SinglePhaseComm it(SinglePhaseE nlistment singlePhaseEnli stment) does get
called, in a multi RM scenario, public void Commit(Enlistme nt enlistment)
doesn't get called. (Prepare does get called though).
Can anyone help? Here's the code for my EnlistmentNotif ication class.
public class EnlistmentNotif ication : IEnlistmentNoti fication,
ISinglePhaseNot ification
{
private StreamReader sr;
private StreamWriter sw;
private string toFile = "";
public EnlistmentNotif ication(String From, string To)
{
sr = new StreamReader(Fr om);
sw = new StreamWriter(To );
toFile = To;
}
#region IEnlistmentNoti fication Members
public void Commit(Enlistme nt enlistment)
{
sw.Close();
sr.Close();
enlistment.Done ();
}
public void InDoubt(Enlistm ent enlistment) { ;}
public void Prepare(Prepari ngEnlistment preparingEnlist ment)
{
Prepare(((Enlis tment)preparing Enlistment));
}
public void Rollback(Enlist ment enlistment)
{
sw.Flush();
sr.Close();
sw.Close();
File.Delete(toF ile);
}
#endregion
#region ISinglePhaseNot ification Members
public void SinglePhaseComm it(SinglePhaseE nlistment
singlePhaseEnli stment)
{
Prepare(singleP haseEnlistment) ;
Commit(singlePh aseEnlistment);
}
#endregion
private void Prepare(Enlistm ent enlistment)
{
sw.Write(sr.Rea dToEnd());
}
}
- Sahil Malik [MVP]
Comment