NserviceBus Hosted in IIS issue - nservicebus

I've been working on a project where I need Nservicebus to be hosted in IIS.
I need the MVC3 webapplication to send a message, a nservicebus host should handle this message
and then send back some sort of message to the webapplication.
the Async Pages example http://docs.particular.net/samples/web/asp-mvc-application/
shows one way of doing it. I can get this to work, however this does not fully furfill my requirements. I need an object to be returned from the handler, not just an int.
To get this to work i've tried setting up a host under IIS, in my Global.asax I've got this code:
Bus = Configure.WithWeb()
.DefineEndpointName("CQRS")
.Log4Net()
.DefaultBuilder()
.DisableTimeoutManager()
.XmlSerializer()
.MsmqTransport()
.IsTransactional(true)
.PurgeOnStartup(false)
.InMemorySubscriptionStorage()
.UnicastBus()
.AllowSubscribeToSelf()
.ImpersonateSender(false)
.LoadMessageHandlers()
.CreateBus().Start();
my web.config:
<MessageForwardingInCaseOfFaultConfig ErrorQueue="CQRS.error" />
<MsmqTransportConfig NumberOfWorkerThreads="1" MaxRetries="5" />
<UnicastBusConfig DistributorControlAddress="" DistributorDataAddress="" TimeoutManagerAddress="CQRS.timeouts">
<MessageEndpointMappings>
<add Messages="Nokavision.InvoiceProcessing.CQRS.Messages" Endpoint="CQRS" />
<add Messages="NServiceBus.Scheduling.Messages.ScheduledTask" Endpoint="CQRS" />
</MessageEndpointMappings>
</UnicastBusConfig>
Sending messages with the Bus object works perfectly, a message appears in the "cqrs" queue.
The handler within the webapplication however does not trigger. This is the code:
public class UpdateInkoopFactuurAlgemeenHandler : IHandleMessages<UpdateInkoopFactuurAlgemeenCommand>
{
public IBus Bus { get; set; }
public void Handle(UpdateInkoopFactuurAlgemeenCommand message)
{
P2PEntities entities = new P2PEntities();
var factuur = (from f in entities.Documenten.OfType<InkoopFactuur>()
where f.DocumentId == message.DTO.DocumentId
select f).FirstOrDefault();
if (factuur != null)
{
factuur.FactuurNummer = message.DTO.FactuurNummer;
entities.SaveChanges();
}
//Bus.Return(new UpdateInkoopFactuurAlgemeenResponse(message.DTO.ClientConnectionId));
}
}
I'm sure I'm missing something small here but what am I doing wrong, why doesn't the handler get triggered while I can clearly see a message in the queue.
Also on the Bus object I can see the handler being loaded.

If you configure installer correctly in your fluent configuration then NSB sets the rights on the queue properly.
http://andreasohlund.net/2012/01/26/installers-in-nservicebus-3-0/

Ok, I think I figured it out, it seems that the queue's created by NSB dont have full access permissions for the IIS USER. I've set "full control" for everyone on each of the queue's and restarted IIS. Somehow it seems to work now

Related

How to register NServiceBus.Timeout.Core.ImanageTimeouts

