• ActiveMQ(5.10.0)


    1. Place the jndi.properties file on the classpath.

    java.naming.factory.initial = org.apache.activemq.jndi.ActiveMQInitialContextFactory
     
    # use the following property to configure the default connector
    java.naming.provider.url = vm://localhost
     
    # use the following property to specify the JNDI name the connection factory
    # should appear as. 
    connectionFactoryNames = connectionFactory, queueConnectionFactory, topicConnectionFactry
     
    # register some queues in JNDI using the form
    # queue.[jndiName] = [physicalName]
    queue.MyQueue = example.MyQueue
     
     
    # register some topics in JNDI using the form
    # topic.[jndiName] = [physicalName]
    topic.MyTopic = example.MyTopic

    2. Sample code

    // create a new intial context, which loads from jndi.properties file
    javax.naming.Context ctx = new javax.naming.InitialContext();
    // lookup the connection factory
    javax.jms.ConnectionFactory factory = (javax.jms.ConnectionFactory) ctx.lookup("connectionFactory");
    // create a new Connection for messaging
    javax.jms.Connection conn = factory.createConnection();
    // lookup an existing queue
    javax.jms.Destination destination = (javax.jms.Destination) ctx.lookup("MyQueue");
    // create a new Session for the client
    javax.jms.Session session = conn.createSession(false, Session.AUTO_ACKNOWLEDGE);
    // create a new consumer to receive messages
    javax.jms.MessageConsumer consumer = session.createConsumer(destination);
  • 相关阅读:
    MethodDispatcher—Cherrypy对REST的支持
    httpclient上传文件
    java导出xlsx文件
    Date和String转换
    进入指定url就可下载xlsx文件
    js前端解决浏览器下载兼容性问题
    linux安装chrome浏览器
    ubuntu14.04配置java jdk
    卷积神经网络
    KMP算法
  • 原文地址:https://www.cnblogs.com/huey/p/4748767.html
Copyright © 2020-2023  润新知