我必須使用activeMQ設計JMS應用程序。我有2個客戶應該兼任發佈者和訂閱者。例如。如果第一個客戶端繪製水平,第二個客戶端應該能夠在他的GUI上看到它,反之亦然。JMS(主題) - 我如何以生產者和消費者的身份實現客戶端
我很清楚如何「綁定」到服務器以及如何運行activeMQ,我只是不知道如何設計客戶端,在哪裏運行SWING以及如何發送圖形。例如。生產者是這樣的......
public class Producer {
private static String url = ActiveMQConnection.DEFAULT_BROKER_URL;
private static String subject = "DRAWINGS";
public static void main(String[] args) throws JMSException {
ConnectionFactory connectionFactory =
new ActiveMQConnectionFactory(url);
Connection connection = connectionFactory.createConnection();
connection.start();
Session session = connection.createSession(false,
Session.AUTO_ACKNOWLEDGE);
Destination destination = session.createTopic(subject);
MessageProducer producer = session.createProducer(destination);
// how to implement producer as consumer as well and where to create the SWING
// and bind it to the client?
connection.close();
}
}
我真的需要你的幫助... –