小编Mic*_*rio的帖子

是否有可能使用MSMQ MessageQueue.Peek丢失消息并超时?

我目前遇到丢失消息的问题.这个错误很少发生,但经常发生,这很烦人.以下是该问题的背景:

  • 我已经打开了goldmine_service_queue上的消息日志,这是Windows 2003服务器上的MSMQ.
  • 我可以证明消息正在插入goldmine_service_queue,因为消息出现在消息日志中.此信息提供有关消息何时消失的计时信息.
  • 日志记录功能使用http://logging.apache.org/log4net/index.html
  • 日志不显示错误.
  • worker函数(如下所示)在Windows服务的一个线程中执行.它负责从队列中查看消息(工作项)并处理它们.
  • 从日志中,我强烈怀疑我的问题可能与MessageQueue.Peek和超时行为有关.

超时和消息接收是否可能同时发生?有没有更好的方法来处理服务停止检查以帮助避免此错误?

        private void workerFunction()
    {

        logger.Info("Connecting to queue: " + Settings.Default.goldmine_service_queue);
        MessageQueue q = new MessageQueue(Settings.Default.goldmine_service_queue);
        q.Formatter = new ActiveXMessageFormatter();

        while (serviceStarted)
        {

            Message currentMessage = null;

            try
            {
                currentMessage = q.Peek(new TimeSpan(0,0,30));
            }
            catch (System.Messaging.MessageQueueException mqEx)
            {
                if (mqEx.ToString().Contains("Timeout for the requested operation has expired"))
                {
                    logger.Info("Check for service stop request");
                }
                else
                {
                    logger.Error("Exception while peeking into MSMQ: " + mqEx.ToString());
                }
            }
            catch (Exception e)
            {
                logger.Error("Exception while …
Run Code Online (Sandbox Code Playgroud)

c# windows-services msmq

5
推荐指数
1
解决办法
8072
查看次数

使用BDD测试的开源项目?

我的团队更了解BDD.

是否有使用行为驱动开发(BDD)的开源.NET/Java项目?

我想把注意力集中在静态语言示例上.

c# java vb.net bdd

5
推荐指数
1
解决办法
1074
查看次数

从IronRuby调用C#

我在库中创建了一个小的C#类.

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace helloWorldLib
{
    public class Greeter
    {
        public string SayHelloWorld(string name)
        {
            return "Hello world " + name;
        }
    }
}
Run Code Online (Sandbox Code Playgroud)

图书馆位于

C:\ Documents and Settings\myUser\My Documents\Visual Studio 2008\Projects\Project1\helloWorldLib\bin\Debug\helloWorldLib.dll

你会如何从IronRuby脚本中调用SayHelloWorld?

我知道这看起来很简单,但经过大量研究后我似乎无法找到一致的代码示例.

非常感谢!

c# ironruby

4
推荐指数
1
解决办法
1705
查看次数

标签 统计

c# ×3

bdd ×1

ironruby ×1

java ×1

msmq ×1

vb.net ×1

windows-services ×1