【问题标题】:BizTalk and Custom Binding and disable receive locationBizTalk 和自定义绑定并禁用接收位置
【发布时间】:2018-11-08 11:01:03
【问题描述】:

我已经为基于 RabbitMQ.ServiceModel 的 BizTalk 创建了一个自定义绑定 (System.ServiceModel.Channels.Binding)

https://github.com/CymaticLabs/Unity3D.Amqp/tree/master/lib/rabbitmq-dotnet-client-rabbitmq_v3_4_4/projects/wcf/RabbitMQ.ServiceModel/src/serviceModel

当队列不存在时,我正在尝试禁用我的接收位置。 我可以检测到RabbitMQInputChannel.cs 中的public override void Open(TimeSpan timeout) 中缺少队列,但我不知道如何禁用我的接收位置。

https://github.com/CymaticLabs/Unity3D.Amqp/blob/master/lib/rabbitmq-dotnet-client-rabbitmq_v3_4_4/projects/wcf/RabbitMQ.ServiceModel/src/serviceModel/RabbitMQInputChannel.cs

    namespace RabbitMQ.ServiceModel
    {
        internal sealed class RabbitMQInputChannel : RabbitMQInputChannelBase // Implement interface IChannel and IInputChannel
        {
            [...]

            public override void Open(TimeSpan timeout)
            {
                try
                {
                    if (State != CommunicationState.Created && State != CommunicationState.Closed)
                    {
                        this.Close();
                        throw new InvalidOperationException(string.Format("Cannot open the channel from the {0} state.", base.State));
                    }
                    OnOpening();

                    string queueName = m_bindingElement.QueueName;
                    string key = m_bindingElement.RoutingKey == null ? string.Empty : m_bindingElement.RoutingKey;
                    string exchange = m_bindingElement.ExchangeName;


                    if (m_bindingElement.QueueDeclare)
                    {
                        try
                        {
                            m_model.QueueDeclare(queueName, true, false, false, null);
                        }
                        catch (Exception ex)
                        {

                        }
                    }


                    //Listen to the queue
                    m_consumer = new EventingBasicConsumer(m_model);
                    m_consumer.ConsumerCancelled += OnConsumerCancelled;
                    m_consumer.Received += (sender, args) => m_queue.Add(args);
                    m_model.BasicConsume(queueName, false, m_consumer);

                    OnOpened();


                }
                catch(Exception ex)
                {
                    EventLogHelper.WriteError(ex.Message);
                    this.Close();
                }
            }

            private void OnConsumerCancelled(object sender, ConsumerEventArgs e)
            {
                // HERE I WANT TO DISABLE MY RECEIVE LOCATION

            }
        }
    }

【问题讨论】:

    标签: c# binding biztalk


    【解决方案1】:

    首先要在 WCF 自定义接收位置上启用 DisableLocationOnFailure 属性。

    那么你需要在队列丢失时在方法IInputChannel.TryReceive中抛出异常。

    【讨论】:

    • 那行不通。 TryReceive 仅在队列中发布消息时调用,而不是在队列已被删除时调用
    • IInputChannel.BeginWaitForMessage 怎么样
    猜你喜欢
    • 1970-01-01
    • 2018-10-03
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-06-25
    • 2010-12-06
    相关资源
    最近更新 更多