AMQP talks to dbus for Koji Part 1
Alright, after doing a lot of reading on dbus and hashing out what I needed, I have managed to generate some code that will listen to an AMQP broker and translate that to the dbus.
#!/usr/bin/env python
# -*- coding: utf-8 -*-
#
# amqp-dbus.py
#
# Copyright 2010 bashton
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
# MA 02110-1301, USA.
import dbus
import dbus.service
from dbus.mainloop.glib import DBusGMainLoop
from moksha.api.hub import Consumer
from moksha.hub.reactor import reactor
class KojiAMQPDBusObj(dbus.service.Object):
def __init__(self, conn, object_path='/org/fedoraproject/amqp_dbus/koji/core'):
dbus.service.Object.__init__(self, conn, object_path)
@dbus.service.signal('org.fedoraproject.amqp_dbus.koji')
def dbus_notify(self, message):
pass
class KojiConsumer(Consumer):
topic='org.fedoraproject.koji.#'
DBusGMainLoop(set_as_default = True)
ses_bus = dbus.SessionBus()
busname = dbus.service.BusName('org.fedoraproject.amqp_dbus.koji', ses_bus)
kojidbus_obj = KojiAMQPDBusObj(ses_bus)
def consume(self,message):
print 'AMQP Topic : ' + message['topic']
print ' Message: ' + message['body']
self.kojidbus_obj.dbus_notify(message['body'])
def main():
kojiconsumer = KojiConsumer()
reactor.run()
return(0)
if __name__ == '__main__':
main()
A sample code that will excite this is very simple:
from moksha import hub
ahub=hub.MokshaHub()
ahub.send_message('org.fedoraproject.koji.1','a message')
ahub.close()
Now if you monitor the dbus using
dbus-monitor
you will see something like
signal sender=:1.184 -> dest=(null destination) serial=5 path=/org/fedoraproject/amqp_dbus/koji/core; interface=org.fedoraproject.amqp_dbus.koji.newpackage; member=dbus_notify
string "a message"
The next step is to write the simple notification applet that reads off of dbus. This should be fairly straightforward as many applets use dbus for doing this including ABRT.
Once that is done I will be delving into the depths of Koji to send messages out on amqp. I spoke with Luke Macken today and he seems to be ready to also help with taking on the world of AMQP and Fedora. These should be exciting times ahead.
Sorry the code indents are all wrong, I will see what I can do about that later.


Hey Brennan,
I Know very little about AMPQ, and enough to get by in Matlab. Is there is any hope of communicating with a server through AMPQ within the Matlab environment? Any tips or references would be apprecitated.