Sha256: b96c7a9112786923ad6525966ae6fd7fe4f2f0e6c1a8ed267f60804e822a00d3

Contents?: true

Size: 1.94 KB

Versions: 42

Compression:

Stored size: 1.94 KB

Contents

module Fog
  module AWS
    class SQS
      class Real
        require 'fog/aws/parsers/sqs/send_message'

        # Add a message to a queue
        #
        # ==== Parameters
        # * queue_url<~String> - Url of queue to add message to
        # * message<~String> - Message to add to queue
        #
        # ==== See Also
        # http://docs.amazonwebservices.com/AWSSimpleQueueService/latest/APIReference/Query_QuerySendMessage.html
        #

        def send_message(queue_url, message)
          request({
            'Action'      => 'SendMessage',
            'MessageBody' => message,
            :path         => path_from_queue_url(queue_url),
            :parser       => Fog::Parsers::AWS::SQS::SendMessage.new
          })
        end
      end

      class Mock
        def send_message(queue_url, message)
          Excon::Response.new.tap do |response|
            if (queue = data[:queues][queue_url])
              response.status = 200

              now        = Time.now
              message_id = Fog::AWS::Mock.sqs_message_id
              md5        = Digest::MD5.hexdigest(message)

              queue[:messages][message_id] = {
                'MessageId'  => message_id,
                'Body'       => message,
                'MD5OfBody'  => md5,
                'Attributes' => {
                  'SenderId'      => Fog::AWS::Mock.sqs_message_id,
                  'SentTimestamp' => now
                }
              }

              queue['Attributes']['LastModifiedTimestamp'] = now

              response.body = {
                'ResponseMetadata' => {
                  'RequestId' => Fog::AWS::Mock.request_id
                },
                'MessageId'        => message_id,
                'MD5OfMessageBody' => md5
              }
            else
              response.status = 404
              raise(Excon::Errors.status_error({:expects => 200}, response))
            end
          end
        end
      end
    end
  end
end

Version data entries

42 entries across 42 versions & 5 rubygems

Version Path
fog-aws-0.9.3 lib/fog/aws/requests/sqs/send_message.rb
fog-aws-0.9.2 lib/fog/aws/requests/sqs/send_message.rb
fog-aws-0.9.1 lib/fog/aws/requests/sqs/send_message.rb
fog-aws-0.9.0 lib/fog/aws/requests/sqs/send_message.rb
fog-aws-0.8.1 lib/fog/aws/requests/sqs/send_message.rb
fog-aws-0.8.0 lib/fog/aws/requests/sqs/send_message.rb
vagrant-cloudstack-1.2.0 vendor/bundle/gems/fog-aws-0.7.5/lib/fog/aws/requests/sqs/send_message.rb
fog-aws-0.7.6 lib/fog/aws/requests/sqs/send_message.rb
fog-aws-0.7.5 lib/fog/aws/requests/sqs/send_message.rb
fog-aws-0.7.4 lib/fog/aws/requests/sqs/send_message.rb
fog-aws-0.7.3 lib/fog/aws/requests/sqs/send_message.rb
fog-aws-0.7.2 lib/fog/aws/requests/sqs/send_message.rb
fog-aws-0.6.0 lib/fog/aws/requests/sqs/send_message.rb
fog-aws-0.5.0 lib/fog/aws/requests/sqs/send_message.rb
fog-aws-0.4.1 lib/fog/aws/requests/sqs/send_message.rb
vagrant-cloudstack-1.1.0 vendor/bundle/gems/fog-1.22.1/lib/fog/aws/requests/sqs/send_message.rb
fog-aws-0.4.0 lib/fog/aws/requests/sqs/send_message.rb
fog-aws-0.3.0 lib/fog/aws/requests/sqs/send_message.rb
fog-aws-0.2.2 lib/fog/aws/requests/sqs/send_message.rb
fog-aws-0.2.0 lib/fog/aws/requests/sqs/send_message.rb