标签: nservicebus

是否可以在 launchsettings.json 中将executablePath 指定为相对路径?

我正在查看一位前同事编写的项目,在文件中launchSettings.json(在“属性”下)他有以下内容:

{
  "profiles": {
    "ProjectName": {
      "commandName": "Executable",
      "executablePath": "C:\\code\\project\\\\src\\project.name\\bin\\Debug\\net471\\NServiceBus.Host.exe"
    }
  }
}
Run Code Online (Sandbox Code Playgroud)

executablePath是他的本地存储库所在的路径。但当然,其他团队成员不会有相同的本地路径。这很好,而不是我们应该强制执行的。

两个问题:

  • 为什么它在那里,它的目的是什么?
  • 这可以是相对路径吗?->是的,可以

->“..\net471\NServiceBus.Host.exe”

.net c# nservicebus

7
推荐指数
2
解决办法
3508
查看次数

NServiceBus重试延迟

配置/编码NServiceBus以延迟重试消息的最佳方法是什么?

在其默认配置中,重试几乎立即发生,直到配置文件中定义的尝试次数.我想在一小时后再次重试等等.

另外,HandleCurrentMessageLater()工作怎么样?什么是Later方面是指什么?

nservicebus

6
推荐指数
1
解决办法
2236
查看次数

无法让自己的主机在NServiceBus上工作

使用版本2.0.0.1219

我试图通过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: "queue@machine" 
       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>
Run Code Online (Sandbox Code Playgroud)

和发布者配置

<?xml version="1.0"?>
<configuration>

  <configSections>
    <section name="MsmqTransportConfig" type="NServiceBus.Config.MsmqTransportConfig, NServiceBus.Core"/>
    <section name="UnicastBusConfig" …
Run Code Online (Sandbox Code Playgroud)

.net c# nservicebus servicebus

6
推荐指数
2
解决办法
2224
查看次数

使用NServiceBus测试Bus.Send应用程序

我在使用NServiceBus的应用程序.NET应用程序中有这个代码:

 Bus.Send<IServiceStarted>(e =>
                             {
                                  e.ServiceInfo = ReadServiceInfo();
                                  e.EventTime = DateProvider.Now;
                             });
Run Code Online (Sandbox Code Playgroud)

你会如何对这样的代码进行单元测试?

c# unit-testing rhino-mocks mocking nservicebus

6
推荐指数
1
解决办法
4325
查看次数

NServiceBus(AsA_Server)没有DTC吗?

我第一次使用NServiceBus并且有一个小的,简单的应用程序,用户提交表单,然后表单字段被发送到队列,处理程序收集这些数据并使用linq-to-sql将其写入数据库.

就DBA而言,组件服务中的任何更改都是完全禁止的,所以我现在正在寻找DTC的替代方案(在数据库服务器上未启用),但是使用AsA_Server以便消息不会得到清除.

我已经尝试在IConfigureThisEndpoint之后删除AsA_Server并自己指定配置,但这似乎不起作用(控制台出现,页面加载但没有任何反应,它甚至没有在断点处停止.)AsA_Client确实有效,但据我了解消息将在启动时被清除,我需要避免.

有什么建议?

谢谢,

OMK

编辑:现在已经通过在禁止事务范围中使用包装对数据库的调用来解决这个问题,这允许在没有环境事务的情况下完成数据库工作以登记:

using (TransactionScope sc = new TransactionScope(TransactionScopeOption.Suppress)) 
{ 
     // code here 
     sc.Complete(); 
} 
Run Code Online (Sandbox Code Playgroud)

msdtc nservicebus linq-to-sql

6
推荐指数
4
解决办法
1930
查看次数

NServiceBus处理程序单元测试的依赖注入

这是你应该如何为NServiceBus处理程序注入依赖项来测试它:

Test.Handler<YourMessageHandler>()
  .WithExternalDependencies(h => h.Dependency = yourObj)
