MCP Commands - Queue Management

<< Click to Display Table of Contents >>

Navigation:  3. Script Language > Internet and Network > MCP. - MCP (Model-Context Protocol) server operations > Queue Management - Listener queue operations >

MCP Commands - Queue Management

MCP.GetQueueCount - Get Queue Count

PreviousTopNext


MiniRobot Language (MRL) - MCP Queue Management Commands

 

MCP.GetQueueCount / MCP.GetQC

Get the Number of Commands in the Queue

 

Purpose

 

The MCP.GetQueueCount command retrieves the current number of pending commands in the MCP server's command queue. This allows scripts to monitor queue load, implement flow control, or make decisions based on the current processing backlog.

 

This command is useful when:

• Monitoring server load and queue backlog

• Implementing flow control to prevent queue overflow

• Determining when all pending commands have been processed

• Debugging and performance monitoring

 

Syntax

 

MCP.GetQueueCount|$$RETURN_VAR

 

MCP.GetQC|$$RETURN_VAR

 

Parameters

 

$$RETURN_VAR - The variable that will receive the queue count (0 or positive integer). Returns -1 if the server is not running.

 

Return Value

 

0..N - The number of commands currently in the queue

-1 - MCP server not running or error

 

Examples

 

' Example 1: Basic queue count check

MCP.GetQueueCount|$$Count

PRT.There are $$Count commands pending

 

' Example 2: Flow control - wait for queue to empty

LBL.WaitLoop

MCP.GetQueueCount|$$Pending

IVV.$$Pending>0

WAI.100

JMP.WaitLoop

EIF.

PRT.All commands processed

 

' Example 3: Prevent queue overflow with flow control

MCP.GetQC|$$CurrentCount

IVV.$$CurrentCount<50

' Safe to add more commands

MCP.Exec|SomeCommand|$$Result

ELS.

PRT.Queue too full, skipping command

EIF.

 

' Example 4: Monitor and report queue statistics

MCP.GetQueueCount|$$QueueSize

IVV.$$QueueSize=-1

PRT.Server not running

ELS.

PRT.Current queue size: $$QueueSize

EIF.

 

Remarks

 

The count returned by MCP.GetQueueCount represents the number of commands currently waiting to be executed, not including any command that may be actively running. The count is a snapshot at the time of the call and may change immediately after due to ongoing queue operations.

 

In synchronous mode, the queue count typically remains low since commands are processed sequentially. In asynchronous mode, the count may grow higher as commands are queued faster than they can be processed.

 

MCP.GetQueueCount and MCP.GetQC are aliases for the same command.

 

Error Conditions

 

The command will fail with a parameter error if:

• The return variable parameter is missing

• Too many parameters are provided

 

See also:

 

MCP.GetQueueMode - Get Queue Mode

MCP.ConfigQueue - Configure Listener Queue

MCP.ResetQueue - Reset the Queue

Queue Management Overview