我的app.config文件如下:
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<configSections>
<section name="ProcessConfiguration" type="Configuration.ProcessConfigurationSection, Configuration" />
</configSections>
<ProcessConfiguration>
<processes>
<process name="Process1" />
</processes>
</ProcessConfiguration>
</configuration>
Run Code Online (Sandbox Code Playgroud)
我有以下(单独)类来获取配置:
namespace Configuration
{
using System.Configuration;
public class ProcessesConfigurationSection : ConfigurationSection
{
[ConfigurationProperty("processes", IsDefaultCollection = false)]
[ConfigurationCollection(typeof(ProcessCollection))]
public ProcessCollection Processes
{
get
{
return (ProcessCollection)base["processes"];
}
}
}
}
namespace Configuration
{
using System.Configuration;
public class ProcessCollection : ConfigurationElementCollection
{
public ProcessConfig this[int index]
{
get
{
return (ProcessConfig)BaseGet(index);
}
set
{
BaseAdd(index, value);
}
}
protected …Run Code Online (Sandbox Code Playgroud) 我是NServiceBus的新手,我正在尝试开发一个发布者和单独的订阅者(我正在使用v3.2.0.0),到目前为止,它的工作正常 - 发布者和订阅者都在NServiceBus主机中运行.我的消息全部发布正常但间歇性地它们不被订阅者接收,发布者显示以下错误:
2012-09-05 14:27:37,491 [Worker.6] WARN NServiceBus.Unicast.UnicastBus [(null)] <(null)> - No handlers could be found for message type: MyNamespace.MyMessage
Run Code Online (Sandbox Code Playgroud)
但是,对于所有消息都不会出现此警告,因此,如果我在消息之后继续发布消息,我可能会看到其中一半显示消息,因此订阅者不会接收消息,尽管所有消息都出现在MSMQ队列中.
我承认我很难掌握这个,所以我的一些代码到目前为止可能完全是垃圾!
我按如下方式向NSB发布消息,消息输入是我定义的几种不同类型之一:
private void Publish<T>(T message)
{
var myBus = Configure.Instance.Builder.Build<IBus>();
myBus.Publish(message);
}
Run Code Online (Sandbox Code Playgroud)
发布者的EndpointConfig如下:
[EndpointName("MyQueue")]
public class EndpointConfig : IConfigureThisEndpoint, AsA_Publisher, IWantCustomInitialization
{
/// <summary>
/// Initialisation for NServiceBus.
/// </summary>
public void Init()
{
Configure.With()
.DefaultBuilder()
.MsmqSubscriptionStorage()
.DisableTimeoutManager()
.DefiningEventsAs(t => t.Namespace != null && t.Namespace.StartsWith("MyNamespace"));
}
}
Run Code Online (Sandbox Code Playgroud)
在订阅方,我有以下EndpointConfig:
[EndpointName("MyQueue")]
public class EndPointConfig : IConfigureThisEndpoint, AsA_Server, IWantCustomInitialization
{
public …Run Code Online (Sandbox Code Playgroud) 我有一个包含一个数据列表的表单,该数据列表绑定到一个数据源,该数据源包含一个项目列表和一个真/假标志.如果为true,则选中myCheck复选框:
<form id="myForm" runat="server">
<asp:Button ID="save" runat="server" Text="Save" OnClick="save_Click" />
<br />
<asp:DataList runat="server" id="myList" onitemdatabound="myList_ItemDataBound">
<HeaderTemplate>
<th>Item Name</th>
<th id="thCheck" runat="server">Check?</th>
</HeaderTemplate>
<ItemTemplate>
<td id="tdName" runat="server"><%# Eval("Name") %></td>
<td runat="server"><asp:CheckBox id="myCheck" runat="server" Checked="false" /></td>
</ItemTemplate>
</asp:DataList>
Run Code Online (Sandbox Code Playgroud)
单击"保存"时,我想查看已检查的项目.我使用以下内容迭代datalist中的项目:
protected void save_Click(Object sender, EventArgs e)
{
String Name;
Boolean omit;
foreach (DataListItem item in myList.Items)
{
CheckBox omitCheck = (CheckBox)item.FindControl("myCheck");
if (omitCheck != null)
{
if (omitCheck.Checked == true) // This line is my problem!!
{
// do stuff
}
break; …Run Code Online (Sandbox Code Playgroud)