I have an NServiceBus publisher project that has ran successfully for months. It was using NServiceBus.Host version 3.2.2. I need to upgrade the version to 3.3.8. After the upgrade, I get the following exception notification:
Exception when starting endpoint, error has been logged. Reason: The requested service 'NServiceBus.Timeout.Core.IManageTimeouts' has not been registered.
To avoid this exception, either register a component to provide the service,
check for service registration using IsRegistered(),
or use the ResolveOptional() method to resolve an optional dependency.
I have searched online to determine why NServiceBus.Host version 3.3.8 would not register IManageTimeouts object. I have also searched for documentation or examples using IsRegistered() and ResolveOptional(). No luck so far... (Maybe I need a semester at Google search university?)
Has any NServiceBus users out there experienced this exception?
Is the IManageTimeouts object new to NServiceBus.Host version 3.3.8?
Could someone provide an example how I could register the IManageTimeouts object with NServiceBus
configuration?
Here are my current configuration settings:
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<configSections>
<section name="MsmqTransportConfig" type="NServiceBus.Config.MsmqTransportConfig, NServiceBus.Core" />
<section name="UnicastBusConfig" type="NServiceBus.Config.UnicastBusConfig, NServiceBus.Core" />
<section name="MessageForwardingInCaseOfFaultConfig" type="NServiceBus.Config.MessageForwardingInCaseOfFaultConfig, NServiceBus.Core" />
</configSections>
<MsmqTransportConfig ErrorQueue="PublisherError" NumberOfWorkerThreads="1" MaxRetries="5" />
<UnicastBusConfig ForwardReceivedMessagesTo="">
<MessageEndpointMappings></MessageEndpointMappings>
</UnicastBusConfig>
<MessageForwardingInCaseOfFaultConfig ErrorQueue="PublisherFault" />
/configuration>
configure = NServiceBus.Configure.With();
Bus = configure
.DefiningMessagesAs(t => t.Namespace != null && t.Namespace.EndsWith("EventPublisher.InternalMessages"))
.DefineEndpointName("EventPublisher")
.Log4Net()
.DefaultBuilder()
.XmlSerializer()
.MsmqTransport()
.IsTransactional(true)
.PurgeOnStartup(false)
.UnicastBus()
.LoadMessageHandlers()
.ImpersonateSender(false)
.CreateBus()
.Start(() => Configure.Instance.ForInstallationOn<Windows>().Install());
It looks like you need to explicitly enable TimeoutManager.
To do that:
.UseRavenTimeoutPersister();

Self-hosting a WCF service, when I try to get one error can any solve the issue

***could you provide the app.config file according to my Program class please
if possible please provide app.config code i got your point but for that what you are telling i don't know how to do***
This code is not working because it's causing an error when reaching host.open(). Please help me solve the issue
public class Program
{
static void Main(string[] args)
{
// Base address
Uri baseServiceAddress = new Uri("http://localhost:8090/Welcome");
using (var host = new ServiceHost(typeof(WCFSelfHostedService), baseServiceAddress))
{
// Enable MetaData publishing.
ServiceMetadataBehavior serviceMetaDataBehaviour = new ServiceMetadataBehavior();
serviceMetaDataBehaviour.HttpGetEnabled = true;
serviceMetaDataBehaviour.MetadataExporter.PolicyVersion = PolicyVersion.Policy15;
host.Description.Behaviors.Add(serviceMetaDataBehaviour);
// Open the ServiceHost to start listening for messages. No endpoint are explicitly defined, runtime creates default endpoint.
host.Open();
Console.WriteLine("The service is ready at {0} and host at {1}", baseServiceAddress, DateTime.Now.ToString());
Console.WriteLine("The service and client is running in the same process.");
WCFSelfHostedService selfHostService = new WCFSelfHostedService();
Console.Write("Enter your name. : ");
Console.WriteLine(selfHostService.WelComeMessage(Console.ReadLine()));
Console.WriteLine("Host is running... Press <Enter> key to stop the service.");
Console.ReadLine();
//Close the service.
host.Close();
}
}
}
When I run this code I get this error:
An unhandled exception of type 'System.InvalidOperationException'
occurred in System.ServiceModel.dll
Additional information: Service
'WCFSelfHostedService.WCFSelfHostedService' has zero application
(non-infrastructure) endpoints. This might be because no configuration
file was found for your application, or because no service element
matching the service name could be found in the configuration file, or
because no endpoints were defined in the service element.
My app.config is:
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<system.serviceModel>
<client>
<endpoint
address ="localhost:8090/Welcome";
binding ="wsHttpBinding"
contract ="MyCalculatorService.ISimpleCalculator">
</endpoint>
</client>
</system.serviceModel>
</configuration>
The error is pretty clear: the service has no application endpoints defined.
Either you have a config file that you're not showing us (if so: please do show!), which would configure service endpoints - or then you need to set up at least one service endpoint in code.
So either create an app.config file for the app where the self-hosting is happening and add something like this to it:
<system.serviceModel>
<services>
<service name="YourNamespace.WCFSelfHostService" >
<endpoint name="Default"
address="http://yourServerName:8088/SomePlace/ServiceName"
binding="basicHttpBinding"
contract="YourNamespace.IWCFSelfHostService" />
</service>
</services>
</system.serviceModel>
or then change your code to set up at least one service endpoint in code - before you call host.Open():
// Base address
Uri baseServiceAddress = new Uri("http://localhost:8090/Welcome");
using (var host = new ServiceHost(typeof(WCFSelfHostedService), baseServiceAddress))
{
// Enable MetaData publishing.
ServiceMetadataBehavior serviceMetaDataBehaviour = new ServiceMetadataBehavior();
serviceMetaDataBehaviour.HttpGetEnabled = true;
serviceMetaDataBehaviour.MetadataExporter.PolicyVersion = PolicyVersion.Policy15;
host.Description.Behaviors.Add(serviceMetaDataBehaviour);
// Define AT LEAST one service endpoint
host.AddServiceEndpoint(typeof(IWCFSelfHostService), new BasicHttpBinding(), baseServiceAddress);
// Open the ServiceHost to start listening for messages. No endpoint are explicitly defined, runtime creates default endpoint.
host.Open();
Console.WriteLine("The service is ready at {0} and host at {1}", baseServiceAddress, DateTime.Now.ToString());
Console.WriteLine("The service and client is running in the same process.");
WCFSelfHostedService selfHostService = new WCFSelfHostedService();
Console.Write("Enter your name. : ");
Console.WriteLine(selfHostService.WelComeMessage(Console.ReadLine()));
Console.WriteLine("Host is running... Press <Enter> key to stop the service.");
Console.ReadLine();
// Close the service.
host.Close();
}
Update: the app.config you're showing us is defininig a client - a program that is calling a service. What you need, however, is an app.config that defines the SERVICE side of things - see my example. You need to define one or multiple <services> in your config, which in turn expose at least one application endpoint where a client can connect to.
WCF is always made up of a service (on a server), and one (or multiple) client(s) calling that service. See this article for a very basic intro to WCF architecture. The service is configured in your config file in the <services>/<service> section, while your client side needs to define their stuff in the <client> section.

