2016-09-04 1 views
1

Je veux définir le TTL à 1 sec pour une file d'attente Rabbitmq en utilisant pika. J'ai essayé le code suivantdéfinir 'x-message-ttl' dans pika python

import ctypes 
int32=ctypes.c_int 
connection = pika.BlockingConnection(pika.ConnectionParameters(
     host='localhost')) 
channel = connection.channel() 
this=channel.queue_declare(queue='hello', 
          arguments={'x-message-ttl' : int32(1000)} 
          ) 

channel.basic_publish(exchange='', 
       routing_key='hello', 
       body=message) 

print this.method.consumer_count 

Je reçois l'erreur suivante

Traceback (most recent call last): 
    File "rabt.py", line 8, in <module> 
    arguments={'x-message-ttl' : int32(1000)} 
    File "build\bdist.win32\egg\pika\adapters\blocking_connection.py", line 2397, in queue_declare 
    File "build\bdist.win32\egg\pika\channel.py", line 815, in queue_declare 
    File "build\bdist.win32\egg\pika\channel.py", line 1312, in _rpc 
    File "build\bdist.win32\egg\pika\channel.py", line 1324, in _send_method 
    File "build\bdist.win32\egg\pika\connection.py", line 2139, in _send_method 
    File "build\bdist.win32\egg\pika\connection.py", line 2119, in _send_frame 
    File "build\bdist.win32\egg\pika\frame.py", line 74, in marshal 
    File "build\bdist.win32\egg\pika\spec.py", line 1015, in encode 
    File "build\bdist.win32\egg\pika\data.py", line 85, in encode_table 
    File "build\bdist.win32\egg\pika\data.py", line 153, in encode_value 
pika.exceptions.UnsupportedAMQPFieldException: (['\x00\x00', '\x05', 'hello', '\x00', None, '\r', 'x-message-ttl'], c_long(1000)) 

Je suis en train de lettre morte tous les messages dans cette file d'attente particulière après 1 sec. Puis-je savoir comment régler le TTL en utilisant Pika? Merci!

Répondre

2
connection = pika.BlockingConnection(pika.ConnectionParameters(
     host='localhost')) 
channel = connection.channel() 
this=channel.queue_declare(queue='hello', 
          arguments={'x-message-ttl' : 1000} 
          ) 

vous n'avez pas besoin la distribution