Monday, March 19, 2012

New request is not allowed to start because it should come with valid transaction des

I have a C# windows service that uses MSMQ, DTC Transactions, SQL server
2005 and Notification services.
I am doing the following in the service:
OnStart
Create the queue
set the P Complete event
call Begin P
PComplete
WaitHandle[] waitHandle = new WaitHandle[] { new
AutoResetEvent(false) };
ThreadPool.QueueUserWorkItem(ProcessMessage, waitHandle[0])
Call End P
WaitHandle.WaiteAll(waitHandle)
queue.BeginP
ProcessMessage(object stateInfo)
AutoResetEvent are = (AutoResetEvent)stateInfo;
Create DTC Transaction
try
Message msg =
callResultQueue.Receive(MessageQueueTransactionType.Automatic);
are.Set();
retreive Message Body
Using (SQLConnection conn = new SQLConnection(connectionString))
conn.open
Write Message Body to database
If Messagebody.Status = 20
Update Notification Services
Commit DTC transaction
catch
Roll Back DTC Transaction
Quite often I am receiving the above message, I've googled it and all I've
come up with is people asking how to solve the error. Any information would
be greatly appreciated. I know the above is mixed psudeo code with code, if
additional code is required please let me know, I'll provide what I can.
Thanks
WayneIt would be helpful if you could post working code...
Noel
Wayne Sepega wrote:
> I have a C# windows service that uses MSMQ, DTC Transactions, SQL server
> 2005 and Notification services.
> I am doing the following in the service:
> OnStart
> Create the queue
> set the P Complete event
> call Begin P
> PComplete
> WaitHandle[] waitHandle = new WaitHandle[] { new
> AutoResetEvent(false) };
> ThreadPool.QueueUserWorkItem(ProcessMessage, waitHandle[0])
> Call End P
> WaitHandle.WaiteAll(waitHandle)
> queue.BeginP
> ProcessMessage(object stateInfo)
> AutoResetEvent are = (AutoResetEvent)stateInfo;
> Create DTC Transaction
> try
> Message msg =
> callResultQueue.Receive(MessageQueueTransactionType.Automatic);
> are.Set();
> retreive Message Body
> Using (SQLConnection conn = new SQLConnection(connectionString))
> conn.open
> Write Message Body to database
> If Messagebody.Status = 20
> Update Notification Services
> Commit DTC transaction
> catch
> Roll Back DTC Transaction
>
> Quite often I am receiving the above message, I've googled it and all I've
> come up with is people asking how to solve the error. Any information woul
d
> be greatly appreciated. I know the above is mixed psudeo code with code, i
f
> additional code is required please let me know, I'll provide what I can.
> Thanks
> Wayne

No comments:

Post a Comment