Subscriber is unable to handler message from publisher

I'm testing NServiceBus on ASP.NET MVC3. At the moment, I'm able to send command message to the backend and the message handler is listening to it. But when i try to publish the same message, the message handler is not listening.
The problem i found is that message is not published to the subscriber's queue. When i debug and check NServiceBusHost console, it says
2012-01-19 22:53:35,042 [1] INFO NServiceBus.Unicast.UnicastBus [(null)] <(null
)> - Subscribing to SampleMessage.Person1WasCreated, SampleMessage, Version=1.0.
0.0, Culture=neutral, PublicKeyToken=null at publisher queue Test-web
I checked my config settings again and again for few days and it seems correct for me . Can anyone please check for me what I'm missing? The thing I'm trying to do is to publish a message from the web and the message should be handle at the backend (ServiceHost2).
ASP.NET MVC3 Web.config
<configSections>
<section name="MsmqTransportConfig" type="NServiceBus.Config.MsmqTransportConfig, NServiceBus.Core" />
<section name="MsmqSubscriptionStorageConfig" type="NServiceBus.Config.MsmqSubscriptionStorageConfig, NServiceBus.Core" />
<section name="UnicastBusConfig" type="NServiceBus.Config.UnicastBusConfig, NServiceBus.Core"/>
</configSections>
<MsmqTransportConfig InputQueue="Test-web" ErrorQueue="Test-web-error" NumberOfWorkerThreads="1" MaxRetries="5" />
<MsmqSubscriptionStorageConfig Queue="Test-subscriptionstorage" />
Global.asax.cs
protected void Application_Start()
{
AreaRegistration.RegisterAllAreas();
RegisterGlobalFilters(GlobalFilters.Filters);
RegisterRoutes(RouteTable.Routes);
Global.Bus = Configure.WithWeb()
.Log4Net()
.CastleWindsorBuilder()
.XmlSerializer()
.MsmqTransport().IsTransactional(false)
.UnicastBus()
.LoadMessageHandlers()
.MsmqSubscriptionStorage()
.CreateBus()
.Start()
;
}
App.Config in ServiceHost2 Project
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<configSections>
<section name="UnicastBusConfig" type="NServiceBus.Config.UnicastBusConfig, NServiceBus.Core" />
<section name="MsmqTransportConfig" type="NServiceBus.Config.MsmqTransportConfig, NServiceBus.Core" />
<section name="MsmqSubscriptionStorageConfig" type="NServiceBus.Config.MsmqSubscriptionStorageConfig, NServiceBus.Core" />
</configSections>
<MsmqSubscriptionStorageConfig Queue="Service2-AC1-subscriptionstorage" />
<MsmqTransportConfig InputQueue="Service2-AC1" ErrorQueue="Service2-AC1-Error" NumberOfWorkerThreads="1" MaxRetries="5" />
<UnicastBusConfig>
<MessageEndpointMappings>
<add Messages="SampleMessage" Endpoint="Test-web" />
</MessageEndpointMappings>
</UnicastBusConfig>
<appSettings>
<add key="EndpointConfigurationType" value="ServiceHost2.EndpointConfig, ServiceHost2"/>
</appSettings>
</configuration>
EndpointConfig for ServiceHost2
namespace ServiceHost2
{
public class EndpointConfig : IConfigureThisEndpoint, AsA_Server, IWantCustomInitialization
{
public void Init()
{
Configure.With()
.Log4Net()
.CastleWindsorBuilder()
.MsmqTransport()
.MsmqSubscriptionStorage()
.XmlSerializer()
.UnicastBus().LoadMessageHandlers()
;
}
}
}
Method in the controller which publish the message
public ActionResult CreatePerson(Person p)
{
var Person1WasCreated = new Person1WasCreated {Id = p.Id,Name = p.Name};
Global.Bus.Publish(Person1WasCreated);
return View();
}
Thanks.
I think I found out why. I was reading on this article today about Why not publish NServiceBus messages from a web application?
It states very clear that, message is not suppose to publish from the web. Somehow The subscription storage created by my web project doesn't allow anything to subscribe to it.
So my solution is, I send the command message from the web to a message handler in Service1, and publish a new event message to Service2. Even the event message is able to subscribe into Service1's subscription storage.Everything works fine now. Thanks.

