Source:
<code>public void testMessageIDNotNullCorrelationIDPreserved() throws Throwable { Connection senderConn = senderCF.createConnection(); Connection consumerConn = consumerCF.createConnection(); consumerConn.setClientID("consumer"); try (Session senderSession = senderConn.createSession(false, Session.AUTO_ACKNOWLEDGE)) { Queue senderDestination = senderSession.createQueue(queueName.toString()); MessageProducer senderProducer = senderSession.createProducer(senderDestination); Message sentMessage = senderSession.createMessage(); <START> sentMessage.setJMSCorrelationID("ID:MessageIDCorrelationId"); <END> senderProducer.send(sentMessage); senderConn.start(); String sentMid = sentMessage.getJMSMessageID(); try (Session consumerSess = consumerConn.createSession(false, Session.AUTO_ACKNOWLEDGE)) { Destination consumerDestination = consumerSess.createQueue(queueName.toString()); MessageConsumer consumer = consumerSess.createConsumer(consumerDestination); consumerConn.start(); Message receivedMessage = consumer.receive(3000); Assert.assertNotNull(receivedMessage); Assert.assertEquals(sentMessage.getJMSCorrelationID(), receivedMessage.getJMSCorrelationID()); String messageId = receivedMessage.getJMSMessageID(); Assert.assertNotNull(messageId); Assert.assertTrue(messageId.startsWith("ID:")); if (protocolConsumer.equals(protocolSender)) { assertEquals(sentMid, messageId); } } } catch (Throwable e) { e.printStackTrace(); throw e; } finally { try { senderConn.close(); } catch (Throwable e) { e.printStackTrace(); } try { consumerConn.close(); } catch (Throwable e) { e.printStackTrace(); } } }</code><technical_language>need set correlation id here, is asserted it, checking is preserved a test (and I realize I introduced this version of test)</technical_language>

Target:
public void testMessageIDNotNullCorrelationIDPreserved() throws Throwable { Connection senderConn = senderCF.createConnection(); Connection consumerConn = consumerCF.createConnection(); consumerConn.setClientID("consumer"); try (Session senderSession = senderConn.createSession(false, Session.AUTO_ACKNOWLEDGE)) { Queue senderDestination = senderSession.createQueue(queueName.toString()); MessageProducer senderProducer = senderSession.createProducer(senderDestination); Message sentMessage = senderSession.createMessage(); sentMessage.setJMSCorrelationID("ID:MessageIDCorrelationId"); senderProducer.send(sentMessage); senderConn.start(); String sentMid = sentMessage.getJMSMessageID(); try (Session consumerSess = consumerConn.createSession(false, Session.AUTO_ACKNOWLEDGE)) { Destination consumerDestination = consumerSess.createQueue(queueName.toString()); MessageConsumer consumer = consumerSess.createConsumer(consumerDestination); consumerConn.start(); Message receivedMessage = consumer.receive(3000); Assert.assertNotNull(receivedMessage); Assert.assertEquals(sentMessage.getJMSCorrelationID(), receivedMessage.getJMSCorrelationID()); String messageId = receivedMessage.getJMSMessageID(); Assert.assertNotNull(messageId); Assert.assertTrue(messageId.startsWith("ID:")); System.out.println("[" + protocolSender + "][" + protocolConsumer + "] " + messageId); System.out.println("[" + protocolSender + "][" + protocolConsumer + "] " + sentMid); if (protocolConsumer.equals(protocolSender)) { assertEquals(sentMid, messageId); } if ("CORE".equals(protocolSender) && "AMQP".equals(protocolConsumer)) { assertEquals(sentMid, messageId); } } } catch (Throwable e) { e.printStackTrace(); throw e; } finally { try { senderConn.close(); } catch (Throwable e) { e.printStackTrace(); } try { consumerConn.close(); } catch (Throwable e) { e.printStackTrace(); } } }