Search code examples
rabbitmqspring-rabbit

RabbitMQ tutorials code not working


I am in the process of learning RabbitMQ. I started with the basic rabbitmq tutorials in their website, unfortunately I am not able to compile them due to the following errors:

ConnectionFactory factory = new ConnectionFactory();
factory.setHost("localhost");

Error: "The method newConnection(Address[]) in the type ConnectionFactory is not applicable for the arguments ()"

Connection connection = factory.newConnection();

Error: The method newConnection(Address[]) in the type ConnectionFactory is not applicable for the arguments ()

The maven dependency I have is:

<dependency>
<groupId>com.rabbitmq</groupId>
<artifactId>rabbitmq-client</artifactId>
<version>0.9.1</version>
</dependency>

What exactly am I doing wrong here? Any help would be appreciated!

Thanks!


Solution

  • Your tutorial seems to be "old", try out a more up to date version. The current release of the RabbitMQ Java AMQP library is 3.1.3.. But also have a look at the Maven Repository. Try out version 3.1.1, it's the newest version in the mvn repo.

    <dependency> 
        <groupId>com.rabbitmq</groupId>
        <artifactId>amqp-client</artifactId> 
        <version>3.1.1</version>
    </dependency>