@@ -28,6 +28,7 @@ groups() ->
2828 publish_unauthorized_error ,
2929 subscribe_error ,
3030 subscribe ,
31+ subscribe_with_x_priority ,
3132 unsubscribe_ack ,
3233 subscribe_ack ,
3334 send ,
@@ -161,6 +162,42 @@ subscribe(Config) ->
161162 {ok , _Client2 , _ , [<<" hello" >>]} = stomp_receive (Client1 , " MESSAGE" ),
162163 ok .
163164
165+ subscribe_with_x_priority (Config ) ->
166+ Version = ? config (version , Config ),
167+ StompPort = rabbit_ct_broker_helpers :get_node_config (Config , 0 , tcp_port_stomp ),
168+ Channel = ? config (amqp_channel , Config ),
169+ ClientA = ? config (stomp_client , Config ),
170+ # 'queue.declare_ok' {} =
171+ amqp_channel :call (Channel , # 'queue.declare' {queue = ? QUEUE ,
172+ durable = true ,
173+ arguments = [{<<" x-queue-type" >>, longstr , <<" quorum" >>},
174+ {<<" x-single-active-consumer" >>, bool , true }
175+ ]}),
176+
177+ % % subscribe and wait for receipt
178+ rabbit_stomp_client :send (
179+ ClientA , " SUBSCRIBE" , [{" destination" , ? DESTINATION }, {" receipt" , " foo" }]),
180+ {ok , _ClientA1 , _ , _ } = stomp_receive (ClientA , " RECEIPT" ),
181+
182+ % % subscribe with a higher priority and wait for receipt
183+ {ok , ClientB } = rabbit_stomp_client :connect (Version , StompPort ),
184+ rabbit_stomp_client :send (
185+ ClientB , " SUBSCRIBE" , [{" destination" , ? DESTINATION },
186+ {" receipt" , " foo" },
187+ {" x-priority" , 10 }
188+ ]),
189+ {ok , ClientB1 , _ , _ } = stomp_receive (ClientB , " RECEIPT" ),
190+
191+ % % send from amqp
192+ Method = # 'basic.publish' {exchange = <<" " >>, routing_key = ? QUEUE },
193+
194+ amqp_channel :call (Channel , Method , # amqp_msg {props = # 'P_basic' {},
195+ payload = <<" hello" >>}),
196+
197+ % % ClientB should receive the message since it has a higher priority
198+ {ok , _ClientB2 , _ , [<<" hello" >>]} = stomp_receive (ClientB1 , " MESSAGE" ),
199+ ok .
200+
164201unsubscribe_ack (Config ) ->
165202 Channel = ? config (amqp_channel , Config ),
166203 Client = ? config (stomp_client , Config ),
0 commit comments