Hi Adam, or anyone,
On Monday, June 10, 2019 6:06:42 PM CEST Adam Williamson wrote:
If you're writing an AMQP consumer in Python, what you'll
ultimately
get for your consumer to process is a `message` object which is an
instance of a fedora_messaging.api.Message() (or a subclass of it - a
message schema class).
I fail to see an example of this, I mean ... [1] says
Message bodies are JSON objects, that adhere to a schema. Message schemas
live in their own Python package, so they can be installed on the producer
and on the consumer.
do we have any such package so I (as a consumer) can install the package
with schema class, and use it to parse the message body? I have seen
the example of producing the message using the schema [2], but not
consuming - only the toy example which is not really using the schema
class.
This will have a `body` attribute which should be a dict of the
message
'body' - the main meat of the message.
... I can use the "meat" to instantiate the message object manually, by
Message(body=body) perhaps, but I still have to first check the topic,
etc, I hoped there's something like:
from MYAPP import MessageConsumer
from fedora_messaging.api import consume
...
class Consumer(MessageConsumer):
def consume(self, message):
""" message _is_ instance of the schema class """
message.do_some_stuff()
if message.some_property:
do_something()
consume(Consumer)
Well, if not that far -- I'd at least like to see something like
`python3-foo-fedora-messaging` package which I could install and give it a
try (this sounds like it is common pattern from the docs). I'd like to design
the copr.git/fedora-messaging directory according to that.
[1]
https://fedora-messaging.readthedocs.io/en/latest/tutorial/schemas.html
[2]
https://github.com/fedora-infra/fedora-messaging/blob/master/docs/tutoria...
[3]
https://github.com/fedora-infra/fedora-messaging/blob/master/docs/tutoria...
Pavel