@@ -312,6 +312,7 @@ public function getBunnyChannel(): Channel
312312 public function convertMessage (BunnyMessage $ bunnyMessage ): InteropAmqpMessage
313313 {
314314 $ headers = $ bunnyMessage ->headers ;
315+ $ headers = $ this ->convertHeadersFromBunnyNotation ($ headers );
315316
316317 $ properties = [];
317318 if (isset ($ headers ['application_headers ' ])) {
@@ -333,4 +334,106 @@ public function convertMessage(BunnyMessage $bunnyMessage): InteropAmqpMessage
333334
334335 return $ message ;
335336 }
337+
338+ /** @internal It must be used here and in the producer only */
339+ public function convertHeadersToBunnyNotation (array $ headers ): array
340+ {
341+ if (isset ($ headers ['content_type ' ])) {
342+ $ headers ['content-type ' ] = $ headers ['content_type ' ];
343+ unset($ headers ['content_type ' ]);
344+ }
345+
346+ if (isset ($ headers ['content_encoding ' ])) {
347+ $ headers ['content-encoding ' ] = $ headers ['content_encoding ' ];
348+ unset($ headers ['content_encoding ' ]);
349+ }
350+
351+ if (isset ($ headers ['delivery_mode ' ])) {
352+ $ headers ['delivery-mode ' ] = $ headers ['delivery_mode ' ];
353+ unset($ headers ['delivery_mode ' ]);
354+ }
355+
356+ if (isset ($ headers ['correlation_id ' ])) {
357+ $ headers ['correlation-id ' ] = $ headers ['correlation_id ' ];
358+ unset($ headers ['correlation_id ' ]);
359+ }
360+
361+ if (isset ($ headers ['reply_to ' ])) {
362+ $ headers ['reply-to ' ] = $ headers ['reply_to ' ];
363+ unset($ headers ['reply_to ' ]);
364+ }
365+
366+ if (isset ($ headers ['message_id ' ])) {
367+ $ headers ['message-id ' ] = $ headers ['message_id ' ];
368+ unset($ headers ['message_id ' ]);
369+ }
370+
371+ if (isset ($ headers ['user_id ' ])) {
372+ $ headers ['user-id ' ] = $ headers ['user_id ' ];
373+ unset($ headers ['user_id ' ]);
374+ }
375+
376+ if (isset ($ headers ['app_id ' ])) {
377+ $ headers ['app-id ' ] = $ headers ['app_id ' ];
378+ unset($ headers ['app_id ' ]);
379+ }
380+
381+ if (isset ($ headers ['cluster_id ' ])) {
382+ $ headers ['cluster-id ' ] = $ headers ['cluster_id ' ];
383+ unset($ headers ['cluster_id ' ]);
384+ }
385+
386+ return $ headers ;
387+ }
388+
389+ /** @internal It must be used here and in the consumer only */
390+ public function convertHeadersFromBunnyNotation (array $ bunnyHeaders ): array
391+ {
392+ if (isset ($ bunnyHeaders ['content-type ' ])) {
393+ $ bunnyHeaders ['content_type ' ] = $ bunnyHeaders ['content-type ' ];
394+ unset($ bunnyHeaders ['content-type ' ]);
395+ }
396+
397+ if (isset ($ bunnyHeaders ['content-encoding ' ])) {
398+ $ bunnyHeaders ['content_encoding ' ] = $ bunnyHeaders ['content-encoding ' ];
399+ unset($ bunnyHeaders ['content-encoding ' ]);
400+ }
401+
402+ if (isset ($ bunnyHeaders ['delivery-mode ' ])) {
403+ $ bunnyHeaders ['delivery_mode ' ] = $ bunnyHeaders ['delivery-mode ' ];
404+ unset($ bunnyHeaders ['delivery-mode ' ]);
405+ }
406+
407+ if (isset ($ bunnyHeaders ['correlation-id ' ])) {
408+ $ bunnyHeaders ['correlation_id ' ] = $ bunnyHeaders ['correlation-id ' ];
409+ unset($ bunnyHeaders ['correlation-id ' ]);
410+ }
411+
412+ if (isset ($ bunnyHeaders ['reply-to ' ])) {
413+ $ bunnyHeaders ['reply_to ' ] = $ bunnyHeaders ['reply-to ' ];
414+ unset($ bunnyHeaders ['reply-to ' ]);
415+ }
416+
417+ if (isset ($ bunnyHeaders ['message-id ' ])) {
418+ $ bunnyHeaders ['message_id ' ] = $ bunnyHeaders ['message-id ' ];
419+ unset($ bunnyHeaders ['message-id ' ]);
420+ }
421+
422+ if (isset ($ bunnyHeaders ['user-id ' ])) {
423+ $ bunnyHeaders ['user_id ' ] = $ bunnyHeaders ['user-id ' ];
424+ unset($ bunnyHeaders ['user-id ' ]);
425+ }
426+
427+ if (isset ($ bunnyHeaders ['app-id ' ])) {
428+ $ bunnyHeaders ['app_id ' ] = $ bunnyHeaders ['app-id ' ];
429+ unset($ bunnyHeaders ['app-id ' ]);
430+ }
431+
432+ if (isset ($ bunnyHeaders ['cluster-id ' ])) {
433+ $ bunnyHeaders ['cluster_id ' ] = $ bunnyHeaders ['cluster-id ' ];
434+ unset($ bunnyHeaders ['cluster-id ' ]);
435+ }
436+
437+ return $ bunnyHeaders ;
438+ }
336439}
0 commit comments