Skip to content

Add Queue Storage peek message support - #76

Merged
brecht-vermeersch merged 6 commits into
php-oss-for-azure:mainfrom
bahdanhal:feature/queue-peek-messages
Sep 4, 2026
Merged

brecht-vermeersch merged 6 commits into
php-oss-for-azure:mainfrom
bahdanhal:feature/queue-peek-messages

Conversation

@bahdanhal

Copy link
Copy Markdown
Contributor

Closes #75

Summary

Adds support for inspecting visible Azure Storage Queue messages without changing their visibility.

The new API follows the existing synchronous/asynchronous method pairs used by QueueClient:

  • peekMessage()
  • peekMessageAsync()
  • peekMessages()
  • peekMessagesAsync()

A separate PeekedMessage model is used because the Azure Peek Messages response does not contain PopReceipt or TimeNextVisible. Peeked messages therefore cannot be passed directly to update or delete operations.

Implementation

  • Sends GET /messages?peekonly=true.
  • Supports the optional numofmessages parameter.
  • Returns null when peekMessage() finds no visible message.
  • Deserializes message ID, text, insertion and expiration times, and dequeue count.
  • Updates the Queue package README, documentation, and changelog.

REST API reference:
https://learn.microsoft.com/en-us/rest/api/storageservices/peek-messages

Tests

Verified locally with PHP 8.5, Guzzle 8, and Azurite:

  • Queue unit tests: 24 passed, 68 assertions.
  • Queue integration tests: 22 passed, 40 assertions.
  • Architecture tests: 8 passed, 86 assertions.
  • PHPStan: passed with no errors.
  • Pint: passed for all 260 files.
  • git diff --check: passed.

The integration tests verify that:

  • a peeked message remains immediately available to receiveMessage();
  • batch peeking does not change visibility;
  • peekMessage() returns null for an empty queue.

Compatibility

This is an additive change. No existing public API is modified and no upgrade instructions are required.

Before submitting, replace #ISSUE in the first line of the description with the actual issue number.

@brecht-vermeersch

Copy link
Copy Markdown
Member

Thanks for this! Changed some parameter naming to align closer to the .NET library.

# Conflicts:
#	src/Storage/Queue/CHANGELOG.md
@brecht-vermeersch
brecht-vermeersch merged commit 62ae884 into php-oss-for-azure:main Sep 4, 2026
@brecht-vermeersch

Copy link
Copy Markdown
Member

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add peek message support to Azure Storage Queue

3 participants