@@ -1562,14 +1562,10 @@ incoming_link_transfer(
1562
1562
[? MODULE , [amqp10_framing :pprint (Section ) || Section <- Sections ]]),
1563
1563
case rabbit_exchange_lookup (Exchange ) of
1564
1564
{ok , X = # exchange {name = # resource {name = XNameBin }}} ->
1565
- Anns0 = #{? ANN_EXCHANGE => XNameBin },
1566
- Anns = case LinkRKey of
1567
- undefined -> Anns0 ;
1568
- _ -> Anns0 #{? ANN_ROUTING_KEYS => [LinkRKey ]}
1569
- end ,
1565
+ Anns = #{? ANN_EXCHANGE => XNameBin },
1570
1566
Mc0 = mc :init (mc_amqp , Sections , Anns ),
1571
- Mc1 = rabbit_message_interceptor : intercept ( Mc0 ),
1572
- { Mc , RoutingKey } = ensure_routing_key (Mc1 ),
1567
+ { RoutingKey , Mc1 } = ensure_routing_key ( LinkRKey , Mc0 ),
1568
+ Mc = rabbit_message_interceptor : intercept (Mc1 ),
1573
1569
check_user_id (Mc , User ),
1574
1570
messages_received (Settled ),
1575
1571
check_write_permitted_on_topic (X , User , RoutingKey ),
@@ -1620,19 +1616,24 @@ rabbit_exchange_lookup(X = #exchange{}) ->
1620
1616
rabbit_exchange_lookup (XName = # resource {}) ->
1621
1617
rabbit_exchange :lookup (XName ).
1622
1618
1623
- ensure_routing_key (Mc ) ->
1624
- case mc :routing_keys (Mc ) of
1625
- [RoutingKey ] ->
1626
- {Mc , RoutingKey };
1627
- [] ->
1628
- % % Set the default routing key of AMQP 0.9.1 'basic.publish'{}.
1629
- % % For example, when the client attached to target /exchange/amq.fanout and sends a
1630
- % % message without setting a 'subject' in the message properties, the routing key is
1631
- % % ignored during routing, but receiving code paths still expect some routing key to be set.
1632
- DefaultRoutingKey = <<" " >>,
1633
- Mc1 = mc :set_annotation (? ANN_ROUTING_KEYS , [DefaultRoutingKey ], Mc ),
1634
- {Mc1 , DefaultRoutingKey }
1635
- end .
1619
+ ensure_routing_key (LinkRKey , Mc0 ) ->
1620
+ RKey = case LinkRKey of
1621
+ undefined ->
1622
+ case mc :property (subject , Mc0 ) of
1623
+ undefined ->
1624
+ % % Set the default routing key of AMQP 0.9.1 'basic.publish'{}.
1625
+ % % For example, when the client attached to target /exchange/amq.fanout and sends a
1626
+ % % message without setting a 'subject' in the message properties, the routing key is
1627
+ % % ignored during routing, but receiving code paths still expect some routing key to be set.
1628
+ <<" " >>;
1629
+ {utf8 , Subject } ->
1630
+ Subject
1631
+ end ;
1632
+ _ ->
1633
+ LinkRKey
1634
+ end ,
1635
+ Mc = mc :set_annotation (? ANN_ROUTING_KEYS , [RKey ], Mc0 ),
1636
+ {RKey , Mc }.
1636
1637
1637
1638
process_routing_confirm ([], _SenderSettles = true , _ , U ) ->
1638
1639
rabbit_global_counters :messages_unroutable_dropped (? PROTOCOL , 1 ),
0 commit comments