@@ -472,31 +472,54 @@ convert_from_3_13_msg(#msg{header = H,
472472
473473-spec protocol_state_message_annotations (amqp_annotations (), mc :annotations ()) ->
474474 amqp_annotations ().
475- protocol_state_message_annotations (MA , Anns ) ->
475+ protocol_state_message_annotations (MA0 , Anns ) ->
476+ % % filter all MA's that are going to be overwrtten by ANNS
477+ MA = lists :filter (
478+ fun
479+ ({{symbol , <<" x-" , _ /binary >> = K }, _ }) ->
480+ not maps :is_key (K , Anns );
481+ ({{symbol , <<" x-exchange" >>}, _ }) ->
482+ not maps :is_key (? ANN_EXCHANGE , Anns );
483+ ({{symbol , <<" x-routing-key" >>}, _ }) ->
484+ not maps :is_key (? ANN_ROUTING_KEYS , Anns );
485+ ({{symbol , <<" x-opt-rabbitmq-received-time" >>}, _ }) ->
486+ not maps :is_key (<<" timestamp_in_ms" >>, Anns );
487+ ({{symbol , <<" x-opt-deaths" >>}, _ }) ->
488+ not maps :is_key (deaths , Anns );
489+ (_ ) ->
490+ true
491+ end , MA0 ),
492+
476493 maps :fold (
477494 fun (? ANN_EXCHANGE , Exchange , L ) ->
478- maps_upsert ( <<" x-exchange" >>, {utf8 , Exchange }, L ) ;
495+ [{{ symbol , <<" x-exchange" >>} , {utf8 , Exchange }} | L ] ;
479496 (? ANN_ROUTING_KEYS , RKeys , L ) ->
480497 RKey = hd (RKeys ),
481- maps_upsert (<<" x-routing-key" >>, {utf8 , RKey }, L );
498+ [{{symbol , <<" x-routing-key" >>}, {utf8 , RKey }} | L ];
499+ % maps_upsert(<<"x-routing-key">>, {utf8, RKey}, L);
482500 (<<" x-" , _ /binary >> = K , V , L )
483501 when V =/= undefined ->
484502 % % any x-* annotations get added as message annotations
485- maps_upsert (K , mc_util :infer_type (V ), L );
503+ [{{symbol , K }, mc_util :infer_type (V )} | L ];
504+ % maps_upsert(K, mc_util:infer_type(V), L);
486505 (<<" timestamp_in_ms" >>, V , L ) ->
487- maps_upsert (<<" x-opt-rabbitmq-received-time" >>, {timestamp , V }, L );
506+ [{{symbol , <<" x-opt-rabbitmq-received-time" >>},
507+ {timestamp , V }} | L ];
508+ % maps_upsert(<<"x-opt-rabbitmq-received-time">>, {timestamp, V}, L);
488509 (deaths , Deaths , L )
489510 when is_list (Deaths ) ->
490511 Maps = encode_deaths (Deaths ),
491- maps_upsert (<<" x-opt-deaths" >>, {array , map , Maps }, L );
512+ [{{symbol , <<" x-opt-deaths" >>},
513+ {array , map , Maps }} | L ];
514+ % maps_upsert(<<"x-opt-deaths">>, {array, map, Maps}, L);
492515 (_ , _ , Acc ) ->
493516 Acc
494517 end , MA , Anns ).
495518
496- maps_upsert (Key , TaggedVal , KVList ) ->
497- TaggedKey = {symbol , Key },
498- Elem = {TaggedKey , TaggedVal },
499- lists :keystore (TaggedKey , 1 , KVList , Elem ).
519+ % maps_upsert(Key, TaggedVal, KVList) ->
520+ % TaggedKey = {symbol, Key},
521+ % Elem = {TaggedKey, TaggedVal},
522+ % lists:keystore(TaggedKey, 1, KVList, Elem).
500523
501524encode (Sections ) when is_list (Sections ) ->
502525 [amqp10_framing :encode_bin (Section ) || Section <- Sections ,
0 commit comments