-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Use FastStream's native acknowledgements (#106)
- Loading branch information
Showing
10 changed files
with
115 additions
and
58 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
import typing | ||
from typing import cast | ||
|
||
import stompman | ||
from faststream.broker.message import StreamMessage, gen_cor_id | ||
|
||
|
||
class StompStreamMessage(StreamMessage[stompman.AckableMessageFrame]): | ||
async def ack(self) -> None: | ||
if not self.committed: | ||
await self.raw_message.ack() | ||
return await super().ack() | ||
|
||
async def nack(self) -> None: | ||
if not self.committed: | ||
await self.raw_message.nack() | ||
return await super().nack() | ||
|
||
async def reject(self) -> None: | ||
if not self.committed: | ||
await self.raw_message.nack() | ||
return await super().reject() | ||
|
||
@classmethod | ||
async def from_frame(cls, message: stompman.AckableMessageFrame) -> typing.Self: | ||
return cls( | ||
raw_message=message, | ||
body=message.body, | ||
headers=cast("dict[str, str]", message.headers), | ||
content_type=message.headers.get("content-type"), | ||
message_id=message.headers["message-id"], | ||
correlation_id=cast("str", message.headers.get("correlation-id", gen_cor_id())), | ||
) |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters