구독 워크플로 자습서: 워크플로 실행 - Amazon Simple Workflow Service

기계 번역으로 제공되는 번역입니다. 제공된 번역과 원본 영어의 내용이 상충하는 경우에는 영어 버전이 우선합니다.

구독 워크플로 자습서: 워크플로 실행

지금까지 워크플로, 활동과 워크플로 및 활동 Poller 구현을 완료했으므로 워크플로를 실행할 준비가 되었습니다.

아직 수행하지 않은 경우 자습서 파트 1의 AWS 세션 구성 단원에서처럼 aws-config.txt 파일에서 AWS 액세스 키를 제공해야 합니다.

이제, 명령줄로 이동해 자습서 소스 파일이 있는 디렉터리로 변경합니다. 다음 파일이 필요합니다.

. |-- aws-config.txt |-- basic_activity.rb |-- get_contact_activity.rb |-- send_result_activity.rb |-- subscribe_topic_activity.rb |-- swf_sns_activities.rb |-- swf_sns_workflow.rb |-- utils.rb `-- wait_for_confirmation_activity.rb

이제, 다음 명령을 사용해 워크플로를 시작합니다.

ruby swf_sns_workflow.rb

이 명령은 워크플로를 시작하고 복사해 별도의 명령줄 창에 붙여 넣을 수 있는 한 줄짜리 메시지를 출력해야 합니다(자습서 소스 파일을 복사한 경우에는 다른 컴퓨터에도 붙여 넣을 수 있음).

Amazon SWF Example ------------------ Start the activity worker, preferably in a separate command-line window, with the following command: > ruby swf_sns_activities.rb 87097e76-7c0c-41c7-817b-92527bb0ea85-activities You can copy & paste it if you like, just don't copy the '>' character. Press return when you're ready...

이 워크플로 코드는 별도의 창에서 활동 Poller를 시작할 때까지 대기합니다.

새 명령줄 창을 열고 소스 파일이 있는 디렉터리로 다시 변경한 다음 swf_sns_workflow.rb 파일에서 제공한 명령을 사용해 활동 Poller를 시작합니다. 예를 들어, 앞선 출력을 수신한 경우 다음과 같이 입력(또는 붙여넣기)합니다.

ruby swf_sns_activities.rb 87097e76-7c0c-41c7-817b-92527bb0ea85-activities

활동 Poller 실행을 시작하면 활동 Poller가 활동 등록에 대한 정보를 출력하기 시작합니다.

** initialized and registered activity: get_contact_activity ** initialized and registered activity: subscribe_topic_activity ** initialized and registered activity: wait_for_confirmation_activity ** initialized and registered activity: send_result_activity

이제 원래 명령줄 창으로 돌아가 Return을 눌러 워크플로 실행을 시작할 수 있습니다. 그러면 워크플로를 등록하고 첫 번째 활동을 예약합니다.

Starting workflow execution. ** registered workflow: swf-sns-workflow ** scheduling activity task: get_contact_activity

활동 Poller가 실행 중인 다른 창으로 돌아갑니다. 실행 중인 첫 번째 활동의 결과가 표시되어 이메일 및 SMS 전화번호를 입력할 수 있는 프롬프트를 제공합니다. 이러한 데이터 중 하나 또는 둘 다를 입력한 다음 텍스트 입력을 확인합니다.

activity task received: <AWS::SimpleWorkflow::ActivityTask> ** Starting activity task: get_contact_activity Please enter either an email address or SMS message (mobile phone) number to receive Amazon SNS notifications. You can also enter both to use both address types. If you enter a phone number, it must be able to receive SMS messages, and must be 11 digits (such as 12065550101 to represent the number 1-206-555-0101). Email: me@example.com Phone: 12065550101 You entered: email: me@example.com phone: 12065550101 Is this correct? (y/n): y
참고

여기 제공된 전화번호를 가상의 번호로, 설명을 위해서만 사용됩니다. 실제로는 각자의 전화번호 및 이메일 주소를 사용하십시오!

이 정보를 입력하자마자 Amazon SNS로부터 주제 구독을 확인하라는 이메일 또는 문자 메시지가 도착해야 합니다. SMS 번호를 입력한 경우에는 휴대폰에 다음과 같은 메시지가 표시됩니다.

이 메시지에 YES라고 회신하면 send_result_activity로 제공한 응답을 받게 됩니다.

이러한 과정이 진행되는 동안 명령줄 창에서는 어떻게 진행되고 있는지 봤습니까? 워크플로 및 활동 Poller 둘 다 열심히 작업 중이었습니다.

워크플로 Poller에서는 다음과 같이 출력됩니다.

** scheduling activity task: subscribe_topic_activity ** scheduling activity task: wait_for_confirmation_activity ** scheduling activity task: send_result_activity !! All activities complete! Sending complete_workflow_execution...

활동 Poller에서는 다음과 같이 출력되는데, 다른 명령줄 창에서 동시에 출력됩니다.

++ Activity task completed: get_contact_activity ** Starting activity task: subscribe_topic_activity ++ Activity task completed: subscribe_topic_activity ** Starting activity task: wait_for_confirmation_activity Topic subscription still pending for (email: me@example.com) Topic subscription confirmed for (sms: 12065550101) ++ Activity task completed: wait_for_confirmation_activity ** Starting activity task: send_result_activity Thanks, you've successfully confirmed registration, and your workflow is complete! ++ Activity task completed: send_result_activity All done!

축하합니다. 워크플로를 완료했고 이 자습서도 마치셨습니다!

제한 시간이 작동하는 방식을 보거나 다른 데이터를 입력하기 위해 이 워크플로를 다시 실행하고 싶을 수 있습니다. 토픽을 구독하면 구독을 해제할 때까지 계속 구독된 상태임을 명심하십시오. 주제 구독을 해제하기 전에 워크플로를 다시 실행하면 wait_for_confirmation_activity가 구독이 이미 확인되었음을 확인할 것이기 때문에 자동 성공으로 이어질 것입니다.

Amazon SNS 주제에서 구독을 해지하려면

  • 문자 메시지에 부정적으로 응답합니다(STOP 보내기).

  • 이메일에서 수신한 구독 해제 링크를 선택합니다.

이제 주제를 다시 구독할 준비가 되었습니다.

추가 정보

이 자습서에서는 기본적인 내용에 대해 많은 부분을 다뤘지만 AWS SDK for Ruby, Amazon SWF 또는 Amazon SNS에 대해 배워야 할 부분은 아직도 많습니다. 자세한 내용 및 더 많은 예를 보려면 각 항목에 해당하는 공식 문서를 참조하십시오.