#96 Use fedora-messaging instead of fedmsg
Closed: complete 4 months ago by jflory7. Opened 5 months ago by shraddhaag.

Currently, fedmsg is being used but it is deprecated in favour of fedora-messaging. We would like to incorporate the same in fedora-happiness-packets too.


Metadata Update from @jflory7:
- Issue priority set to: needs review (was: awaiting triage)
- Issue tagged with: difficulty - medium, help wanted, new change, type - backend, type - fedora-messaging, type - summer coding

5 months ago

@shraddhaag Thanks for opening this. A great first task for this ticket is to do some info gathering. Example first steps could be the following:

  1. See where happiness-packets currently uses fedmsg (fedmsg API documentation)
  2. Review fedora-messaging API documentation, compare to happiness-packets code for changes

If anyone wants to work on this, let us know here to assign the ticket. :thumbsup:

I'd like to work on this

@shraddhaag Sure! Thanks for volunteering. :smile:

If you find any helpful resources about fedora-messaging, sharing them here is helpful. Additionally, if you get stuck or have questions, ask in this ticket and we'll do our best to help you figure it out.

Metadata Update from @jflory7:
- Issue untagged with: help wanted
- Issue assigned to shraddhaag
- Issue priority set to: waiting on assignee (was: needs review)

5 months ago

See this comment from @jcline with some tips on migrating from fedmsg to fedora-messaging. See the fedora-messaging tutorial for guidance on migrating.

@jflory7 @jcline: I was trying to create a Message Schema. I first tried running the out of box sample_schema_example mentioned in the docs.

[Note: No changes to the body_schema and setup.py was done, the package given in the GitHub repository is used without any tampering]

  1. On running a publish.py script [1], an AttributeError[2] is raised.
  2. On running python setup.py test inside the sample_schema_package again same AttributeError[3] are raised in all the tests.

Could you please point me towards solving this AttributeError?

[1] https://pastebin.com/raw/7j5B313A
[2] https://pastebin.com/raw/3eewVAU6
[3] https://pastebin.com/raw/gYYuVXNY

@shraddhaag ahh, yeah this is a bug in the sample_schema_package. The body on a message used to be a Python property. The property used to be overridden in the MessageV1 class, but now the fedora_messaging.message.Message class is setting body as an instance variable instead of a property.

The fix for this issue is at https://github.com/fedora-infra/fedora-messaging/pull/135 (let me know if it doesn't fix things for you). If you've got a clone of the repository and don't know how to get a hold of that patch, running "curl https://patch-diff.githubusercontent.com/raw/fedora-infra/fedora-messaging/pull/135.patch | git am" will apply the pull request as a commit on top of whatever branch you've got checked out.

I recently discovered fedmsg-migration-tools, a project @abompard seems to be working on. Its documentation is found here.

It's not super clear from the repository description, but that repository is infrastructure tools to bridge fedmsg into the AMQP broker and bridge messages back into fedmsg during the migration period. We run these in infrastructure so folks can get messages from either during the transition period.

One thing it may be useful for is if you want to get messages from fedmsg into a broker so you can use fedora-messaging to consume them - https://fedmsg-migration-tools.readthedocs.io/en/latest/migration/overview.html#demo has an example of how to do that.

Hi @jflory7 I have finally successfully setup fedora-messaging in the local development environment in our project!

The message being successfully heard on consumer after a happiness packet is confirmed by a receiver is here.

The setups for the same that I have done to achieve the same are:
1. Include fedora-messaging in the dependencies.
2. Made a Message Schema for our project. The message structure is like this. I have written tests for the same.
3. Packaged the Message Schema and installed as a dependancy in the docker-container.
4. Made a new container for RabbitMQ (added the necessary configurations in the project's Dockerfile) to test whether messages are being send to the broker. I also made a default script consume.py to listen to the messages that are being sent to the broker when a recipient confirm's that a message is received.

Should I send a PR for you to review? (There's still a lot of refactoring to be done but I'd love to hear your view on it :smile: )

Hi @jcline! If you'd like I could open an issue and send a PR on how to include fedora-messaging in a project that's using docker. I hit a lot of roadblock due to the added overhead that Docker provides especially while setting up RabbitMQ to verify the working of fedora-messaging in the local development server. If you approve I could send a PR to add the steps for it in the documentation. :smile:

Hi @shraddhaag, I'm happy to take any pull requests documenting fedora-messaging itself in containers, but I'd rather not have documentation on how to setup a RabbitMQ container since that's probably something best left up to the RabbitMQ project itself.

If a brief description was in the https://fedora-messaging.readthedocs.io/en/stable/tutorial/installation.html#setting-up-rabbitmq section that would probably be okay. Perhaps pointers to https://www.rabbitmq.com/download.html#docker?

@jcline I'll be happy to send a PR for documenting installation of fedora-messaging in containers. I'll also include a small description for RaabitMQ as suggested by you. Thank you for the quick response :)

Hi @jflory7 I have finally successfully setup fedora-messaging in the local development environment in our project!

Awesome!! Super exciting news. :grin:

  1. Made a Message Schema for our project. The message structure is like this. I have written tests for the same.

From discussion in #22, perhaps it is better to make recipient required instead of sender?

Should I send a PR for you to review? (There's still a lot of refactoring to be done but I'd love to hear your view on it 😄 )

I think a new pull request is helpful when you can. I am not an expert with fedora-messaging but I will try to round up one or two other folks who are subject-matter experts to take a look at your PR. I think they might be able to offer more detailed thoughts on implementation than I could offer.

From discussion in #22, perhaps it is better to make recipient required instead of sender?

As the sender and recipient are both used in the one or both the use cases, both are required as they are sent as properties of the message schema to the base schema. I have handled the value of sender sent to the broker in the view. Also I have configured the message schema to not send the username of the sender to the broker when sender is Anonymous.

I have changed the message to be send on the bus when the sender confirms sending the happiness packets.

I have received this output from the above configurations :)

I think a new pull request is helpful when you can. I am not an expert with fedora-messaging but I will try to round up one or two other folks who are subject-matter experts to take a look at your PR. I think they might be able to offer more detailed thoughts on implementation than I could offer.

Okay sure. I'm in the process of opening a PR! :)

Metadata Update from @jflory7:
- Issue marked as blocking: #182

4 months ago

Happily, this was completed in #161! I'm closing this ticket as complete. :clapper: Awesome work on this one @shraddhaag!

Also related: fedora-infra/fedora-messaging#141

Metadata Update from @jflory7:
- Issue close_status updated to: complete
- Issue status updated to: Closed (was: Open)

4 months ago

Metadata Update from @jflory7:
- Issue set to the milestone: Summer Coding 2019: community bonding

4 months ago

Login to comment on this ticket.