Я борюсь с довольно странной проблемой ... Я использовал коммуникацию служебной шины (через MassTransit + MSMQ) между службами WCF, с .NET 4.0 на Windows 7 Ultimate. Когда службы запускаются, все работает нормально, и они получают сообщение друг друга, но в данный момент они больше не получают их до тех пор, пока я вручную не удалю приватные очереди в управлении компьютером -> Службы и приложения -> Очередь сообщений - > Частные очереди.Внедрение MassTransit: иногда сообщение не получено
За каждую службу у меня есть загрузчик, где я устанавливаю вне MassTransit:
// Bootstrapper configuration
public void Configure(IUnityContainer container)
{
// Service bus configuration
var config = ConfigurationDataAccess.GetSupervisionServiceConfig();
// Cleaning up the former Private Queues before to start the service
var privateQueues = MessageQueue.GetPrivateQueuesByMachine(System.Environment.MachineName);
foreach (var messageQueue in privateQueues)
{
try
{
if (messageQueue.QueueName.Contains("supervisionservice"))
{
MessageQueue.Delete(messageQueue.Path);
}
}
catch (MessageQueueException)
{
// An exception has occurred trying to remove a private message queue.
}
}
// Initializing MassTransit
var bus = ServiceBusFactory.New(sbc =>
{
sbc.UseMsmq();
sbc.VerifyMsmqConfiguration();
sbc.UseMulticastSubscriptionClient();
sbc.ReceiveFrom(config.ServiceBusReceiveFromAddress);
});
container.RegisterInstance(bus);
//Start the service...
}
}
Тогда услуг основного класса продлить MassTransit, вот пример:
[ServiceBehavior(InstanceContextMode = InstanceContextMode.Single)]
public class DataService : Consumes<ServiceMessage>.Selected
{
public DataService()
{
// The service bus object takes the instance from the bootstrapper through the dependency
// injection of the Unity.
ServiceBus.SubscribeInstance(this);
}
public bool Accept(ServiceMessage message)
{
// For an easy explanation
return true;
}
public void Consume(ServiceMessage message)
{
// Treat the message
}
public void SendMessage(ServiceMessage message)
{
// Publish the message over the service bus
ServiceBus.Publish(message);
}
}
Как я уже объяснил, в данной точке метод Accept больше не вызывается. Единственный способ - вручную удалить частные очереди и перезапустить службы. Затем система снова работает нормально, до следующей проблемы :-(.
Любые предложения будут очень благодарны.
Большое спасибо! Алессандро
Любые предложения? – Alessandro