示例#1
0
 def _with_payload(self, payload_with_end):
     payload = payload_with_end[:-1]
     frame_end = payload_with_end[-1]
     if frame_end != '\xCE': #TODO use AMQP constants
         raise AmqpError('unexpected frame end')
     self.frame.set_payload(payload)
     self.callback(self.frame)
示例#2
0
 def publish(self,
             message,
             exchange,
             routing_key='',
             immediate=False,
             mandatory=False):
     if self.flow_stopped:
         raise FlowStoppedException
     if (immediate or mandatory) and self.on_return is None:
         raise AmqpError("on_return callback must be set for "
                         "immediate or mandatory publishing")
     self.send_method(basic.Publish(ticket=0,
                                    exchange=exchange,
                                    routing_key=routing_key,
                                    mandatory=mandatory,
                                    immediate=immediate),
                      message=message)
示例#3
0
 def select(self, callback=None):
     if self.on_error is None:
         raise AmqpError(
             "Channel.on_error callback must be set for tx mode")
     self.send_method(tx.Select(), callback)