or run

tessl search
Log in

Version

Workspace
tessl
Visibility
Public
Created
Last updated
Describes
pypipkg:pypi/azure-servicebus@7.14.x
tile.json

tessl/pypi-azure-servicebus

tessl install tessl/pypi-azure-servicebus@7.14.0

Microsoft Azure Service Bus Client Library for Python providing comprehensive messaging capabilities for enterprise applications.

Agent Success

Agent success rate when using this tile

92%

Improvement

Agent success rate improvement when using this tile compared to baseline

1.01x

Baseline

Agent success rate without this tile

91%

task.mdevals/scenario-10/

Real-time Order Processing System

Summary

Build a real-time order processing system that continuously monitors incoming orders from a message queue and processes them as they arrive. The system should handle orders efficiently using a streaming approach and properly acknowledge successful processing.

Dependencies { .dependencies }

azure-servicebus { .dependency }

Provides enterprise messaging capabilities for asynchronous communication.

Requirements

Implement a Python application that:

  1. Connects to an Azure Service Bus queue named "orders" using a connection string
  2. Continuously monitors and receives incoming order messages in real-time using a streaming approach
  3. Processes each order message by:
    • Extracting the order ID from the message body (JSON format with an "order_id" field)
    • Logging the order ID to stdout with format: "Processing order: {order_id}"
    • Simulating processing by sleeping for 0.5 seconds
  4. Confirms successful processing of each message to remove it from the queue
  5. Handles up to 10 messages before stopping gracefully
  6. Uses proper resource cleanup

The connection string should be read from an environment variable named SERVICEBUS_CONNECTION_STRING.

Implementation files

src/order_processor.py { .target }

Main implementation file containing the order processing logic.

tests/test_order_processor.py { .target }

Test file with the following test cases.

Test cases

Test 1: Basic streaming and processing { @test }

Setup:

  • Mock Service Bus receiver that yields 3 messages
  • Message bodies: {"order_id": "ORD-001"}, {"order_id": "ORD-002"}, {"order_id": "ORD-003"}

Expected behavior:

  • Application iterates through all 3 messages
  • Each order ID is logged in sequence
  • All 3 messages are marked as successfully processed
  • Resources are properly cleaned up

Test 2: Stop after message limit { @test }

Setup:

  • Mock Service Bus receiver that can yield 15 messages
  • Messages have order IDs from "ORD-001" to "ORD-015"

Expected behavior:

  • Application processes exactly 10 messages
  • Processing stops after the 10th message
  • All 10 processed messages are marked as successfully processed
  • Receiver is properly closed

Test 3: Handle empty queue gracefully { @test }

Setup:

  • Mock Service Bus receiver with no messages available
  • Iterator should complete without errors

Expected behavior:

  • Application handles the empty queue without crashing
  • No processing occurs
  • Resources are cleaned up properly