def __init__(self, receive_queue_messages_response=None): if receive_queue_messages_response: self.error = receive_queue_messages_response.Error self.is_error = receive_queue_messages_response.IsError self.is_peek = receive_queue_messages_response.IsPeak my_messages = [] for message in receive_queue_messages_response.Messages: my_messages.append(Message(message)) self.messages = receive_queue_messages_response.Messages self.messages_expired = receive_queue_messages_response.MessagesExpired self.messages_received = receive_queue_messages_response.MessagesReceived self.request_id = receive_queue_messages_response.RequestID
def create_queue_message(meta_data, body, policy=None): message = Message() message.metadata = meta_data message.body = body message.tags = [ ('key', 'value'), ('key2', 'value2'), ] message.attributes = None message.policy = policy return message
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE # SOFTWARE. from kubemq.queue.message_queue import MessageQueue from kubemq.queue.message import Message if __name__ == "__main__": queue = MessageQueue("hello-world-queue", "test-queue-client-id2", "localhost:50000") message = Message() message.metadata = 'metadata' message.body = "some-simple_queue-queue-message".encode('UTF-8') message.attributes = None try: sent = queue.send_queue_message(message) if sent.error: print('message enqueue error, error:' + sent.error) else: print('message sent at: %d' % ( sent.sent_at )) except Exception as err: print('message enqueue error, error:%s' % ( err ))