Sha256: f8ca2dbfa04f24eccfe94ad7eb2b1e30234ff8090e4614da71424b2db0e839dc

Contents?: true

Size: 1.67 KB

Versions: 2

Compression:

Stored size: 1.67 KB

Contents

# encoding: utf-8

require 'spec_helper'
require 'integration/eventmachine/spec_helper'

require "multi_json"

describe AMQ::Client::EventMachineClient, "Basic.Publish" do
  include EventedSpec::SpecHelper
  default_timeout 21.0

  context "when message size exceeds negotiated frame size" do
    let(:message) { "z" * 1024 * 1024 * 8 }

    it "correctly frames things" do
      @received_messages = []

      @received_messages = []
      em_amqp_connect do |client|
        client.on_error do |conn, connection_close|
          fail "Handling a connection-level exception: #{connection_close.reply_text}"
        end

        channel = AMQ::Client::Channel.new(client, 1)
        channel.open do
          queue = AMQ::Client::Queue.new(client, channel).declare(false, false, false, true)
          queue.bind("amq.fanout")

          queue.consume(true) do |amq_method|
            queue.on_delivery do |method, header, payload|
              @received_messages << payload
            end

            exchange = AMQ::Client::Exchange.new(client, channel, "amq.fanout", :fanout)
            EventMachine.add_timer(2.0) do
              30.times do
                Thread.new do
                  exchange.publish(message, queue.name, {}, false, true)
                end
              end
            end
          end

          done(14.0) {
            # we don't care about the exact number, just the fact that there are
            # no UNEXPECTED_FRAME connection-level exceptions. MK.
            @received_messages.size.should > 10
            @received_messages.all? {|m| m == message}.should be_true
          }
        end
      end # em_amqp_connect
    end # it
  end # context
end # describe

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
amq-client-1.0.0.pre2 spec/integration/eventmachine/basic_publish_with_framing_spec.rb
amq-client-1.0.0.pre1 spec/integration/eventmachine/basic_publish_with_framing_spec.rb