I'm trying to send a simple message to a RabbitMQ (Version: 3.7.7) with AMQP 1.0 using the QPID JMS client. I'm using the following versions:
<dependency>
<groupId>org.apache.qpid</groupId>
<artifactId>qpid-jms-client</artifactId>
<version>0.40.0</version>
</dependency>
<dependency>
<groupId>javax.jms</groupId>
<artifactId>javax.jms-api</artifactId>
<version>2.0</version>
</dependency>
I enabled the rabbitmq_amqp1_0
plugin on the RabbitMQ and created a queue with the name "queue" on the broker with the help of the management UI. I then created a unit test with the following content:
public class JMSIssueTest {
private static final String AMQP_URI = "amqp://localhost:5672";
private static final String QUEUE_NAME = "queue";
@Test
public void testSend() throws Exception {
JmsConnectionFactory factory = new JmsConnectionFactory(AMQP_URI);
try(Connection connection = factory.createConnection()){
connection.setExceptionListener(new MyExceptionListener());
connection.start();
Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
Queue queue = session.createQueue(QUEUE_NAME);
MessageProducer producer = session.createProducer(queue); // the code stops here
TextMessage message = session.createTextMessage("test");
producer.send(message);
System.out.println("send");
}
}
private static class MyExceptionListener implements ExceptionListener {
@Override
public void onException(JMSException exception) {
System.out.println("Connection ExceptionListener fired, exiting.");
exception.printStackTrace(System.out);
System.exit(1);
}
}
}
If run this test I don't receive an error but in the console, I can see the following output:
DEBUG org.apache.qpid.jms.provider.amqp.builders.AmqpProducerBuilder - Creating AmqpFixedProducer for: queue
On the RabbitMQ I can see the connection with the protocol type AMQP 1.0
.
Am I creating the producer wrongly?