예제 #1
0
 def test_delete_messages_removes_whole_set_of_messages(self):
     queue = Queue(database='karait_test', queue='queue_test')
     queue.write(Message({'foo': 1}))
     queue.write(Message({'foo': 2}))
     queue.write(Message({'foo': 3}))
     messages = queue.read()
     self.assertEqual(3, len(messages))
     queue.delete_messages(messages)
     messages = queue.read()
     self.assertEqual(0, len(messages))
예제 #2
0
 def test_delete_messages_removes_whole_set_of_messages(self):
     queue = Queue(
         database='karait_test',
         queue='queue_test'
     )
     queue.write(Message({'foo': 1}))
     queue.write(Message({'foo': 2}))
     queue.write(Message({'foo': 3}))
     messages = queue.read()
     self.assertEqual(3, len(messages))
     queue.delete_messages(messages)
     messages = queue.read()
     self.assertEqual(0, len(messages))
예제 #3
0
import time
import json
from karait import Queue
print("Starting python reader.")

messages_read = 0.0
start_time = time.time()

queue = Queue()
while True:
    messages = queue.read(routing_key='for_reader')
    for message in messages:
        messages_read += 1.0

        message.messages_read = messages_read
        message.messages_read_per_second = messages_read / (time.time() -
                                                            start_time)

        if (messages_read % 250) == 0.0:
            print("Message Read: \n%s" % json.dumps(message.to_dictionary()))

    queue.delete_messages(messages)
예제 #4
0
파일: reader.py 프로젝트: bcoe/karait
import time
import json
from karait import Queue
print("Starting python reader.")

messages_read = 0.0
start_time = time.time()

queue = Queue()
while True:
  messages = queue.read(routing_key='for_reader')
  for message in messages:
    messages_read += 1.0
        
    message.messages_read = messages_read
    message.messages_read_per_second = messages_read / (time.time() - start_time)
    
    if (messages_read % 250) == 0.0:
      print("Message Read: \n%s" % json.dumps(message.to_dictionary()))

  queue.delete_messages(messages)