WCF Return Multiple Function Results Asynchronously?

I've been reading up on how to do this but I'm having a hard time getting my head around it.
Synchronous and Asynchronous Operations
WCF: Working with One-Way Calls, Callbacks, An...
My goal is to return results from multiple functions in a Silverlight enabled WCF service as they are discovered.
A general overview of how this service is desired to work is as follows.
User enters a url that has many large csv files listed in hyperlinks. The service gets the initial user entered url, makes a web request of that url, gets the csv file names using regex, service downloads the csv files to server, files are converted to a different format.
Currently all of that works, but no response is shown until the entire operation is done. I would like to provide feedback during each function.
I'm using VB for this app but am fluent in C# if anyone has a code suggestion.
<ServiceContract(Namespace:="http://somemadeupurl")>
<SilverLightFaultBehavior()>
<AspNetCompatibilityRequirements(RequirementsMode:=
AspNetCompatibilityRequirementsMode.Allowed)>
Public Class GetCSV
<OperationContract()>
Public Function ProcessInitialLink(ByVal strInitialLink As String)
'download the source html
'do a webrequest and extract csv links
'since dates are in the filenames I would like to send back most
'recent to user here
Dim strMostRecentCSV As String=SomeRegexMatch
> 'problem here. Would like to return strMostRecentCSV and keep processing
GetAndConvertBigCSV(strMostRecentCSV)
Return strMostRecentCSV
End Function
'actually a list but for brevity..
Private Function GetAndConvertBigCSV(ByVal strMostRecentCSV as string)
'do a bunch of downloading
'call a function to do a bunch of converting
'call a function to clean up files
End Function
End Class
If it's done like this it will return strMostRecentCSV but has to wait until GetAndConvertBigCSV is done before returning.
I've tried spawning GetAndConvertBigCSV as a new thread and it works but returns nothing that I can bind to the Silverlight client (e.Result)
At a minimum I would like to provide feedback of the first function Return then have the service continue.
Thanks a million for help.
I think that what you probably want is a "polling duplex http service" - what this means is that WCF will fake up a duplex style service for you (by polling). The advantage of a duplex service over a regular asynchronous service is that it is easy to call back to the client multiple times (so you can provide feedback on the progress of your task).
It is very easy to implement. Let's say you have two projects a web application and a silverlight application...
Web Application
Create your service, for example:
[ServiceContract(CallbackContract = typeof(ICallback))]
public interface ILongRunningService
{
[OperationContract]
void StartLongRunningProcess(string initialParameter);
}
[ServiceContract]
public interface ICallback
{
[OperationContract(IsOneWay = true)]
void Update(string someStateInfo);
}
public class LongRunningService : ILongRunningService
{
public void StartLongRunningProcess(string initialParameter)
{
// Get hold of the callback channel and call it once a second
// five times - you can do anything here - create a thread,
// start a timer, whatever, you just need to get the callback
// channel so that you have some way of contacting the client
// when you want to update it
var callback = OperationContext
.Current
.GetCallbackChannel<ICallback>();
ThreadPool
.QueueUserWorkItem(o =>
{
for (int i = 0; i < 5; i++)
{
callback.Update("Step " + i);
Thread.Sleep(1000);
}
});
}
}
Then you need a svc file that has this in it (adjust the service attribute to be your service implementation class):
<%# ServiceHost Service="SilverlightApplication.Web.LongRunningService" %>
Finally you will need this configuration inside web.config (this goes inside the configuration root element):
<system.serviceModel>
<extensions>
<bindingExtensions>
<add name=
"pollingDuplexHttpBinding"
type="System.ServiceModel.Configuration.PollingDuplexHttpBindingCollectionElement,System.ServiceModel.PollingDuplex, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" />
</bindingExtensions>
</extensions>
<services>
<service name="SilverlightApplication.Web.LongRunningService">
<endpoint
address=""
binding="pollingDuplexHttpBinding"
bindingConfiguration="multipleMessagesPerPollPollingDuplexHttpBinding"
contract="SilverlightApplication.Web.ILongRunningService">
</endpoint>
<endpoint
address="mex"
binding="mexHttpBinding"
contract="IMetadataExchange"/>
</service>
</services>
<bindings>
<pollingDuplexHttpBinding>
<binding name="multipleMessagesPerPollPollingDuplexHttpBinding"
duplexMode="MultipleMessagesPerPoll"
maxOutputDelay="00:00:07"/>
</pollingDuplexHttpBinding>
</bindings>
<behaviors>
<serviceBehaviors>
<behavior name="">
<serviceMetadata httpGetEnabled="true" />
<serviceDebug includeExceptionDetailInFaults="false" />
</behavior>
</serviceBehaviors>
</behaviors>
<serviceHostingEnvironment multipleSiteBindingsEnabled="true" />
</system.serviceModel>
The important parts are the name attribute on the service element and the contract attribute on the endpoint element. They should be the class and interface you defined (with the namespace).
IMPORTANT You need to add a reference to the C:\Program Files (x86)\Microsoft SDKs\Silverlight\v4.0\Libraries\ Server\System.ServiceModel.PollingDuplex.dll assembly (remove the x86 if not 64 bit OS) to the web application project.
Silverlight Application
You need to firstly add a service reference to the service you created and then, let's say you want to call the service from a button you would have the following code:
private void button1_Click(object sender, RoutedEventArgs e)
{
// Create the client proxy with the URL of the service
var proxy = new LongRunningServiceClient(
new PollingDuplexHttpBinding(
PollingDuplexMode.MultipleMessagesPerPoll),
new EndpointAddress(
"http://localhost/WebApplication/LongRunningService.svc"));
// Attach the handler to be called periodically and start the process
proxy.UpdateReceived += Update;
proxy.StartLongRunningProcessAsync("blah");
}
private void Update(object sender, UpdateReceivedEventArgs e)
{
// Use the result from the e parameter here
}
IMPORTANT You need to add a reference to the C:\Program Files (x86)\Microsoft SDKs\Silverlight\v4.0\Libraries\ Client\System.ServiceModel.PollingDuplex.dll assembly (remove the x86 if not 64 bit OS) to the silverlight client project.
And that is it - the Update method will get called, in this case once a second five times. but you can do whatever you like.
I would NOT recommend using a polling duplex to solve this business requirement, due to the load it places in the server. What I read was that you have a need to return several files back to the client, and provide feedback to the client as the files are being downloaded.
As downloading a file does not seem to be an issue (which should be a stream), I think you are asking is how to update the UI, while the files are being downloaded, perhaps capturing how much of the file is actually being downloaded. At the least, you should be updating the UI as each file arrives.
The latter is easy, simply download the download links to each file on the client, do them one by one, and update the UI between file downloads. That would be a single threaded approach.
Update the UI while a background thread is executing, is a more complicated approach, but a much better implementation, as the client "feels" that they remain in control while the files are being downloaded. Here is an approach for downloading a file async.
Remember in SilverLight, you really only have HTTP to transfer information to the application, which cannot do duplex. HTTP long pooling achieves the same result, but connections are left open, and greatly minimize the ability to scale.