Run Code Online (Sandbox Code Playgroud)

(http://nservicebus.com/UnitTesting.aspx)

但是这意味着我的Dependency对象引用应该公开,我不喜欢.有没有办法让它保持私有readonly并在构造函数中分配它,所以应该只通过处理程序构造函数传递实现?

谢谢

c# unit-testing dependency-injection nservicebus

6
推荐指数
1
解决办法
2383
查看次数

NServiceBus警告"无法找到消息类型的处理程序"

我是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)

c# nservicebus

6
推荐指数
1
解决办法
5709
查看次数

TransactionScopeOptions.Suppress 超时

在我刚刚接手的一个应用程序中发现了这一行,并没有多大意义。

using (new TransactionScope(TransactionScopeOption.Suppress, new TimeSpan(1,0,0))) {

这会立即发生在 nservicebus 消息处理程序方法内并覆盖整个处理程序。

它似乎试图抑制环境事务并在一小时后中止。超时到期后会发生什么?我认为这只是选项的组合,并不意味着任何合理的事情。但它会导致什么情况发生呢?

c# transactions nservicebus

6
推荐指数
1
解决办法
1111
查看次数

NServiceBus 4.0的RavenDB错误

我已经下载并安装了NServiceBus 4.0,但是当公交车启动时我遇到了一些困难......

2013-09-18 15:53:40,887 [1] WARN NServiceBus.Persistence.Raven.RavenUserInstall er [(null)] <(null)> - 无法将用户添加到raven.处理将继续System.MissingMethodException:找不到方法:'Raven.Abstractions.Data.PutRes ult Raven.Client.Connection.IDatabaseCommands.Put(System.String,System.Nullable`1,Raven.Json.Linq.RavenJObject,Raven. Json.Linq.RavenJObject)".at NServiceBus.Persistence.Raven.RavenUserInstaller.AddUserToDatabase(String identity,DocumentStore documentStore)位于c:\ BuildAgent\work\d4de8921a0aabf04\src\NServiceBus.Core\Persistence\Raven中的NServiceBus.Persistence.Raven.RavenUserInstaller.Install(字符串标识)\Ra venUserInstaller.cs:第40行

当我尝试将更改保留到文档存储区时...

 public class RavenUnitOfWork: IManageUnitsOfWork
    {
        public IDocumentSession Session { get; set; }
        public void Begin()
        {

        }

        public void End(Exception ex = null)
        {
            if (ex == null && Session != null)
            {
                Console.WriteLine("Saving Changes to DB.");
                 Session.SaveChanges();
            }
        }
    }

produces


    2013-09-18 15:57:38,007 [13] INFO  NServiceBus.Unicast.Transport.TransportReceiv
    er [(null)] <(null)> - Failed to process message
    System.InvalidOperationException: Url: "/bulk_docs"

    System.FormatException: …
Run Code Online (Sandbox Code Playgroud)

nservicebus ravendb

6
推荐指数
1
解决办法
2038
查看次数

如何检查RavenDB中是否存在表(实体)

我使用Raven.Client.Lightweight 2.5库查询RavenDB中的内置TimeoutData实体以获取特定的超时文档.数据库中可能不存在TimeoutData,因为还没有文档存储在那里.在这种情况下,当您尝试查询时抛出NotSupportedException.

目前我已经为这种情况创建了解决方法:

try
{
    timeoutData = _session.Query<TimeoutData>().FirstOrDefault(t => t.Headers.ContainsValue(someValue));
}
catch (NotSupportedException)
{
    return null;
}
Run Code Online (Sandbox Code Playgroud)

是否可以在不使用try-catch的情况下验证TimeoutData是否存在?我也尝试了以下代码,但是当TimeoutData实体中存在文档时它返回false:

if (!_session.Query<TimeoutData>().Any())
{

}
Run Code Online (Sandbox Code Playgroud)

.net c# nservicebus ravendb

6
推荐指数
1
解决办法
365
查看次数