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
# 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 ))