michalcukierman commented on issue #21074:
URL: https://github.com/apache/pulsar/issues/21074#issuecomment-1695434624
Having the script:
```bash
trap printout SIGINT
printout() {
[[ ! -z "$PYTHON_PID" ]] && echo "\nExiting... Killing Python Consumer"
&& kill -15 $PYTHON_PID
exit
}
TOPIC="test-compaction-0"
echo "Create topic"
kubectl exec --namespace pulsar -t pulsar-toolset-0 -- bin/pulsar-admin
topics create-partitioned-topic ${TOPIC} -p 12
kubectl exec --namespace pulsar -t pulsar-toolset-0 -- bin/pulsar-admin
topics compact ${TOPIC}
echo "Produce messages"
kubectl exec --namespace pulsar -t pulsar-toolset-0 -- bin/pulsar-perf
produce -bm 1 -r 300 -m 10000 -s 102400 ${TOPIC}
# Compact topic
echo "Compact topic"
kubectl exec --namespace pulsar -t pulsar-toolset-0 -- bin/pulsar-admin
topics compact ${TOPIC}
# Unload topic and start reading the results
sleep 10 && echo "Unload topic"
kubectl exec --namespace pulsar -t pulsar-toolset-0 -- bin/pulsar-admin
topics unload ${TOPIC}
echo "Start reading"
python3 consumer.py ${TOPIC} &
PYTHON_PID=$!
# Unload topic again (don't know if it's required)
sleep 10 && echo "Unload topic"
kubectl exec --namespace pulsar -t pulsar-toolset-0 -- bin/pulsar-admin
topics unload ${TOPIC}
sleep 10 && echo "Unload topic"
kubectl exec --namespace pulsar -t pulsar-toolset-0 -- bin/pulsar-admin
topics unload ${TOPIC}
sleep 10 && echo "Unload topic"
kubectl exec --namespace pulsar -t pulsar-toolset-0 -- bin/pulsar-admin
topics unload ${TOPIC}
sleep 100000 # wait for CTRL+C
```
and the python script `consumer.py`:
```python
import pulsar
import sys
client = pulsar.Client('pulsar://localhost:6650')
consumer = client.subscribe(sys.argv[1],
subscription_name='python-consume',
initial_position=pulsar.InitialPosition.Earliest,
is_read_compacted=True)
count=0
while True:
msg = consumer.receive()
count += 1
print("#", count, " -> ", msg.message_id())
consumer.acknowledge(msg)
client.close()
```
I can see that the messages are delivered in a loop.
The results after greping by the message ID: `python3 consumer.py ${TOPIC} |
grep "(144,0"`
are:
<img width="664" alt="Screenshot 2023-08-28 at 12 22 37"
src="https://github.com/apache/pulsar/assets/4356553/1f35e24b-133d-4ce2-9fee-ad8b8caf3143">
- The same message is re-delivered in a loop.
- All messages may never be delivered.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]