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-9/

Message Retry Handler

Build a message processing system that handles transient failures by retrying messages that fail processing.

Overview

You need to implement a message processor that receives messages from a queue, attempts to process them, and handles failures appropriately. When a message fails processing due to a transient error (e.g., temporary network issue), the system should return the message to the queue for retry. Messages should only be permanently removed after successful processing.

Requirements

Message Processing

Implement a function process_messages(connection_string, queue_name, max_messages, processor_callback) that:

  1. Connects to a Service Bus queue using the provided connection string
  2. Receives up to max_messages from the queue
  3. For each message:
    • Invokes the processor_callback function with the message body
    • If the callback succeeds (returns True), confirms successful processing
    • If the callback fails (returns False or raises an exception), returns the message to the queue for redelivery
  4. Closes all connections properly when done

The processor_callback is a function that takes a single argument (the message body as a string) and returns a boolean indicating success (True) or failure (False).

Error Handling

  • Handle processing failures gracefully by returning failed messages to the queue
  • Ensure successful messages are properly completed and removed from the queue
  • Do not let exceptions in the callback crash the entire processor

Implementation

@generates

API

def process_messages(connection_string: str, queue_name: str, max_messages: int, processor_callback) -> dict:
    """
    Process messages from a Service Bus queue with retry handling.

    Args:
        connection_string: Azure Service Bus connection string
        queue_name: Name of the queue to receive messages from
        max_messages: Maximum number of messages to process
        processor_callback: Function that processes message body and returns True for success, False for failure

    Returns:
        Dictionary with keys:
        - 'processed': count of successfully processed messages
        - 'failed': count of messages that failed processing and were returned to queue
    """
    pass

Tests

  • When all messages process successfully, all are completed and removed from queue @test
  • When a message fails processing, it is abandoned and remains in queue for redelivery @test
  • When callback raises an exception, message is abandoned and processing continues @test
  • Mixed success and failure messages are handled correctly @test

Dependencies { .dependencies }

azure-servicebus { .dependency }

Provides Azure Service Bus messaging capabilities.

@satisfied-by