c# - BizTalk 和自定义绑定并禁用接收位置
问题描述
我已经为基于 RabbitMQ.ServiceModel 的 BizTalk 创建了一个自定义绑定 (System.ServiceModel.Channels.Binding)
当队列不存在时,我正在尝试禁用我的接收位置。public override void Open(TimeSpan timeout)
我可以检测到 in中缺少队列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
}
}
}
解决方案
首先是在 WCF 自定义接收位置上启用DisableLocationOnFailure属性。
然后需要在队列丢失时在方法IInputChannel.TryReceive中抛出异常。
推荐阅读
- streamsets - StreamSets - 如何为 oracle jdbc 生产者绑定变量
- azure-functions - 侦听每个 Azure Function App 实例中的数据库更改
- javascript - 根据日期和唯一 ID 过滤数组
- bixby - 如何将 json 文件提取到 Bixby 中的本地文件系统?
- compare - 在 LVCompare.vi 中打开 VI 引用
- javascript - Angular 2 修复动态粒子 JS 无法读取 null 的属性“getElementsByClassName”
- php - 警告:sizeof():参数必须是数组或实现了 Countable php7.2 的对象
- ruby - 如何在 Ruby 中连接两个嵌套子数组(在多维数组中)元素?
- javascript - Promises 解决的不清楚的问题
- python-3.x - ModuleNotFoundError:在 Python3.8 上安装 pythonnet 期间没有名为“wheel”的模块