RabbitMQ - Resolve "bad_header"

by
Jeremy Canfield |
Updated: November 18 2021
| RabbitMQ articles
Let's say the main RabbitMQ log file contains something like this. In this example, IP address 10.12.221.15:59123 is the channel and 10.16.11.105:5672 is the RabbitMQ server HTTP listener. This means that the producer coming into RabbitMQ from IP address 10.12.221.15 attempted to publish a message with a bad header.
=ERROR REPORT==== 9-Dec-2020::09:37:19 ===
closing AMQP connection <0.1885.29> (10.12.211.15:59123 -> 10.16.11.105:5672):
{bad_header,<<22,3,1,2,0,1,0,1>>}
For example, let's say the producer is a Java application using channel.basicPublish to published a message with a header to an exchange. In this example, the Java code could look something like this. The point here is that this is not an issue with RabbitMQ, but instead suggests an issue with how the producer application is defining the headers.
headers.put("foo", "Hello");
headers.put("bar", "World");
channel.basicPublish(exchange, routingkey,
new AMQP.BasicProperties.Builder()
.contentType("text/plain")
.deliveryMode(2)
.userId("john.doe")
.headers(headers)
.build(),
message.getBytes());
Did you find this article helpful?
If so, consider buying me a coffee over at
Comments
February 09 2021 by Nik
Hi there