简体   繁体   English

如何从Java中的Azure Service Bus队列中提取消息?

[英]How to pull the messages from Azure Service Bus Queue in Java?

I want to pull the messages from Azure service bus queue. 我想从Azure服务总线队列中提取消息。 I can pull it from the sample code provided here . 我可以从此处提供的示例代码中提取它。 The messages which are coming are coming line by line. 即将来临的消息正在逐行传出。 In my case I need the entire message at once. 就我而言,我需要一次完整的消息。 How to do it? 怎么做?

@AnandDeshmukh, there are two way to pull messages from Azure Service Bus Queue, which include AMQP with JMS , REST API via HTTP . @AnandDeshmukh,有两种方法可以从Azure服务总线队列中提取消息,包括AMQP和JMS以及通过HTTP的REST API

I see you are using Azure Service Bus SDK for Java when you are refering to the tutorial to pull messages. 当您参考教程提取消息时,我看到您正在使用Azure Service Bus SDK for Java。 According to the source codes of the SDK for Java on GitHub, you can discover that the SDK just wrapped the related REST APIs which only get a message via HTTP protocol at a time. 根据GitHub上Java版SDK的源代码 ,您会发现SDK只是包装了相关的REST API,这些REST API一次只能通过HTTP协议获取消息。

Although I don't know what your application scene is, if you want high performance for receiving messages, I recommend the better way is using AMQP for getting messages from queue. 尽管我不知道您的应用程序场景是什么,但是如果您想要高性能来接收消息,我建议更好的方法是使用AMQP从队列中获取消息。 AMQP is a binary, application layer protocol, designed to efficiently support a wide variety of messaging applications and communication patterns, please see https://en.wikipedia.org/wiki/Advanced_Message_Queuing_Protocol to know it. AMQP是二进制的应用程序层协议,旨在有效地支持各种消息传递应用程序和通信模式,请参见https://en.wikipedia.org/wiki/Advanced_Message_Queuing_Protocol进行了解。

You can not get all messages at once but you can always make their batch(session) to deliver at once. 您不能一次获得所有消息,但始终可以使它们的批处理(会话)立即发送。 For enabling session in service bus you need to do two changes. 要在服务总线中启用会话,您需要进行两项更改。

1. While creating service bus chose to Enable Session 2. While pushing messaging to Service Bus set property SessionId of Message to same id for a batch

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 NPE从Azure服务总线队列接收消息时 - NPE while receiving messages from Azure Service bus Queue 互操作性 Azure 服务总线消息队列消息 - Interoperability Azure Service Bus Message Queue Messages Java:从Windows Azure服务总线队列接收答案 - Java: Receive answer from Windows Azure Service Bus Queue 如何使用 Java 在 Azure 服务总线中创建队列? - How to create a Queue in Azure Service Bus using Java? 从服务总线队列中读取死信消息 - Reading deadlettered messages from service bus queue 如何从Azure Service总线接收批量消息 - How to Receive Bulk Messages from Azure Service bus Azure服务总线IQueueClient.registerSessionHandler:无法连续使用来自队列/主题的消息 - Azure Service Bus IQueueClient.registerSessionHandler: Unable to consume messages continuously from Queue/Topic Java:Azure 服务总线队列通过会话接收消息 - Java: Azure Service Bus Queue Receiving messsages with sessions 使用 Java 程序接收 Azure 服务总线队列中的待处理消息? - Receive pending message in Azure Service Bus queue with Java program? 我们如何使用 java 对 azure 服务总线队列中存在的消息添加延迟? - How can we add a delay on the message which is present in azure service bus queue using java?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM