2013-04-09 2 views
0

내가 설정 서버에 SQS를 보내드립니다 클라이언트에 필요
Q = sqs.queues.create ("q_name")
m = q.send_message ("메타")
...SQS 메시지가

하지만, 서버가 클라이언트의 메시지를 읽을 수있는 방법?
미리 감사드립니다.

답변

0

먼저 서버를 SQS에 연결해야 큐를 가져올 수 있습니다. 대기열에서 get_messages를 수행하십시오. 속성에 대한 자세한 정보를 얻으려면 boto docs으로 가십시오. 이렇게하면 매개 변수에 따라 1 - 10 개의 메시지 개체가 제공됩니다. 그런 다음 각 객체에서 get_body()를 수행하면 메시지 문자열을 갖게됩니다.

다음은 Python의 간단한 예입니다. 미안 루비를 몰라.

sqsConn = connect_to_region("us-west-1", # this is the region you created the queue in 
         aws_access_key_id=AWS_ACCESS_KEY_ID, 
         aws_secret_access_key=AWS_SECRET_ACCESS_KEY) 

QUEUE = sqsConn.get_queue("my-queue") # the name of your queue 

msgs = QUEUE.get_messages(num_messages=10, # try and get 10 messages 
          wait_time_seconds=1, # wait 1 second for these messages 
          visibility_timeout=10) # keep them visible for 10 seconds 

body = msgs[0].get_body() # get the string from the first object 

희망이 있습니다.

+0

도움을 주셔서 감사합니다. 파이썬으로도 도움이되었습니다. –