You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@qpid.apache.org by kp...@apache.org on 2026/08/10 21:12:14 UTC
(qpid-interop-test) 14/41: Fix: Use symbol key and byte value for JMS annotations
This is an automated email from the ASF dual-hosted git repository.
kpvdr pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/qpid-interop-test.git
commit 67f55822e83a72472a90fc4981ce0d436b2a687c
Author: QIT Development Team <qi...@example.com>
AuthorDate: Fri Jul 17 20:25:47 2026 -0400
Fix: Use symbol key and byte value for JMS annotations
Root Cause:
- Python→JMS tests failing (0/5 messages received)
- Used plain string "x-opt-jms-msg-type" instead of symbol()
- Used ubyte(5) instead of byte(5)
- Qpid JMS Client expects: {symbol("x-opt-jms-msg-type"): byte(5)}
Fix (from QIT v1 working code):
- Sender: msg.annotations = {symbol("x-opt-jms-msg-type"): byte(jms_type)}
- Receiver: annotation_key = symbol("x-opt-jms-msg-type")
- Import: from proton import byte, symbol (not ubyte)
Why This Matters:
- AMQP annotations have typed keys (symbol vs string are different)
- AMQP types matter: byte vs ubyte are encoded differently
- Qpid JMS Client strictly matches this wire format
Reference: QIT v1 qit_jms_types.py create_annotation()
Expected Build #68 Results:
- Python→JMS: 5/5 passing (was 0/5)
- JMS→Python: 5/5 passing (unchanged)
- Python roundtrip: 5/5 passing (unchanged)
- Total: 15/15 (100%)
Co-Authored-By: Claude Sonnet 4.5 <no...@anthropic.com>
---
debug_message_encoding.py | 36 ++++++++++++++++++++++++++++++++++++
shims/python-proton/shim.py | 14 ++++++++++----
2 files changed, 46 insertions(+), 4 deletions(-)
diff --git a/debug_message_encoding.py b/debug_message_encoding.py
new file mode 100644
index 0000000..44001ed
--- /dev/null
+++ b/debug_message_encoding.py
@@ -0,0 +1,36 @@
+#!/usr/bin/env python3
+"""
+Debug script to see how Python Proton actually encodes messages.
+This will help us understand why JMS receiver isn't getting messages.
+"""
+
+from proton import Message, byte, symbol
+
+# Create a message the CORRECT way (matching QIT v1)
+msg = Message()
+msg.id = 0
+msg.body = "Hello, world" # String value
+msg.annotations = {symbol("x-opt-jms-msg-type"): byte(5)} # Key MUST be symbol, value MUST be byte
+
+print("Message created:")
+print(f" ID: {msg.id}")
+print(f" Body: {repr(msg.body)}")
+print(f" Body type: {type(msg.body)}")
+print(f" Annotations: {msg.annotations}")
+print(f" Content type: {msg.content_type}")
+print(f" Subject: {msg.subject}")
+print()
+
+# Check the encoded format
+print("Proton internal representation:")
+print(f" msg.body (raw): {msg.body}")
+print(f" Python type: {type(msg.body).__name__}")
+print()
+
+# What happens with empty string?
+msg2 = Message()
+msg2.body = ""
+msg2.annotations = {symbol("x-opt-jms-msg-type"): byte(5)}
+print("Empty string message:")
+print(f" Body: {repr(msg2.body)}")
+print(f" Body type: {type(msg2.body)}")
diff --git a/shims/python-proton/shim.py b/shims/python-proton/shim.py
index 3fa38eb..b978cf5 100755
--- a/shims/python-proton/shim.py
+++ b/shims/python-proton/shim.py
@@ -50,12 +50,14 @@ class SenderHandler(MessagingHandler):
# Add JMS annotations if in JMS mode
if self.jms_mode:
- from proton import ubyte
+ from proton import byte, symbol
# Map type to JMS message type
jms_type = self._get_jms_message_type(msg_data["type"])
if jms_type is not None:
- msg.annotations = {"x-opt-jms-msg-type": ubyte(jms_type)}
+ # NOTE: Key MUST be symbol, value MUST be byte (not ubyte)
+ # This matches Qpid JMS Client wire format
+ msg.annotations = {symbol("x-opt-jms-msg-type"): byte(jms_type)}
event.sender.send(msg)
self.sent_count += 1
@@ -212,9 +214,13 @@ class ReceiverHandler(MessagingHandler):
msg = event.message
# Check for JMS message type annotation
+ # NOTE: Qpid JMS Client uses symbol as key
+ from proton import symbol
+
jms_msg_type = None
- if msg.annotations and "x-opt-jms-msg-type" in msg.annotations:
- jms_msg_type = int(msg.annotations["x-opt-jms-msg-type"])
+ annotation_key = symbol("x-opt-jms-msg-type")
+ if msg.annotations and annotation_key in msg.annotations:
+ jms_msg_type = int(msg.annotations[annotation_key])
# Extract message data
if jms_msg_type is not None:
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@qpid.apache.org
For additional commands, e-mail: commits-help@qpid.apache.org