-
Notifications
You must be signed in to change notification settings - Fork 2.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[ServiceBus] message.dead_letter doesn't set any properties of message which is consistent with the .NET Sdk #9242
Comments
Is there an ETA when this issue might be addressed? |
Hey @MichaelWeedon, my apologies for the slow reply, am digging into this issue and will loop back with ETA once we get a sense for the resolution. Thanks in advance for all your patience thus far. |
Hi @MichaelWeedon , thanks for your patience and sorry for letting you wait for such a long time. I have created a patch wheel for the issue, can you test whether it solves the problem on your side? (Code change could be found here if you're interested in implementation detail #10246) |
@yunhaoling File "/Users/xxxx/projects/venv/lib/python3.6/site-packages/azure/servicebus/aio/async_message.py", line 108, in dead_letter |
Which version of uamqp library are you using, can you try installing the the latest uamqp library by We're aware of the issue |
@yunhaoling $ pip list | grep uamqp |
@MichaelWeedon
Thanks |
@yunhaoling |
@MichaelWeedon thanks for the additional context, I would try to reproduce the issue. |
@MichaelWeedon sorry for not getting back to you sooner. It took me some time to figure out the difference between session/non-session entity when handling dead letter. I've made another patch, this one works well for both type of entity on my side. Can you help verify the patch solves your problem or not? |
@yunhaoling, installed latest patch and do not see a difference in behavior in the samples or my program - meaning no attributes in dead letter. Do you have code that illustrates this properly sending the attributes to the dead letter queue? |
@MichaelWeedon Here is the code I used, please replace from azure.servicebus.aio import ServiceBusClient, Message
from azure.servicebus import ReceiveSettleMode
import asyncio
import logging
logging.basicConfig(level=logging.INFO)
_logger = logging.getLogger(__name__)
CONN_STR = "<YOUR CONNECTION STR>"
QUEUE_NAME = "<YOUR QUEUE NAME>"
SESSION_ID = "<YOUR SESSION ID>"
def print_message(message):
_logger.info("Receiving: {}".format(message))
_logger.debug("Time to live: {}".format(message.time_to_live))
_logger.debug("Sequence number: {}".format(message.sequence_number))
_logger.debug("Enqueue Sequence number: {}".format(message.enqueue_sequence_number))
_logger.debug("Partition ID: {}".format(message.partition_id))
_logger.debug("Partition Key: {}".format(message.partition_key))
_logger.info("User Properties: {}".format(message.user_properties))
_logger.debug("Annotations: {}".format(message.annotations))
_logger.debug("Delivery count: {}".format(message.header.delivery_count))
try:
_logger.debug("Locked until: {}".format(message.locked_until))
_logger.debug("Lock Token: {}".format(message.lock_token))
except TypeError:
pass
_logger.debug("Enqueued time: {}".format(message.enqueued_time))
async def main():
client = ServiceBusClient.from_connection_string(conn_str=CONN_STR)
queue_client = client.get_queue(QUEUE_NAME)
async with queue_client.get_receiver(session=SESSION_ID, idle_timeout=10, mode=ReceiveSettleMode.PeekLock, prefetch=10) as receiver:
async with queue_client.get_sender() as sender:
for i in range(10):
message = Message("Dead lettered message no. {}".format(i))
message.session_id = SESSION_ID
await sender.send(message)
count = 0
messages = await receiver.fetch_next()
while messages:
for message in messages:
print_message(message)
await message.dead_letter(description="Testing queue deadletter")
count += 1
messages = await receiver.fetch_next()
assert count == 10
async with queue_client.get_deadletter_receiver(idle_timeout=10, mode=ReceiveSettleMode.PeekLock) as receiver:
count = 0
async for message in receiver:
print_message(message)
assert message.user_properties[b'DeadLetterReason'] == b'Testing queue deadletter'
assert message.user_properties[b'DeadLetterErrorDescription'] == b'Testing queue deadletter'
await message.complete()
count += 1
assert count == 10
loop = asyncio.get_event_loop()
loop.run_until_complete(main()) |
@yunhaoling, Thanks. Able to get it to work. One caveat is I cannot get the reason (i.e description) to be set if I process the dead_letter within a handle exception. Meaning if while processing the message an exception occurs, I want to dead_letter the message using the exception as the reason. In this scenario, no reason is set - thoughts? |
Hi @MichaelWeedon , can you share me with code that reproduce the issue? -- dead_letter message when an exceptions occurs and use the exception as the reason within a handle exception. |
@yunhaoling Upon further investigation, it appears the problem is corrected for all cases. For some reason my pycharm environment was not picking up the newer sdk you supplied. |
Hi @MichaelWeedon , thanks for the feedback, glad it works for you. Currently we're triaging some other ServiceBus issues and try to get them resolved. We'll keep you updated about the release plan, thanks for your patience in advance. |
Hi @MichaelWeedon , apologize for the late response. We've released azure-servicebus v0.50.3 today which should have the issue addressed. Please update the library. The important thing worth your attention here is that v0.50.3 would be our final release for v0.50 -- it is about to be deprecated. We're shipping a brand-new azure-servicebus v7.0.0 (which is currently in b2) to build a more user friendly and productive library following our SDK design guidelines. We decided not to maintain the old preview (v0.50) library which will never go GA. We've provided migration guide on v0.50 to v7 to help get you onboard. Apologize for the inconvenience we bring to you and thanks for your understanding and patience. We're looking forward to you trying our latest preview library and feedback is most welcome. |
My apologies for the previous response (deleted). |
Customer report:
When you are receiving a message and explicitly try to deadletter it (message.dead_letter(description)), the description (string) doesn't show up in the properties of the message even when it is specified. I tried it with the regular dead_letter and also async dead_letter in Python, both returned these properties of the message:
"properties": {},
When I run the same test using the .NET SDK for Service Bus, it works as expected. Here are the message properties from .NET
"properties": {
"DeadLetterReason": "bad"
}
Repro:
The text was updated successfully, but these errors were encountered: