Merge branch 'stable'
This commit is contained in:
commit
e04f811092
|
@ -592,7 +592,16 @@ do_subscribe(Destination, DestHdr, Frame,
|
||||||
_ -> amqp_channel:call(
|
_ -> amqp_channel:call(
|
||||||
Channel, #'basic.qos'{prefetch_count = Prefetch})
|
Channel, #'basic.qos'{prefetch_count = Prefetch})
|
||||||
end,
|
end,
|
||||||
ExchangeAndKey = rabbit_routing_util:parse_routing(Destination),
|
case dict:find(ConsumerTag, Subs) of
|
||||||
|
{ok, _} ->
|
||||||
|
Message = "Duplicated subscription identifier",
|
||||||
|
Detail = "A subscription identified by '~s' alredy exists.",
|
||||||
|
error(Message, Detail, [ConsumerTag], State),
|
||||||
|
send_error(Message, Detail, [ConsumerTag], State),
|
||||||
|
{stop, normal, close_connection(State)};
|
||||||
|
error ->
|
||||||
|
ExchangeAndKey =
|
||||||
|
rabbit_routing_util:parse_routing(Destination),
|
||||||
try
|
try
|
||||||
amqp_channel:subscribe(Channel,
|
amqp_channel:subscribe(Channel,
|
||||||
#'basic.consume'{
|
#'basic.consume'{
|
||||||
|
@ -606,8 +615,8 @@ do_subscribe(Destination, DestHdr, Frame,
|
||||||
ok = rabbit_routing_util:ensure_binding(
|
ok = rabbit_routing_util:ensure_binding(
|
||||||
Queue, ExchangeAndKey, Channel)
|
Queue, ExchangeAndKey, Channel)
|
||||||
catch exit:Err ->
|
catch exit:Err ->
|
||||||
%% it's safe to delete this queue, it was server-named
|
%% it's safe to delete this queue, it
|
||||||
%% and declared by us
|
%% was server-named and declared by us
|
||||||
case Destination of
|
case Destination of
|
||||||
{exchange, _} ->
|
{exchange, _} ->
|
||||||
ok = maybe_clean_up_queue(Queue, State);
|
ok = maybe_clean_up_queue(Queue, State);
|
||||||
|
@ -626,7 +635,8 @@ do_subscribe(Destination, DestHdr, Frame,
|
||||||
multi_ack = IsMulti,
|
multi_ack = IsMulti,
|
||||||
description = Description},
|
description = Description},
|
||||||
Subs),
|
Subs),
|
||||||
route_state = RouteState1});
|
route_state = RouteState1})
|
||||||
|
end;
|
||||||
{error, _} = Err ->
|
{error, _} = Err ->
|
||||||
Err
|
Err
|
||||||
end.
|
end.
|
||||||
|
|
|
@ -3,6 +3,34 @@ import stomp
|
||||||
import base
|
import base
|
||||||
import time
|
import time
|
||||||
|
|
||||||
|
class TestErrorsAndCloseConnection(base.BaseTest):
|
||||||
|
def __test_duplicate_consumer_tag_with_headers(self, destination, headers):
|
||||||
|
self.subscribe_dest(self.conn, destination, None,
|
||||||
|
headers = headers)
|
||||||
|
|
||||||
|
self.subscribe_dest(self.conn, destination, None,
|
||||||
|
headers = headers)
|
||||||
|
|
||||||
|
self.assertTrue(self.listener.await())
|
||||||
|
|
||||||
|
self.assertEquals(1, len(self.listener.errors))
|
||||||
|
errorReceived = self.listener.errors[0]
|
||||||
|
self.assertEquals("Duplicated subscription identifier", errorReceived['headers']['message'])
|
||||||
|
self.assertEquals("A subscription identified by 'T_1' alredy exists.", errorReceived['message'])
|
||||||
|
time.sleep(2)
|
||||||
|
self.assertFalse(self.conn.is_connected())
|
||||||
|
|
||||||
|
|
||||||
|
def test_duplicate_consumer_tag_with_transient_destination(self):
|
||||||
|
destination = "/exchange/amq.direct/duplicate-consumer-tag-test1"
|
||||||
|
self.__test_duplicate_consumer_tag_with_headers(destination, {'id': 1})
|
||||||
|
|
||||||
|
def test_duplicate_consumer_tag_with_durable_destination(self):
|
||||||
|
destination = "/queue/duplicate-consumer-tag-test2"
|
||||||
|
self.__test_duplicate_consumer_tag_with_headers(destination, {'id': 1,
|
||||||
|
'persistent': True})
|
||||||
|
|
||||||
|
|
||||||
class TestErrors(base.BaseTest):
|
class TestErrors(base.BaseTest):
|
||||||
|
|
||||||
def test_invalid_queue_destination(self):
|
def test_invalid_queue_destination(self):
|
||||||
|
@ -64,4 +92,3 @@ class TestErrors(base.BaseTest):
|
||||||
self.assertEquals("'" + content + "' is not a valid " +
|
self.assertEquals("'" + content + "' is not a valid " +
|
||||||
dtype + " destination\n",
|
dtype + " destination\n",
|
||||||
err['message'])
|
err['message'])
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue