我必须使用activeMQ 设计一个JMS 应用程序。我有 2 个客户,他们应该同时作为发布者和订阅者。例如,如果第一个客户端绘制 smth.,第二个客户端应该能够在他的 GUI 上看到它,反之亦然。
我很清楚如何“绑定”到服务器以及如何运行 activeMQ,我只是不知道如何设计客户端、在哪里运行 SWING 以及如何发送绘图。EG 一个制片人应该是这样的……
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();
}
}