[Twisted-Python] MultiService puzzler

Don Smith donwsmith at gmail.com
Wed Dec 12 00:08:30 EST 2007

Hi all,

I'm trying to build an app using MultiService. I need to have 2 services,
one that listens for UDP datagrams and another that can send those datagrams
to an ActiveMQ server via a Stomp client.

I can set up the two services just fine, but I'm stuck with how to call the
MQ service send method from the UDPServer instance.

Some code to illustrate:

class GetUDP(DatagramProtocol):

    def datagramReceived(self, datagram, address):
        print datagram,address
        #Send datagram to the queue server
        # I don't know how to access the send method for the Stomp client

testq = internet.TCPClient(APPVARIABLES['queue_server'],
int(APPVARIABLES['queue_port']), connections.StompClientFactory

#create a UDP listener
#TODO: this should be driven by the config file
#reactor.listenUDP(42000, GetUDP())
# Create an application as normal
application = service.Application("MQExample")

# Connect our MultiService to the application, just like a normal service.

Note: this is won't run exactly as is, but should give an idea of my
problem. I've setup the ActiveMQ Stomp client as 'testq'. I've setup the
UDPServer service to listen for UDP packets. I can get the UDP packets and
print them, but I can't figure out how to hand them to my Stomp client's
send() method. This is possible, right?


-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://twistedmatrix.com/pipermail/twisted-python/attachments/20071211/7ffb9910/attachment.htm 

More information about the Twisted-Python mailing list