RabbitMQ "Hello World" - Beispiel gibt "Connection Refused"

II versuche zu machen, die "hello world" - Anwendung von hier: RabbitMQ Hallo Welt

Hier ist der code von meinem Produzenten Klasse:

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();
    }
}

Und hier, was ich bekomme, wenn diese umzusetzen:

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

Was ist die Ursache?

Fand ich die Lösung zu meinem problem hier Fehler bei der Herstellung einer socket-Verbindung

Für Referenz, Google sagt В соединении отказано übersetzt Connection Refused.
Nimmt diese Frage Hilfe mit Ihrem problem? stackoverflow.com/questions/8939074/...
Tut mir Leid, dass das nicht übersetzen. Ich habe nicht bemerkt. gut, thegrinner, dass die post descrybes die Art und Weise der Lösung meines Problems, aber ich habe es gelöst etwas früher, als zu sehen, dass Beitrag. vielen Dank jedenfalls.

InformationsquelleAutor Nikitin Mikhail | 2013-03-15

Schreibe einen Kommentar