RabbitMQ "Hello World" example gives "Connection Refused"

exception, java, rabbitmq

Solution

To deal with it I installed RabbitMQ server. If rabbitmq-server is not installed this error will be thrown. Make sure you have installed RabbitMQ server and it's up and running by hitting http://localhost:15672/

Problem

II'm trying to make the "hello world" application from here: RabbitMQ Hello World Here is the code of my producer class: ``` package com.mdnaRabbit.producer; import com.rabbitmq.client.ConnectionFactory; import com.rabbitmq.client.Connection; import com.rabbitmq.client.Channel; import java.io.IOException; public class App { private final static String QUEUE_NAME = "hello"; public static void main( String[] argv) throws IOException{ ConnectionFactory factory = new ConnectionFactory(); factory.setHost("localhost"); Connection connection = factory.newConnection(); Channel channel = connection.createChannel(); channel.queueDeclare(QUEUE_NAME, false, false, false, null); String message = "Hello World!"; channel.basicPublish("", QUEUE_NAME, null, message.getBytes()); System.out.println(" [x] Sent" + "'"); channel.close(); connection.close(); } } ``` And here what I get when implement this: ``` Exception in thread "main" java.net.ConnectException: Connection refused at java.net.PlainSocketImpl.socketConnect(Native Method) at java.net.AbstractPlainSocketImpl.doConnect(AbstractPlainSocketImpl.java:339) at java.net.AbstractPlainSocketImpl.connectToAddress(AbstractPlainSocketImpl.java:200) at java.net.AbstractPlainSocketImpl.connect(AbstractPlainSocketImpl.java:182) at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:391) at java.net.Socket.connect(Socket.java:579) at com.rabbitmq.client.ConnectionFactory.createFrameHandler(ConnectionFactory.java:445) at com.rabbitmq.client.ConnectionFactory.newConnection(ConnectionFactory.java:504) at com.rabbitmq.client.ConnectionFactory.newConnection(ConnectionFactory.java:533) at com.mdnaRabbit.producer.App.main(App.java:16) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:601) at com.intellij.rt.execution.application.AppMain.main(AppMain.java:120) Process finished with exit code 1 ``` What is causing this? I found the solution to my problem here Error in making a socket connection

Original source