EnlistmentNotification Problems !!

S

Sahil Malik [MVP]

Okay, so here is my EnlistmentNotification class - this is the class that
implements both ISinglePhaseNotification and IEnlistmentNotification (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
SinglePhaseCommit(SinglePhaseEnlistment singlePhaseEnlistment) does get
called, in a multi RM scenario, public void Commit(Enlistment enlistment)
doesn't get called. (Prepare does get called though).

Can anyone help? Here's the code for my EnlistmentNotification class.

public class EnlistmentNotification : IEnlistmentNotification,
ISinglePhaseNotification
{
private StreamReader sr;
private StreamWriter sw;
private string toFile = "";

public EnlistmentNotification(String From, string To)
{
sr = new StreamReader(From);
sw = new StreamWriter(To);
toFile = To;
}

#region IEnlistmentNotification Members

public void Commit(Enlistment enlistment)
{
sw.Close();
sr.Close();
enlistment.Done();
}

public void InDoubt(Enlistment enlistment) { ;}

public void Prepare(PreparingEnlistment preparingEnlistment)
{
Prepare(((Enlistment)preparingEnlistment));
}

public void Rollback(Enlistment enlistment)
{
sw.Flush();
sr.Close();
sw.Close();
File.Delete(toFile);
}

#endregion

#region ISinglePhaseNotification Members

public void SinglePhaseCommit(SinglePhaseEnlistment
singlePhaseEnlistment)
{
Prepare(singlePhaseEnlistment);
Commit(singlePhaseEnlistment);
}

#endregion

private void Prepare(Enlistment enlistment)
{
sw.Write(sr.ReadToEnd());
}
}

- Sahil Malik [MVP]
http://codebetter.com/blogs/sahil.malik/
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top