A queue can be the target of a SELECT statement. However, the contents of a queue can only be modified using statements that operate on Service Broker conversations, such as SEND, RECEIVE, and END CONVERSATION. A queue cannot be the target of an INSERT, UPDATE, DELETE, or TRUNCATE statement.
A queue might not be a temporary object. Therefore, queue names starting with # are not valid.
Creating a queue in an inactive state lets you get the infrastructure in place for a service before allowing messages to be received on the queue.
Service Broker does not stop activation stored procedures when there are no messages on the queue. An activation stored procedure should exit when no messages are available on the queue for a short time.
Permissions for the activation stored procedure are checked when Service Broker starts the stored procedure, not when the queue is created. The CREATE QUEUE statement does not verify that the user specified in the EXECUTE AS clause has permission to execute the stored procedure specified in the PROCEDURE NAME clause.
When a queue is unavailable, Service Broker holds messages for services that use the queue in the transmission queue for the database. The sys.transmission_queue catalog view provides a view of the transmission queue.
A queue is a schema-owned object. Queues appear in the sys.objects catalog view.
The following table lists the columns in a queue.
|
Column name
|
Data type
|
Description
|
|---|
|
status
|
tinyint
|
Status of the message. For messages returned by the RECEIVE command, the status is always 1. Messages in the queue can contain one of the following values:
0=Received message
1=Ready
2=Not yet complete
3=Retained sent message
|
|
priority
|
tinyint
|
Reserved for future use.
|
|
queuing_order
|
bigint
|
Message order number in the queue.
|
|
conversation_group_id
|
uniqueidentifier
|
Identifier for the conversation group that this message belongs to.
|
|
conversation_handle
|
uniqueidentifier
|
Handle for the conversation that this message is part of.
|
|
message_sequence_number
|
bigint
|
Sequence number of the message in the conversation.
|
|
service_name
|
nvarchar(512)
|
Name of the service that the conversation is to.
|
|
service_id
|
int
|
SQL Server object identifier of the service that the conversation is to.
|
|
service_contract_name
|
nvarchar(256)
|
Name of the contract that the conversation follows.
|
|
service_contract_id
|
int
|
SQL Server object identifier of the contract that the conversation follows.
|
|
message_type_name
|
nvarchar(256)
|
Name of the message type that describes the message.
|
|
message_type_id
|
int
|
SQL Server object identifier of the message type that describes the message.
|
|
validation
|
nchar(2)
|
Validation used for the message.
E=Empty
N=None
X=XML
|
|
message_body
|
varbinary(MAX)
|
Content of the message.
|
|
message_id
|
uniqueidentifier
|
Unique identifier for the message.
|