@@ -38,7 +38,9 @@ groups() ->
3838 [
3939 responder_attaches_queue_target ,
4040 many_replies ,
41- many_volatile_queues_same_session
41+ many_volatile_queues_same_session ,
42+ failure_multiple_consumers_same_session_same_queue ,
43+ failure_multiple_consumers_different_session_same_queue
4244 ]},
4345 {cluster_size_3 , [shuffle ],
4446 [
@@ -495,6 +497,63 @@ many_volatile_queues_same_session(Config) ->
495497 ok = close_connection_sync (ConnResponder ),
496498 ok = close_connection_sync (ConnRequester ).
497499
500+ % % Test that there can't be multiple consumers (from one session) on one volatile queue.
501+ failure_multiple_consumers_same_session_same_queue (Config ) ->
502+ OpnConf0 = connection_config (Config ),
503+ OpnConf = OpnConf0 #{notify_with_performative => true },
504+ {ok , Conn } = amqp10_client :open_connection (OpnConf ),
505+ {ok , Session } = amqp10_client :begin_session_sync (Conn ),
506+ {ok , Receiver1 } = amqp10_client :attach_link (Session , attach_args (<<" receiver-1" >>)),
507+ AddrVolQ = receive {amqp10_event , {link , Receiver1 , {attached , Attach }}} ->
508+ # 'v1_0.attach' {
509+ source = # 'v1_0.source' {
510+ address = {utf8 , Addr }}} = Attach ,
511+ Addr
512+ after 9000 -> ct :fail ({missing_event , ? LINE })
513+ end ,
514+
515+ {ok , Receiver2 } = amqp10_client :attach_receiver_link (
516+ Session , <<" receiver-2" >>, AddrVolQ , settled ),
517+ receive {amqp10_event , {link , Receiver2 , {detached , # 'v1_0.detach' {}}}} ->
518+ ok
519+ after 9000 -> ct :fail ({missing_event , ? LINE })
520+ end ,
521+
522+ ok = end_session_sync (Session ),
523+ ok = close_connection_sync (Conn ).
524+
525+ % % Test that there can't be multiple consumers (from different sessions) on one volatile queue.
526+ failure_multiple_consumers_different_session_same_queue (Config ) ->
527+ OpnConf0 = connection_config (Config ),
528+ OpnConf = OpnConf0 #{notify_with_performative => true },
529+ {ok , Conn } = amqp10_client :open_connection (OpnConf ),
530+ {ok , Session1 } = amqp10_client :begin_session_sync (Conn ),
531+ {ok , Session2 } = amqp10_client :begin_session_sync (Conn ),
532+
533+ {ok , Receiver1 } = amqp10_client :attach_link (Session1 , attach_args (<<" receiver-1" >>)),
534+ AddrVolQ = receive {amqp10_event , {link , Receiver1 , {attached , Attach }}} ->
535+ # 'v1_0.attach' {
536+ source = # 'v1_0.source' {
537+ address = {utf8 , Addr }}} = Attach ,
538+ Addr
539+ after 9000 -> ct :fail ({missing_event , ? LINE })
540+ end ,
541+
542+ {ok , Receiver2 } = amqp10_client :attach_receiver_link (
543+ Session2 , <<" receiver-2" >>, AddrVolQ , settled ),
544+ receive {amqp10_event , {link , Receiver2 , {detached , # 'v1_0.detach' {error = Error }}}} ->
545+ ? assertMatch (
546+ # 'v1_0.error' {
547+ description = {utf8 , <<" only creator channel may consume from "
548+ " queue 'amq.rabbitmq.reply-to." , _ /binary >>}},
549+ Error )
550+ after 9000 -> ct :fail ({missing_event , ? LINE })
551+ end ,
552+
553+ ok = end_session_sync (Session1 ),
554+ ok = end_session_sync (Session2 ),
555+ ok = close_connection_sync (Conn ).
556+
498557% % "new" and "old" refers to new and old RabbitMQ versions in mixed version tests.
499558rpc_new_to_old_node (Config ) ->
500559 rpc (0 , 1 , Config ).
0 commit comments