sqlserver清空service broker中的队列的语句分享
在我们开发service broker应用时候,可能用于测试或者客户端没有配置正确等导致服务端队列存在很多垃圾队列,不便于我们排查错误,我们可以使用SQL脚本来清空服务端这些垃圾数据
代码如下:USE TestDB
declare @conversation uniqueidentifier
while exists (select 1 from sys.transmission_queue )
begin
set @conversation = (select top 1 conversation_handle from sys.transmission_queue )
end conversation @conversation with cleanup
end
那么客户端接受到的消息如果没有处理,也会积攒在客户端队列中,其实就相当于许多未读邮件,我们可以使用以下脚本读取队列 ,读取后队列自动清空:
代码如下:
USE TestDB
DECLARE @RecvReplyMsg NVARCHAR(100) ;
DECLARE @RecvReplyDlgHandle UNIQUEIDENTIFIER ;
BEGIN TRANSACTION ;
WHILE ( 1 = 1 )
BEGIN
WAITFOR
( RECEIVE TOP(1)
@RecvReplyDlgHandle = conversation_handle,
@RecvReplyMsg = message_body
FROM dbo.Test_TargetQueue
), TIMEOUT 1000 ;
END CONVERSATION @RecvReplyDlgHandle ;
SELECT @RecvReplyMsg AS ReceivedReplyMsg ;
END
COMMIT TRANSACTION ;

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

AI Hentai Generator
Generate AI Hentai for free.

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics

deque in Python is a low-level, highly optimized deque useful for implementing elegant and efficient Pythonic queues and stacks, which are the most common list-based data types in computing. In this article, Mr. Yun Duo will learn the following together with you: Start using deque to effectively pop up and append elements. Access any element in deque. Use deque to build an efficient queue. Start using deque to append elements to the right end of a Python list and pop up elements. The operations are generally very Efficient. If time complexity is expressed in Big O, then we can say that they are O(1). And when Python needs to reallocate memory to increase the underlying list to accept new elements, these

As web applications continue to develop, we need to handle a large number of tasks to maintain the stability and availability of the application. Using a queuing system is one solution. ThinkPHP6 provides a built-in queue system to manage tasks. However, handling a large number of tasks requires better queue management, which can be achieved using Supervisor. This article will introduce how to use Supervisor to manage ThinkPHP6 queues. Before that, we need to understand some basic concepts: queue system queue system is

Performance Analysis and Optimization Strategy of JavaQueue Queue Summary: Queue (Queue) is one of the commonly used data structures in Java and is widely used in various scenarios. This article will discuss the performance issues of JavaQueue queues from two aspects: performance analysis and optimization strategies, and give specific code examples. Introduction Queue is a first-in-first-out (FIFO) data structure that can be used to implement producer-consumer mode, thread pool task queue and other scenarios. Java provides a variety of queue implementations, such as Arr

Application summary of queue technology in message delay and message retry in PHP and MySQL: With the continuous development of web applications, the demand for high concurrency processing and system reliability is getting higher and higher. As a solution, queue technology is widely used in PHP and MySQL to implement message delay and message retry functions. This article will introduce the application of queue technology in PHP and MySQL, including the basic principles of queues, methods of using queues to implement message delay, and methods of using queues to implement message retries, and give

Queue in Java is a linear data structure with multiple functions. A queue has two endpoints and it follows the first-in-first-out (FIFO) principle for inserting and deleting its elements. In this tutorial, we will learn about two important functions of queues in Java, which are add() and Offer(). What is a queue? Queue in Java is an interface that extends the util and collection packages. Elements are inserted in the backend and removed from the frontend. Queues in Java can be implemented using classes such as linked lists, DeQueue, and priority queues. A priority queue is an extended form of a normal queue, where each element has a priority. The add() method of the queue is used to insert elements into the queue. It will define the element (as

Implementation of queue task monitoring and task scheduling in PHP and MySQL Introduction In modern web application development, task queue is a very important technology. Through queues, we can queue some tasks that need to be executed in the background, and control the execution time and order of tasks through task scheduling. This article will introduce how to implement task monitoring and scheduling in PHP and MySQL, and provide specific code examples. 1. Working principle of queue Queue is a first-in-first-out (FIFO) data structure that can be used to

Linuxservice cannot use system environment variables. Detailed description: When doing a MySQL multi-instance installation before, the installation was successful and Linux could be started successfully; however, support-files/mysqld_multi.server was moved to the /etc/init.d/ directory and set to boot. Startup (chkconfigxxxon) failed; problem exploration found the problem and started to solve it. It was found that servicexxxstart could not start multiple instances of mysql, but mysqld_multistart could be used; then after various attempts, it was found that the /etc/profile settings could be printed out in a normal environment. m

Queue and asynchronous processing optimization methods in the PHP flash sale system With the rapid development of the Internet, various preferential activities on e-commerce platforms, such as flash sales and rush sales, have also become the focus of users. However, this high concurrent user request is a huge challenge for traditional PHP applications. In order to improve the performance and stability of the system and solve the pressure caused by concurrent requests, developers need to optimize the flash sale system. This article will focus on the optimization methods achieved through queues and asynchronous processing in the PHP flash sale system, and give specific code examples.
