Search code examples
rabbitmqspring-amqp

spring amqp message CorrelationIdString is null


code like below i send a message and set it messageid and CorrelationIdString

rabbitTemplate.send(RabbitMQConfig.EXCHANGE_NAME, "aaa.orange.bbb",new Message(messageBody, MessagePropertiesBuilder.newInstance().setCorrelationIdString(uuid3).
                        setMessageId(uuid3).setContentType("text/x-json").build()),
                new CorrelationData(uuid3)

                );

and the receiver code

public void processMessage (Message msg) throws Exception {
//        Thread.sleep(100000);
        System.out.println("Receiver1 got message" + msg);

and the log

Receiver1 got message(Body:'hello,world1 2' MessageProperties [headers={spring_listener_return_correlation=93fbcc71-b0eb-4d33-a187-d4b27122a663}, timestamp=null, messageId=5f779051-12c5-43f1-a589-6d14430d3a52, userId=null, receivedUserId=null, appId=null, clusterId=null, type=null, correlationId=null, correlationIdString=null, replyTo=null, contentType=text/x-json, contentEncoding=null, contentLength=0, deliveryMode=null, receivedDeliveryMode=PERSISTENT, expiration=null, priority=0, redelivered=false, receivedExchange=first_exchange, receivedRoutingKey=aaa.orange.bbb, receivedDelay=null, deliveryTag=1, messageCount=0, consumerTag=amq.ctag-JbtjvUYYqlWOIsgKkOe-8A, consumerQueue=queue_a])

my question is why CorrelationIdString is null is that a problem or not


Solution

  • We migrated away from a byte[] for correlationId to String in 1.6 and 1.7 but we had to stick with byte[] by default for backwards compatibility; the migration is complete in 2.0 (currently 2.0.2) and correlationIdString is not longer a property.

    I suggest moving to 2.0.

    Alternatively, if you must use an older version, see CorrelationIdPolicy here to switch from byte[] to String or BOTH.