Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add filters #29

Merged
merged 1 commit into from
Feb 4, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion examples/getting_started/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ def threaded_function(addr_queue):
connection = create_connection()
offset_specification = StreamFilterOptions()
offset_specification.offset(10)
consumer = connection.consumer(addr_queue, handler=MyMessageHandler())
consumer = connection.consumer(addr_queue, handler=MyMessageHandler(), stream_filter_options=offset_specification)
try:
consumer.run()
except KeyboardInterrupt:
Expand Down
2 changes: 0 additions & 2 deletions rabbitmq_amqp_python_client/entities.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,6 @@ def __init__(self):
self._filter_set: Dict[symbol, Described] = {}

def offset(self, offset: int):
#self._filter_set[symbol(STREAM_FILTER_SPEC)] = Described(symbol(STREAM_FILTER_SPEC), "first")
print("im here")
self._filter_set[symbol('rabbitmq:stream-offset-spec')] = Described(symbol('rabbitmq:stream-offset-spec'), "first")

def filters(self) -> Dict[symbol, Described]:
Expand Down
8 changes: 2 additions & 6 deletions rabbitmq_amqp_python_client/options.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from .qpid.proton._data import ( # noqa: E402
PropertyDict,
symbol,
symbol, Described,
)
from .qpid.proton._endpoints import Link # noqa: E402
from .qpid.proton.reactor import LinkOption, Filter # noqa: E402
Expand Down Expand Up @@ -71,11 +71,7 @@ def __init__(self, addr: str, filter_options: StreamFilterOptions):


def apply(self, link: Link) -> None:
link.target.address = self._addr
link.snd_settle_mode = Link.SND_UNSETTLED
link.rcv_settle_mode = Link.RCV_FIRST
link.properties = PropertyDict({symbol("paired"): True})
link.source.dynamic = False
link.source.filter.put_dict(self.filter_set)

def test(self, link: Link) -> bool:
return bool(link.is_receiver)
Loading