-
Notifications
You must be signed in to change notification settings - Fork 15
SqlServerQueueCreationOptions
When creating a new SQL queue, there are various features that you can enable and disable. Most of these options will change the schema of the queue. All of these options must be set before creating the queue.
- Additional columns
You may add additional columns to the queue status table. When sending messages, you can then include data to populate your custom columns. User columns are stored on the status table.
Add a user defined column named 'OrderID'
createQueue.Options.AdditionalColumns.Add(new Column("OrderID", ColumnTypes.Bigint, true, null));
Sending user defined data with a message. Note that this data is not returned with the message when de-queuing
var data = new AdditionalMessageData();
data.AdditionalMetaData.Add(new AdditionalMetaData<Int64>("OrderID", 1234));
queue.Send(message, data);
- Additional constraints
Add an index on the OrderID column. Note that every column and index you add will degrade performance.
createQueue.Options.AdditionalConstraints.Add(new Constraint("OrderID_IX", ContraintType.Index, "OrderID"));
- EnableDelayedProcessing
The queue can be configured to support delayed processing. If you won't use this for a particular queue, you can increase performance by setting this to false. Note that the retry behavior uses this. If you disable it, and enable retries they will not be delayed.
If you pass a delay with a message, and this setting is false, the delay will be ignored.
createQueue.Options.EnableDelayedProcessing = true;
- Holding a SQL transaction until the message is commited
You can tell the queue to keep the de-queue transaction open until the message is done processing. This will strain your SQL server; only enable this if you really need it.
createQueue.Options.EnableHoldTransactionUntilMessageCommited = true;
- Enable Heartbeat
The queue can be configured to support heart beats. If a worker dies, other workers will be able to dequeue the message. This option cannot be enabled if transactions are being held.
createQueue.Options.EnableHeartBeat = true;
- Enable Message Expiration
The queue can be configured to support expiration of messages. If you won't use this for a particular queue, you can increase performance by setting this to false. RPC queues will set this to true when created, even if set to false.
If you pass an expiration with a message, and this setting is false, the expiration will be ignored.
createQueue.Options.EnableMessageExpiration = true;
- Enable Priority
The queue can be configured to support message priority. This allows you to move messages to the front of the queue. Otherwise, the queue behaves as a loose FIFO queue.
If you pass an priority with a message, and this setting is false, the priority will be ignored.
createQueue.Options.EnablePriority = true;
- Enable Status
You can enable a status column on the queue. This is required if heartbeat is enabled. This allows the queue to rollback messages, and recover from crashed workers.
If both transactions and status are disabled, the queue acts as a FIFO queue with no message recovery possible. This might be what you want if speed is important, and it doesn't matter if some messages are lost if a worker crashes or power is lost, etc.
createQueue.Options.EnableStatus = true;
- Enable Status Table
The queue can create and update a seperate table that you can query to see the status of queue. This is safer then querying the queue itself, as you may block operations and cause deadlocks.
This table is automaticly enabled if user columns are added to the queue. They are stored in this table.
createQueue.Options.EnableStatusTable = true;
- Queue Type
There are three types of queues
Normal
RPCSend
RPCReceive
When using RPC, you'll need to create two queues. An RpcSend and an RpcReceive. When running the RPC queue, you'll pass it both queues so that it knows where to write requests and listen for responses
For any issues please use the GitHub issues