• 大小: 3.15MB
    文件类型: .rar
    金币: 1
    下载: 0 次
    发布日期: 2023-09-21
  • 语言: 其他
  • 标签: ActiveMQ  

资源简介

中间件技术 实验三 消息中间件应用开发: - CSDN博客 https://blog.csdn.net/lly1122334/article/details/80139790

资源截图

代码片段和文件信息

package example1;

import javax.jms.Connection;  
import javax.jms.ConnectionFactory;  
import javax.jms.Destination;  
import javax.jms.JMSException;  
import javax.jms.MessageConsumer;  
import javax.jms.Session;  
  
import org.apache.activemq.ActiveMQConnectionFactory;  
  
public class Consumer {  
  
    private static String brokerURL = “tcp://localhost:61616“;  
    private static transient ConnectionFactory factory;  
    private transient Connection connection;  
    private transient Session session;  
      
    public Consumer() throws JMSException {  
        factory = new ActiveMQConnectionFactory(brokerURL);  
        connection = factory.createConnection();  
        connection.start();  
        session = connection.createSession(false Session.AUTO_ACKNOWLEDGE);  
    }  
      
    public void close() throws JMSException {  
        if (connection != null) {  
            connection.close();  
        }  
    }      
      
    public static void main(String[] args) throws JMSException {  
        Consumer consumer = new Consumer();  
        String[] stocks = {“ORCL“};
        for (String stock : stocks) {  
            Destination destination = consumer.getSession().createTopic(“STOCKS.“ + stock);  
            MessageConsumer messageConsumer = consumer.getSession().createConsumer(destination);  
            messageConsumer.setMessageListener(new Listener());  
        }  
    }  
      
    public Session getSession() {  
        return session;  
    }  
  
}  

 属性            大小     日期    时间   名称
----------- ---------  ---------- -----  ----

     文件        366  2016-04-13 09:19  MessageMiddleWare\.classpath

     文件        393  2016-04-13 07:59  MessageMiddleWare\.project

     文件        598  2016-04-13 09:04  MessageMiddleWare\.settings\org.eclipse.jdt.core.prefs

     文件       2154  2016-04-13 09:29  MessageMiddleWare\bin\example1\Consumer.class

     文件       1689  2016-04-13 09:19  MessageMiddleWare\bin\example1\Listener.class

     文件       4584  2016-04-13 09:29  MessageMiddleWare\bin\example1\Publisher.class

     文件       2475  2016-04-13 09:19  MessageMiddleWare\bin\example2\Receiver.class

     文件       2835  2016-04-13 09:19  MessageMiddleWare\bin\example2\Sender.class

     文件       2899  2016-04-13 09:19  MessageMiddleWare\bin\example3\MessageReceiver.class

     文件       3177  2016-04-13 09:19  MessageMiddleWare\bin\example3\MessageSender.class

     文件        900  2016-04-13 09:19  MessageMiddleWare\bin\example3\MyActiveMQDemo.class

     文件    3834031  2011-10-12 10:02  MessageMiddleWare\lib\activemq-all-5.4.3.jar

     文件       1556  2016-04-13 09:29  MessageMiddleWare\src\example1\Consumer.java

     文件        845  2016-04-13 08:48  MessageMiddleWare\src\example1\Listener.java

     文件       4002  2016-04-13 09:29  MessageMiddleWare\src\example1\Publisher.java

     文件       2205  2016-04-13 09:08  MessageMiddleWare\src\example2\Receiver.java

     文件       2756  2016-04-13 09:08  MessageMiddleWare\src\example2\Sender.java

     文件       2322  2016-04-13 09:11  MessageMiddleWare\src\example3\MessageReceiver.java

     文件       2593  2016-04-13 09:10  MessageMiddleWare\src\example3\MessageSender.java

     文件        452  2016-04-13 09:11  MessageMiddleWare\src\example3\MyActiveMQDemo.java

     目录          0  2016-04-13 09:19  MessageMiddleWare\bin\example1

     目录          0  2016-04-13 09:19  MessageMiddleWare\bin\example2

     目录          0  2016-04-13 09:19  MessageMiddleWare\bin\example3

     目录          0  2016-04-13 08:48  MessageMiddleWare\src\example1

     目录          0  2016-04-13 09:08  MessageMiddleWare\src\example2

     目录          0  2016-04-13 09:11  MessageMiddleWare\src\example3

     目录          0  2016-04-13 07:59  MessageMiddleWare\.settings

     目录          0  2016-04-13 09:19  MessageMiddleWare\bin

     目录          0  2016-04-13 09:19  MessageMiddleWare\lib

     目录          0  2016-04-13 09:12  MessageMiddleWare\src

............此处省略4个文件信息

评论

共有 条评论