Skip to content

Commit de07a2f

Browse files
authored
Fetch messages (#116)
* add fetch_messages function * try fetch dls * fetch messages + fetch dls messages * bug fix + erase on close/destroy * enable change batch size on same consumer in fetch * add readme for consumer.fetch() * allow change batch size in existing consumer
1 parent 06fb01c commit de07a2f

File tree

2 files changed

+187
-54
lines changed

2 files changed

+187
-54
lines changed

README.md

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -295,6 +295,28 @@ async def msg_handler(msgs, error, context):
295295
consumer.consume(msg_handler)
296296
```
297297

298+
### Fetch a single batch of messages
299+
```python
300+
msgs = await memphis.fetch_messages(
301+
station_name="<station-name>",
302+
consumer_name="<consumer-name>",
303+
consumer_group="<group-name>", # defaults to the consumer name
304+
batch_size=10, # defaults to 10
305+
batch_max_time_to_wait_ms=5000, # defaults to 5000
306+
max_ack_time_ms=30000, # defaults to 30000
307+
max_msg_deliveries=10, # defaults to 10
308+
generate_random_suffix=False
309+
start_consume_from_sequence=1 # start consuming from a specific sequence. defaults to 1
310+
last_messages=-1 # consume the last N messages, defaults to -1 (all messages in the station))
311+
)
312+
```
313+
314+
### Fetch a single batch of messages after creating a consumer
315+
```python
316+
msgs = await consumer.fetch(batch_size=10) # defaults to 10
317+
```
318+
319+
298320
### Acknowledge a message
299321

300322
Acknowledge a message indicates the Memphis server to not re-send the same message again to the same consumer / consumers group

0 commit comments

Comments
 (0)