MsmqException (0xC00E0051) after 60 seconds

I am using the netMsmqBinding with a transactional queue, and although the WCF service is called without problems, the service is throwing a MsmqException just 60 seconds after the message is processed.
This is the exception:
System.ServiceModel.MsmqException (0xC00E0051): An error occurred while receiving a message from the queue: Unrecognized error
-1072824239 (0xc00e0051). Ensure that MSMQ is installed and running. Make sure the queue is available to receive from. at
System.ServiceModel.Channels.MsmqInputChannelBase.TryReceive(TimeSpan
timeout, Message& message) at
System.ServiceModel.Dispatcher.InputChannelBinder.TryReceive(TimeSpan
timeout, RequestContext& requestContext) at
System.ServiceModel.Dispatcher.ErrorHandlingReceiver.TryReceive(TimeSpan
timeout, RequestContext& requestContext)
I have done some research, debugging and tracing and I have found that when a new message is received, two transactions are opened, the first one is committed just after the service execution, but the second one is never committed, so then, after 60 seconds, the DTC aborts it throwing the MsmqException.
This is the operation definition:
[OperationBehavior(TransactionScopeRequired = true, TransactionAutoComplete = true)]
public void SomeOperation(SomeParameter parameter)
{
// business logic
}
Any ideas about what is happening, and how can I solve this issue?
UPDATE:
Config:
<netMsmqBinding>
<binding name="TransactionalMsmqBinding" exactlyOnce="true" deadLetterQueue="System" receiveErrorHandling="Move">
<security mode="None"/>
</binding>
</netMsmqBinding>
...
<service name="SomeNamespace.SomeService">
<endpoint contract="SomeNamespace.ISomeService" bindingConfiguration="TransactionalMsmqBinding" binding="netMsmqBinding" address="net.msmq://localhost/private/services/someservice.svc">
</endpoint>
<endpoint contract="SomeNamespace.IAnotherService" bindingConfiguration="TransactionalMsmqBinding" binding="netMsmqBinding" address="net.msmq://localhost/private/services/anotherservice.svc">
</endpoint>
</service>
Service Implementation:
[ExceptionShieldingBehavior(typeof(ArgumentValidationException), typeof(ValidationServiceException))]
[AuthorizationAndAuditBehaviour]
[ServiceBehavior(Namespace = GlobalConstants.ServiceContractNamespace)]
public class SomeService: ISomeService, IAnotherService
{
[OperationBehavior(TransactionScopeRequired = true, TransactionAutoComplete = true)]
public void SomeOperation(SomeParameter parameter)
{
// business logic
}
[OperationBehavior(TransactionScopeRequired = true, TransactionAutoComplete = true)]
public void AnotherOperation(AnotherParameter parameter)
{
// business logic
}
}
Service Contracts:
[ServiceContract(Namespace = GlobalConstants.ServiceContractNamespace)]
public interface ISomeService
{
[OperationContract(IsOneWay = true)]
void SomeOperation(SomeParameter parameter);
}
[ServiceContract(Namespace = GlobalConstants.ServiceContractNamespace)]
public interface IAnotherService
{
[OperationContract(IsOneWay = true)]
void AnotherOperation(AnotherParameter parameter);
}
Complete behavior:
The client sends a message
The service is activated
The DTC starts two transactions (I can see them in the DTC monitor and in the TransactionManager.DistributedTransactionStarted event)
The first transaction finishes as soon as the operation finishes
The second transaction is aborted 60 seconds after (MsmqException is thrown)
The wcf host (IIS) is sometimes faulted (I have some code to automatically recover it, apparently this behaviour has changed in .net 4)
If the host was broken and automatically recovered, all will happen again on next message
If the host was not broken, the second transaction won't start the next time and everything will work without problems :).
If I recycle the AppPool, the problem starts again
I have found the problem.
As I am exposing the same Service using two different msmq Endpoints, for some weird reason the SMSvcHost.exe process activates the same Endpoint twice.
I have just written a post with the solution: http://blog.jorgef.net/2011/07/msmqexception.html
I hope it helps.
Jorge