Tag: azureservicebus

Azure Service Bus中BrokeredMessage主体的编码

我们在Azure Service Bus客户端周围有以下包装器: public virtual void SendMessage(object bodyObject) { var brokeredMessage = _messageBodySerializer.SerializeMessageBody(bodyObject); _queueClient.Send(brokeredMessage); } 使用SerializeMessageBody包含: public BrokeredMessage SerializeMessageBody(object bodyObject) { var brokeredMessage = new BrokeredMessage(bodyObject); brokeredMessage.Properties[MESSAGE_TYPE_PROPERTY_KEY] = bodyObject.GetType().AssemblyQualifiedName; return brokeredMessage; } 我已经编写了一个集成测试,通过运行SendMessage然后使用Service Bus Explorer 2.0查看消息内容来检查这是否有效。 我们这样做是为了确保我们可以使用该工具修改和重新发送消息来修改XML。 我发送的消息如下: [DataContract] public class TestServiceBusMessage { [DataMember] public Guid ExternalIdentifier { get; set; } [DataMember] public int Identifier […]

在Azure Service Bus中获取消息统计信息

我正在编写一个实用程序来监视我们的Azure服务总线主题和订阅。 我可以获取主题详细信息,例如名称,排队消息计数和死信消息计数,但我想获取已处理的消息数。 这是我正在使用的代码: var sub = namespaceManager.GetSubscription(topicPath, subscriptionName); var name = sub.Name; var pending= sub.MessageCountDetails.ActiveMessageCount; var deadletter = sub.MessageCountDetails.DeadLetterMessageCount 似乎GetSubscription不包含任何属性来获取处理的消息数。 有没有人试过这样做呢?

如何在Azure Service Bus主题上删除DeadLetter消息

我正在写一段代码,这将允许我们: 查看Azure Service Bus主题(Peek)中存在的所有死信消息的列表 修复并将它们发送回主题 重新发送时从死信队列中删除它们。 前2分我没有问题; 使用Peek接收模式,我可以显示消息列表,我们可以编辑和重新发送,没有任何问题。 当我想要实际从死信队列中删除消息时,问题出现了。 我们如何通过消息级别对消息执行此操作? 我们可能只想删除驻留在死信队列中的2条消息,并保留其他消息以便稍后查看。 在死信队列中的消息上调用.Complete()是否像在主订阅中那样删除它? 以供参考; 这是我们获取死信队列的SubscriptionClient代码: private SubscriptionClient GetOrCreateSubscriptionClient(string connectionString) { if (!NamespaceManager.TopicExists(_topicName)) { NamespaceManager.CreateTopic(new TopicDescription(_topicName) { MaxSizeInMegabytes = 5120, DefaultMessageTimeToLive = TimeSpan.FromSeconds(DEFAULT_LOCK_DURATION_IN_SECONDS) }); } if (!NamespaceManager.SubscriptionExists(_topicName, _subscriptionName)) { NamespaceManager.CreateSubscription(_topicName, _subscriptionName); } var deadLetterPath = SubscriptionClient.FormatDeadLetterPath(_topicName, _subscriptionName); var client = SubscriptionClient.CreateFromConnectionString( connectionString, deadLetterPath, _subscriptionName, ReceiveMode.PeekLock); return client; […]

为什么手动引发的瞬态错误exception被处理为AggregateException?

当我尝试手动引发瞬态exception时,它总是作为AggregateException处理。 由于它作为AggregateException处理,因此在我的重试策略中不会将其作为暂时性error handling,也不会针对预定义的重试计数进行重试。 此处显示瞬态错误。 因此,我尝试了CommunicationException和ServerErrorException但它作为AggregateException处理。 当我查找AggregateException时,它会显示“表示在应用程序执行期间发生的一个或多个错误”。 是的,它非常有用!!! 以下是我案例的示例代码: 我有一个使用ServiceBusTransientErrorDetectionStrategy的重试策略 public void TestManually() { var retryPolicy = new RetryPolicy(RetryStrategy.DefaultFixed); retryPolicy.Retrying += (obj, eventArgs) => { Trace.TraceError(“Hey!! I’m Retrying, CurrentRetryCount = {0} , Exception = {1}”, eventArgs.CurrentRetryCount, eventArgs.LastException.Message); }; retryPolicy.ExecuteAsync(() => MyTestFunction().ContinueWith(t => { if (t.Exception != null) { // A non-transient exception occurred or retry limit […]

如何通过端口80向Azure Service Bus发送消息?

据我所知,Azure Service总线使用端口9350,9353等来发送消息。 在我的组织中,由于防火墙策略,我们无法打开这些端口。 因此,每当我尝试将消息发送到Azure中的队列时,我都会收到错误消息 主机mycloudsevice.servicebus.windows.net不存在DNS条目“。 有没有办法通过端口80/443发送这些,因为它们总是打开的? 如果我能做任何示例或代码更改,请告诉我。

Azure Service Bus无法接收JSON正文

调试此代码时,应用程序停止。 没有显示错误消息或exception。 X计划: client.OnMessage((message) => { using (var stream = message.GetBody()) using (var streamReader = new StreamReader(stream, Encoding.UTF8)) { var body = streamReader.ReadToEnd(); } } 下面我通过REST API发布JSON对象。 项目Y: public void CreateMessage(T messageToSend, string queueAddress, WebClient webclient) { var apiVersion = “&api-version=2014-01”; var serializedMessage = JsonConvert.SerializeObject(messageToSend, Formatting.Indented); string receivedMessageBody = webclient.UploadString(queueAddress + “/messages” + “?timeout=60&” + […]

使用未处理的Service Bus故障消息回收Azure辅助角色

我一直在运行Azure辅助角色部署,该部署使用Microsoft.ServiceBus 2.2库来响应从其他辅助角色和Web角色发布的作业。 最近(在这里讨论的操作系统更新时间可疑),群集的实例开始不断回收,重新启动,运行一小段时间,然后再次回收。 我可以确认角色实例从我在诊断中的跟踪消息中一直通过我的RoleEntryPoint的OnStart()方法。 有时,Azure管理门户的“实例”窗格会提到回收角色遇到“未处理的exception”,但不会提供更多详细信息。 使用远程桌面登录到其中一个实例后,我拥有的两条线索是: 性能计数器指示\处理器(_Total)\%处理器时间hover在100%,定期下降到80年代中期,与\ TCPv4 \ Connections Established下降同时发生。 \ TCPv4 \ Connections Established中的某些内容与\ Processor(_Total)\%Processor Time中的下降不相关。 我能够在其中一个实例的服务器管理器中的本地服务器事件中找到以下消息: 应用程序:WaWorkerHost.exe Framework版本:v4.0.30319描述:由于未处理的exception,进程已终止。 exception信息:Microsoft.ServiceBus.Common.CallbackException Stack:at System.Threading._IOCompletionCallback.PerformIOCompletionCallback(UInt32,UInt32,System)中的Microsoft.ServiceBus.Common.Fx + IOCompletionThunk.UnhandledExceptionFrame(UInt32,UInt32,System.Threading.NativeOverlapped *) .Threading.NativeOverlapped *) 在此期间,没有与服务总线关联的权限配置更改,尽管我们没有更新任何VM,但仍会出现此消息。 尽管如此,似乎我们的服务仍在运行=>正在处理作业并将其从正在收听的服务总线队列中删除。 关于这些问题的大多数谷歌搜索都提出了这种与IntelliTrace有某种关系的建议,但是,这些虚拟机没有启用IntelliTrace。 有没有人对这里发生的事情有任何想法?

如何更改服务总线队列的属性?

我正在使用服务总线队列在Web角色和工作者角色之间进行通信。 有时工作者角色不接受Web角色消息。 但它立即接受我发送的下一条消息。 所以我想也许它正在发生,因为批处理操作已启用。 我一直试图把它弄错,但我还没有成功。 这是我的代码。 public static QueueClient GetServiceBusQueueClient(string queuename) { string connectionString; if (RoleEnvironment.IsAvailable) connectionString = CloudConfigurationManager.GetSetting(“Microsoft.ServiceBus.ConnectionString”); else connectionString = ConfigurationManager.AppSettings[“Microsoft.ServiceBus.ConnectionString”]; var namespaceManager = NamespaceManager.CreateFromConnectionString(connectionString); QueueDescription queue = null; if (!namespaceManager.QueueExists(queuename)) { queue = namespaceManager.CreateQueue(queuename); queue.EnableBatchedOperations = false; queue.MaxDeliveryCount = 1000; } else { queue = namespaceManager.GetQueue(queuename); queue.EnableBatchedOperations = false; queue.MaxDeliveryCount = 1000; […]

将Azure ServiceBus上的消息从.NET Core发送器发送到.NET 4.6处理程序

我想从.NET Core控制台应用程序通过Azure Service Bus发送消息,并在.NET 4.6控制台应用程序中接收它。 在.NET Core中,我使用Azure的新服务总线客户端作为发送者,但尚未用于生产(根据他们的自述文件)。 https://github.com/Azure/azure-service-bus-dotnet 我可以从.NET Core发送并使用示例轻松地使用.NET Core接收。 但是,当.NET 4.6应用程序订阅主题并收到相同的消息时,.NET 4.6应用程序会抛出此exception: Microsoft.Azure.WebJobs.Host.FunctionInvocationException: Exception while executing function: Functions.ProcessEvent System.InvalidOperationException: Exception binding parameter ‘message’ The BrokeredMessage with ContentType ‘string’ failed to deserialize to a string with the message: ‘Expecting element ‘string’ from namespace ‘http://schemas.microsoft.com/2003/10/Serialization/’.. Encountered ‘Element’ with name ‘base64Binary’, namespace http://schemas.microsoft.com/2003/10/Serialization/’. ‘ —> System.Runtime.Serialization.SerializationException: […]

Service Bus 1.1使用WindowsAzure.ServiceBus dll创建队列

我正准备开发连接到Azure Service Bus的应用程序。 对于开发,我想使用Service Bus 1.1。 我已经安装了localy Service Bus 1.1,当我连接Service Service.v1_1 ver时,它工作正常。 1.0.5 。 但是,正如我想最终使用Azure,我更喜欢使用WindowsAzure Service Bus,我知道sholud与Service Bus 1.1一起使用。 但是当我想执行时: namespaceManager.QueueExists(queueName) 使用WindowsAzure.ServiceBus ver 3.1.2包我收到: ‘System.ArgumentException’ …. The remote server returned an error: (400) Bad Request. The api-version in the query string is not supported. Either remove it from the Uri or use one of ‘2012-03,2012-08,2013-04,2013-07’. […]