apache / apache/pulsar-client-cpp
[question] python jsonschema cant inheritance
- Dominant language
- C++
- Stars
- 71
- Forks
- 90
- Avg merge
- 2h 33m
- Merged PRs (30d)
- 3
Description
# schema
```python3
class BaseTaskOperateMsg(Record):
task_ids = Array(Integer())
class TaskOffline2OnlineMsg(BaseTaskOperateMsg):
pass
```
# producer
```python3
client = pulsar.Client("pulsar://localhost:6650")
producer = client.create_producer(
topic="taskOffline2Online1",
schema=JsonSchema(TaskOffline2OnlineMsg),
)
msg = TaskOffline2OnlineMsg(task_ids=[1, 2])
producer.send(msg)
client.close()
```
# consumer
```python3
client = pulsar.Client("pulsar://localhost:6650")
consumer = client.subscribe("taskOffline2Online1", "sub1", schema=JsonSchema(TaskOffline2OnlineMsg))
while True:
msg = consumer.receive()
try:
print("Received message '{}' id='{}'".format(msg.data(), msg.message_id()))
print(msg.value())
# Acknowledge successful processing of the message
consumer.acknowledge(msg)
except Exception:
# Message failed to be processed
consumer.negative_acknowledge(msg)
break
```
when using TaskOffline2OnlineMsg, i cant get task_ids.
Contributor guide
Research direction
Start by reproducing the producer and consumer example using JsonSchema(TaskOffline2OnlineMsg), including the inherited task_ids field. Inspect how TaskOffline2OnlineMsg and BaseTaskOperateMsg are handled by the Python schema implementation, then verify whether the consumer can retrieve task_ids and document the result or identify the required fix.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- distributed-systems
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 35/100