zoukankan      html  css  js  c++  java
  • 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);
  • 相关阅读:
    如何搭建SVN的客户端和使用
    SVN服务器的本地搭建和使用
    grep命令
    cat命令
    cut命令
    yum 命令
    XPath、XQuery 以及 XSLT 函数
    XPath 实例
    XPath 运算符
    XPath Axes(轴)
  • 原文地址:https://www.cnblogs.com/huey/p/4748767.html
Copyright © 2011-2022 走看看