工作中使用的版本2.0.0.1219無法獲得自我主機上NServiceBus
我試圖自我主機都基於用戶和出版商與NServiceBus和VS2010。程序運行並初始化,但我無法獲得消息。發佈者的行爲就像發佈一樣,沒有錯誤,但訂閱者一無所獲。
下面是用戶配置
<?xml version="1.0"?>
<configuration>
<configSections>
<section name="MsmqTransportConfig" type="NServiceBus.Config.MsmqTransportConfig, NServiceBus.Core"/>
<section name="UnicastBusConfig" type="NServiceBus.Config.UnicastBusConfig, NServiceBus.Core"/>
</configSections>
<!-- in order to configure remote endpoints use the format: "[email protected]"
input queue must be on the same machine as the process feeding off of it.
error queue can (and often should) be on a different machine.
-->
<MsmqTransportConfig InputQueue="loads" ErrorQueue="error" NumberOfWorkerThreads="1" MaxRetries="5"/>
<UnicastBusConfig>
<MessageEndpointMappings>
<add Messages="NServiceMessage" Endpoint="loads"/>
</MessageEndpointMappings>
</UnicastBusConfig>
<startup><supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.0"/></startup></configuration>
和發佈服務器配置
<?xml version="1.0"?>
<configuration>
<configSections>
<section name="MsmqTransportConfig" type="NServiceBus.Config.MsmqTransportConfig, NServiceBus.Core"/>
<section name="UnicastBusConfig" type="NServiceBus.Config.UnicastBusConfig, NServiceBus.Core"/>
</configSections>
<MsmqTransportConfig InputQueue="loads" ErrorQueue="error" NumberOfWorkerThreads="1" MaxRetries="5"/>
<UnicastBusConfig DistributorControlAddress="" DistributorDataAddress="" ForwardReceivedMessagesTo="">
<MessageEndpointMappings>
<!-- publishers don't need to set this for their own message types -->
<!--<add Messages="Messages" Endpoint="messagebus" />-->
</MessageEndpointMappings>
</UnicastBusConfig>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.0"/>
</startup>
</configuration>
這裏是發行代碼:
class Program
{
private static IBus _serviceBus;
static void Main(string[] args)
{
_serviceBus = Configure.With()
.Log4Net()
.DefaultBuilder()
.XmlSerializer()
.MsmqSubscriptionStorage()
.MsmqTransport()
.UnicastBus()
.LoadMessageHandlers()
.CreateBus()
.Start();
while (true)
{
Console.WriteLine("Press a key to send data.");
Console.ReadKey();
SendMessaage();
}
}
private static void SendMessaage()
{
LoadMessage message = GetNextMessage();
_serviceBus.Publish(message);
}
private static LoadMessage GetNextMessage()
{
LoadMessage result = new LoadMessage();
result.DeliveryDate = DateTime.Today.AddDays(3).ToShortDateString();
result.DestinationCity = "Boise";
result.DestinationCountry = "USA";
result.DestinationState = "ID";
result.EventId = Guid.NewGuid();
result.Time = DateTime.Now.ToUniversalTime();
result.OriginState = "OR";
result.OriginCity = "Portland";
result.OriginCountry = "USA";
result.EquipmentID = 3;
return result;
}
}
與認購代碼
class Program
{
private static IBus _serviceBus;
private static LoadMessageHandler _messageHandler;
static void Main(string[] args)
{
_messageHandler = new LoadMessageHandler();
_serviceBus = Configure
.With()
.Log4Net()
.DefaultBuilder()
.BinarySerializer()
.MsmqSubscriptionStorage()
.MsmqTransport()
.UnicastBus()
.LoadMessageHandlers()
.CreateBus()
.Start();
Console.ReadKey();
}
}
和消息代碼
public class LoadMessageHandler : IHandleMessages<LoadMessage>
{
public void Handle(LoadMessage message)
{
Console.WriteLine(String.Format("GUID: {0}", message.EventId));
}
}
需要更完整的代碼(包括名稱空間和目標dll)來確定此問題的原因。 NServiceMessage在 指向LoadMessage類型定義的dll。 –
Cirdec
2010-08-25 18:54:39