def __init__(self): self.connection = RabbitMQConnection.connection() self.channel = self.connection.channel() result = self.channel.queue_declare(exclusive=True) self.callback_queue = result.method.queue self.channel.basic_consume(self.on_response, no_ack=True, queue=self.callback_queue)
# but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Lesser General Public License for more details. # # You should have received a copy of the GNU Lesser General Public License # along with this library. If not, see <http://www.gnu.org/licenses/>. """ Created on Feb 25, 2011 @author: Houssem Medhioub @contact: [email protected] @organization: Institut Telecom - Telecom SudParis @version: 0.1 @license: LGPL - Lesser General Public License """ import it.tsp.cloudstack.amqp.pika.connection_amqp as RabbitMQConnection import sys import pika connection = RabbitMQConnection.connection() channel = connection.channel() channel.exchange_declare(exchange="logs", type="fanout") message = " ".join(sys.argv[1:]) or "info: Hello World!" channel.basic_publish(exchange="logs", routing_key="", body=message) print " [Producer] Sent %r" % (message,) connection.close()