0
我試圖用默認設置從amqp客戶端連接到aqtivemq服務器。它總是給出錯誤消息,說連接被拒絕。然後,我用rabbitmq服務器而不是activemq服務器嘗試了它,它工作正常。我想知道activemq是否需要一個linux庫來進行通信。使用Amqp客戶端未連接到activemq服務器。
ActiveMQ的服務器版本不連接:5.4.2/5.10.0使用 Rabitmq版本:3.3.5
rabitmq樣本客戶機代碼
import com.rabbitmq.client.ConnectionFactory;
import com.rabbitmq.client.Connection;
import com.rabbitmq.client.Channel;
public class Cache {
private final static String QUEUE_NAME = "hello";
public static void main(String[] argv)
throws java.io.IOException {
//creating the connection factory
ConnectionFactory factory = new ConnectionFactory();
factory.setHost("localhost");
//Creating a connection to the server
Connection connection = factory.newConnection();
Channel channel = connection.createChannel();
//declaring a queuw
channel.queueDeclare(QUEUE_NAME, false, false, false, null);
String message = "Hello World!";
//publishing the queue the queue
channel.basicPublish("", QUEUE_NAME, null, message.getBytes());
System.out.println(" [x] Sent '" + message + "'");
//closing the connection
channel.close();
connection.close();
}
}
在下面的代碼行失敗
//Creating a connection to the server
Connection connection = factory.newConnection();
我該如何解決這個問題?駱駝春天的URI(從和):
任何錯誤的日誌? – 2014-10-17 09:20:20