<div dir="ltr"><div><div><div>when I run this code :<br>package rabbitmqproject;<br>import com.rabbitmq.client.Connection;<br>import com.rabbitmq.client.Channel;<br>import com.rabbitmq.client.*;<br><br><br>public class Main {<br>
<br> private final static String QUEUE_NAME = "hello";<br><br> public static void main(String[] argv) throws java.io.IOException {<br> ConnectionFactory factory = new ConnectionFactory();<br> factory.setHost("localhost");<br>
Connection connection = factory.newConnection();<br> Channel channel = connection.createChannel();<br><br> channel.queueDeclare(QUEUE_NAME, false, false, false, null);<br> String message = "Hello World!";<br>
channel.basicPublish("", QUEUE_NAME, null, message.getBytes());<br><br> System.out.println(" [x] Sent '" + message + "'");<br> channel.close();<br> connection.close();<br>
<br>}<br>}<br><br></div>i got some exception in " Connection connection = factory.newConnection();" line <br></div> my out put is: Exception in thread "main" java.io.IOException<br> at com.rabbitmq.client.impl.AMQChannel.wrap(AMQChannel.java:107)<br>
at com.rabbitmq.client.impl.AMQConnection.start(AMQConnection.java:265)<br> at com.rabbitmq.client.ConnectionFactory.newConnection(ConnectionFactory.java:403)<br> at com.rabbitmq.client.ConnectionFactory.newConnection(ConnectionFactory.java:423)<br>
at rabbitmqproject.Main.main(Main.java:22)<br><br><br></div>please help me what is the reason<br></div>