首页 ActiveMQ in Action

ActiveMQ in Action

举报
开通vip

ActiveMQ in Action 1 JMS 在介绍 ActiveMQ 之前,首先简要介绍一下 JMS 规范。 1.1 JMS 的基本构件 1.1.1 连接工厂 连接工厂是客户用来创建连接的对象,例如 ActiveMQ 提供的 ActiveMQConnectionFactory。 1.1.2 连接 JMS Connection 封装了客户与 JMS 提供者之间的一个虚拟的连接。 1.1.3 会话 JMS Session 是生产和消费消息的一个单线程上下文。会话用于创建消息生 产者(pro...

ActiveMQ in Action
1 JMS 在介绍 ActiveMQ 之前,首先简要介绍一下 JMS 规范 编程规范下载gsp规范下载钢格栅规范下载警徽规范下载建设厅规范下载 。 1.1 JMS 的基本构件 1.1.1 连接工厂 连接工厂是客户用来创建连接的对象,例如 ActiveMQ 提供的 ActiveMQConnectionFactory。 1.1.2 连接 JMS Connection 封装了客户与 JMS 提供者之间的一个虚拟的连接。 1.1.3 会话 JMS Session 是生产和消费消息的一个单线程上下文。会话用于创建消息生 产者(producer)、消息消费者(consumer)和消息(message)等。会话提供 了一个事务性的上下文,在这个上下文中,一组发送和接收被组合到了一个原子 操作中。 1.1.4 目的地 目的地是客户用来指定它生产的消息的目标和它消费的消息的来源的对象。 JMS1.0.2 规范中定义了两种消息传递域:点对点(PTP)消息传递域和发布/订阅 消息传递域。 点对点消息传递域的特点如下: • 每个消息只能有一个消费者。 • 消息的生产者和消费者之间没有时间上的相关性。无论消费者在生产者发 送消息的时候是否处于运行状态,它都可以提取消息。 发布/订阅消息传递域的特点如下: • 每个消息可以有多个消费者。 • 生产者和消费者之间有时间上的相关性。订阅一个主题的消费者只能消费 自它订阅之后发布的消息。JMS 规范允许客户创建持久订阅,这在一定程 度上放松了时间上的相关性要求。持久订阅允许消费者消费它在未处于激 活状态时发送的消息。 在点对点消息传递域中,目的地被成为队列(queue);在发布/订阅消息传递 域中,目的地被成为主题(topic)。 1.1.5 消息生产者 消息生产者是由会话创建的一个对象,用于把消息发送到一个目的地。 1.1.6 消息消费者 消息消费者是由会话创建的一个对象,它用于接收发送到目的地的消息。消 息的消费可以采用以下两种 方法 快递客服问题件处理详细方法山木方法pdf计算方法pdf华与华方法下载八字理论方法下载 之一: • 同步消费。通过调用消费者的 receive 方法从目的地中显式提取消息。 receive 方法可以一直阻塞到消息到达。 • 异步消费。客户可以为消费者注册一个消息监听器,以定义在消息到达时 所采取的动作。 1.1.7 消息 JMS 消息由以下三部分组成: • 消息头。每个消息头字段都有相应的 getter 和 setter 方法。 • 消息属性。如果需要除消息头字段以外的值,那么可以使用消息属性。 • 消息体。JMS 定义的消息类型有 TextMessage、MapMessage、BytesMessage、 StreamMessage 和 ObjectMessage。 1.2 JMS 的可靠性机制 1.2.1 确认 JMS 消息只有在被确认之后,才认为已经被成功地消费了。消息的成功消费 通常包含三个阶段:客户接收消息、客户处理消息和消息被确认。 在事务性会话中,当一个事务被提交的时候,确认自动发生。在非事务性会 话中,消息何时被确认取决于创建会话时的应答模式(acknowledgement mode)。 该参数有以下三个可选值: • Session.AUTO_ACKNOWLEDGE。当客户成功的从 receive 方法返回的时候, 或者从 MessageListener.onMessage 方法成功返回的时候,会话自动确认 客户收到的消息。 • Session.CLIENT_ACKNOWLEDGE。客户通过消息的 acknowledge 方法确认消 息。需要注意的是,在这种模式中,确认是在会话层上进行:确认一个被 消费的消息将自动确认所有已被会话消费的消息。例如,如果一个消息消 费者消费了 10 个消息,然后确认第 5个消息,那么所有 10 个消息都被确 认。 • Session.DUPS_ACKNOWLEDGE。该选择只是会话迟钝第确认消息的提交。如 果 JMS provider 失败,那么可能会导致一些重复的消息。如果是重复的 消息,那么 JMS provider 必须把消息头的 JMSRedelivered 字段设置为 true。 1.2.2 持久性 JMS 支持以下两种消息提交模式: • PERSISTENT。指示 JMS provider 持久保存消息,以保证消息不会因为 JMS provider 的失败而丢失。 • NON_PERSISTENT。不要求 JMS provider 持久保存消息。 1.2.3 优先级 可以使用消息优先级来指示 JMS provider 首先提交紧急的消息。优先级分 10 个级别,从 0(最低)到 9(最高)。如果不指定优先级,默认级别是 4。需 要注意的是,JMS provider 并不一定保证按照优先级的顺序提交消息。 1.2.4 消息过期 可以设置消息在一定时间后过期,默认是永不过期。 1.2.5 临时目的地 可以通过会话上的 createTemporaryQueue 方法和 createTemporaryTopic 方法来创建临时目的地。它们的存在时间只限于创建它们的连接所保持的时间。 只有创建该临时目的地的连接上的消息消费者才能够从临时目的地中提取消息。 1.2.6 持久订阅 首先消息生产者必须使用 PERSISTENT 提交消息。客户可以通过会话上的 createDurableSubscriber 方法来创建一个持久订阅,该方法的第一个参数必须 是一个 topic。第二个参数是订阅的名称。 JMS provider 会存储发布到持久订阅对应的 topic 上的消息。如果最初创 建持久订阅的客户或者任何其它客户使用相同的连接工厂和连接的客户 ID、相 同的主题和相同的订阅名再次调用会话上的 createDurableSubscriber 方法,那 么该持久订阅就会被激活。JMS provider 会象客户发送客户处于非激活状态时 所发布的消息。 持久订阅在某个时刻只能有一个激活的订阅者。持久订阅在创建之后会一直 保留,直到应用程序调用会话上的 unsubscribe 方法。 1.2.7 本地事务 在一个 JMS 客户端,可以使用本地事务来组合消息的发送和接收。JMS Session 接口提供了 commit 和 rollback 方法。事务提交意味着生产的所有消息 被发送,消费的所有消息被确认;事务回滚意味着生产的所有消息被销毁,消费 的所有消息被恢复并重新提交,除非它们已经过期。 事务性的会话总是牵涉到事务处理中,commit或 rollback方法一旦被调用, 一个事务就结束了,而另一个事务被开始。关闭事务性会话将回滚其中的事务。 需要注意的是,如果使用请求/回复机制,即发送一个消息,同时希望在同一个 事务中等待接收该消息的回复,那么程序将被挂起,因为知道事务提交,发送操 作才会真正执行。 需要注意的还有一个,消息的生产和消费不能包含在同一个事务中。 1.3 JMS 规范的变迁 JMS 的最新版本的是 1.1。它和同 1.0.2 版本之间最大的差别是,JMS1.1 通 过统一的消息传递域简化了消息传递。这不仅简化了 JMS API,也有利于开发人 员灵活选择消息传递域,同时也有助于程序的重用和维护。 以下是不同消息传递域的相应接口: JMS 公共 点对点域 发布/订阅域 ConnectionFactory QueueConnectionFactory TopicConnectionFactory Connection QueueConnection TopicConnection Destination Queue Topic Session QueueSession TopicSession MessageProducer QueueSender TopicPublisher MessageConsumer QueueReceiver TopicSubscriber 2 ActiveMQ 2.1 Broker 2.1.1 Running Broker ActiveMQ5.0 的二进制发布包中bin目录中包含一个名为activemq的脚本, 直接运行这个脚本就可以启动一个 broker。 此外也可以通过 Broker Configuration URI 或 Broker XBean URI 对 broker 进行配置,以下是一些命令行参数的例子: Example Description activemq Runs a broker using the default 'xbean:activemq.xml' as the broker configuration file. activemq xbean:myconfig.xml Runs a broker using the file myconfig.xml as the broker configuration file that is located in the classpath. activemq xbean:file:./conf/broker1.xml Runs a broker using the file broker1.xml as the broker configuration file that is located in the relative file path ./conf/broker1.xml activemq xbean:file:C:/ActiveMQ/conf/broker2.xml Runs a broker using the file broker2.xml as the broker configuration file that is located in the absolute file path C:/ActiveMQ/conf/broker2. xml activemq broker:(tcp://localhost:61616, tcp://localhost:5000)?useJmx=true Runs a broker with two transport connectors and JMX enabled. activemq broker:(tcp://localhost:61616, network:tcp://localhost:5000)?persistent=f alse Runs a broker with 1 transport connector and 1 network connector with persistence disabled. 2.1.2 Embedded Broker 可以通过在应用程序中以编码的方式启动 broker,例如: Java 代码 1. BrokerService broker = new BrokerService(); 2. broker.addConnector("tcp://localhost:61616"); 3. broker.start(); 如果需要启动多个 broker,那么需要为 broker 设置一个名字。例如: Java 代码 1. BrokerService broker = new BrokerService(); 2. broker.setName("fred"); 3. broker.addConnector("tcp://localhost:61616"); 4. broker.start(); 如果希望在同一个 JVM 内访问这个 broker,那么可以使用 VM Transport, URI 是:vm://brokerName。关于更多的 broker 属性,可以参考 Apache 的官方 文档。 此外,也可以通过 BrokerFactory 来创建 broker,例如: Java 代码 1. BrokerService broker = BrokerFactory.createBroker(new URI(someU RI)); someURI 的可选值如下: URI scheme Example Description xbean: xbean:activemq.xml Searches the classpath for an XML document with the given URI (activemq.xml in this case) which will then be used as the Xml Configuration file: file:foo/bar/activemq.xml Loads the given file (in this example foo/bar/activemq.xml) as the Xml Configuration broker: broker:tcp://localhost:61616 Uses the Broker Configuration URI to configure the broker 当使用 XBean 的配置方式的时候,需要指定一个 xml 配置文件,例如: Java 代码 1. BrokerService broker = BrokerFactory.createBroker(new URI("xbea n:com/test/activemq.xml")); 使用 Spring 的配置方式如下: Xml 代码 1. 2. 3. 4. 2.1.3 Monitoring Broker 2.1.3.1 JMX 在使用 JMX 监控 broker 之前,首先要启用 broker 的 JMX 监控功能,例如在 配置文件中设置 useJmx="true",如下: Xml 代码 1. 4. 5. ... 6. 接下来运行 JDK 自带的 jconsole。在运行了 jconsole 后,它会弹出对话框 来选择需要连接到的 agent。如果是在启动 broker 的主机上运行 jconsole,那 么 ActiveMQ broker 会出现在 jconsole 的 Local 标签中。如果要连接到远程的 broker,那么可以在 Advanced 标签中指定 JMX URL,以下是一个连接到本机的 JMX URL: service:jmx:rmi:///jndi/rmi://localhost:1099/jmxrmi 在 jconsole 的 MBeans 标签中,可以查看详细信息,也可以执行相应的 operation。需要注意的是,在 jconsole 连接到 broker 的时候,并不需要输入 用户名和密码,如果这存在潜在的安全问题,那么就需要为 JMX Connector 配置 密码保护(需要使用 1.5 以上版本的 JDK)。 首先要禁止 ActiveMQ 创建自己的 connector,例如: Xml 代码 1. 2. 3. 4. 5. 然后在 ActiveMQ 的 conf 目录下创建一个访问控制文件和密码文件,如下: conf/jmx.access: # The "monitorRole" role has readonly access. # The "controlRole" role has readwrite access. monitorRole readonly controlRole readwrite conf/jmx.password: # The "monitorRole" role has password "abc123". # The "controlRole" role has password "abcd1234". monitorRole abc123 controlRole abcd1234 然后修改 ActiveMQ 的 bin 目录下 activemq 的启动脚本,查找包含"SUNJMX=" 的一行如下: REM set SUNJMX=-Dcom.sun.management.jmxremote.port=1616 -Dcom.sun.management.jmxremote.authenticate=false -Dcom.sun.management.jmxremote.ssl=false 把它替换成 set SUNJMX=-Dcom.sun.management.jmxremote.port=1616 -Dcom.sun.management.jmxremote.authenticate=true -Dcom.sun.management.jmxremote.ssl=false -Dcom.sun.management.jmxremote.password.file=%ACTIVEMQ_BASE%/conf/jmx .password -Dcom.sun.management.jmxremote.access.file=%ACTIVEMQ_BASE%/conf/jmx.a ccess 最后重启 ActiveMQ 和 jconsole,这时候需要强制 login。如果在启动 activemq 的过程中出现以下错误,那么需要为这个文件增加访问控制。Windows 平台上的具体解决方法请参考如下网址: http://java.sun.com/j2se/1.5.0/docs/guide/management/security-windows .html Error: Password file read access must be restricted: D:\apache-activemq-5.0.0\bin\../conf/jmx.password 2.1.3.2 Web Console Web Console 被集成到了 ActiveMQ 的二进制发布包中,因此缺省访问 http://localhost:8161/admin 即可访问 Web Console。 在配置文件中,可以通过修改nioConnector的port属性来修改Web console 的缺省端口: Xml 代码 1. 2. 3. 4. 5. ... 6. 出于安全性或者可靠性的考虑,Web Console 可以被部署到不同于 ActiveMQ 的进程中。例如把 activemq-web-console.war 部署到一个单独的 web 容器中 (Tomcat,Jetty 等)。在 ActiveMQ5.0 的二进制发布包中不包含 activemq-web-console.war,因此需要下载 ActiveMQ 的源码,然后进入到 ${activemq.base}/src/activemq-web-console 目录中执行 mvn instanll。如果 一切正常,那么缺省会在${activemq.base}/src/activemq-web-console/target 目录中生成 activemq-web-console-5.0.0.war。然后将 activemq-web-console-5.0.0.war 拷贝到 Tomcat 的 webapps 目录中,并重命名 成 activemq-web-console.war。 需要注意的是,要将activemq-all-5.0.0.jar拷贝到WEB-INF\lib目录中(可 能还需要拷贝 jms.jar)。还要为 Tomcat 设置以下五个系统属性(修改 catalina.bat 文件): set JAVA_OPTS=%JAVA_OPTS% -Dwebconsole.type="properties" set JAVA_OPTS=%JAVA_OPTS% -Dwebconsole.jms.url="tcp://localhost:61616" set JAVA_OPTS=%JAVA_OPTS% -Dwebconsole.jmx.url="service:jmx:rmi:///jndi/rmi://localhost:1099/jm xrmi" set JAVA_OPTS=%JAVA_OPTS% -Dwebconsole.jmx.role="" set JAVA_OPTS=%JAVA_OPTS% -Dwebconsole.jmx.password="" 如果 JMX 没有配置密码保护,那么 webconsole.jmx.role 和 webconsole.jmx.password设置成""即可。如果broker被配置成了Master/Slave 模式,那么可以配置成使用 failover transport,例如: -Dwebconsole.jms.url=failover:(tcp://serverA:61616,tcp://serverB:6161 6) 顺便说一下,由于 webconsole.type 属性是 properties,因此实际上起作用 的 Web Console 的配置文件是 WEB-INF/ webconsole-properties.xml。最后启 动被监控的 ActiveMQ,访问 http://localhost:8080/activemq-web-console/, 查看显示是否正常。 2.1.3.3 Advisory Message ActiveMQ 支持 Advisory Messages,它允许你通过 标准 excel标准偏差excel标准偏差函数exl标准差函数国标检验抽样标准表免费下载红头文件格式标准下载 的 JMS 消息来监控 系统。目前的 Advisory Messages 支持: • consumers, producers and connections starting and stopping • temporary destinations being created and destroyed • messages expiring on topics and queues • brokers sending messages to destinations with no consumers. • connections starting and stopping Advisory Messages可以被想象成某种的管理通道,通过它你可以得到关于JMS provider、producers、consumers 和 destinations 的信息。Advisory topics 都使用 ActiveMQ.Advisory.这个前缀,以下是目前支持的 topics: Client based advisories Advisory Topics Description ActiveMQ.Advisory.Connection Connection start & stop messages ActiveMQ.Advisory.Producer.Queue Producer start & stop messages on a Queue ActiveMQ.Advisory.Producer.Topic Producer start & stop messages on a Topic ActiveMQ.Advisory.Consumer.Queue Consumer start & stop messages on a Queue ActiveMQ.Advisory.Consumer.Topic Consumer start & stop messages on a Topic 在消费者启动/停止的 Advisory Messages 的消息头中有个 consumerCount 属性,他用来指明目前 desination 上活跃的 consumer 的数量。 Destination and Message based advisories Advisory Topics Description ActiveMQ.Advisory.Queue Queue create & destroy ActiveMQ.Advisory.Topic Topic create & destroy ActiveMQ.Advisory.TempQueue Temporary Queue create & destroy ActiveMQ.Advisory.TempTopic Temporary Topic create & destroy ActiveMQ.Advisory.Expired.Queue Expired messages on a Queue ActiveMQ.Advisory.Expired.Topic Expired messages on a Topic ActiveMQ.Advisory.NoConsumer.Queue No consumer is available to process messages being sent on a Queue ActiveMQ.Advisory.NoConsumer.Topic No consumer is available to process messages being sent on a Topic 以上的这些 destnations 都可以用来作为前缀,在其后面追加其它的重要信 息,例如 topic、queue、clientID、producderID 和 consumerID 等。这令你可 以利用 Wildcards 和 Selectors 来过滤 Advisory Messages(关于 Wildcard 和 Selector 会在稍后介绍)。 例如,如果你希望订阅 FOO.BAR 这个 queue 上 Consumer 的 start/stop 的消 息,那么可以订阅 ActiveMQ.Advisory.Consumer.Queue.FOO.BAR;如果希望订 阅所有 queue 上的 start/stop 消息,那么可以订阅 ActiveMQ.Advisory.Consumer.Queue.>;如果希望订阅所有 queue 或者 topic 上的 start/stop 消息,那么可以订阅 ActiveMQ.Advisory.Consumer. >。 org.apache.activemq.advisory.AdvisorySupport 类上有如下的 helper methods,用来在程序中得到 advisory destination objects。 Java 代码 1. AdvisorySupport.getConsumerAdvisoryTopic() 2. AdvisorySupport.getProducerAdvisoryTopic() 3. AdvisorySupport.getDestinationAdvisoryTopic() 4. AdvisorySupport.getExpiredTopicMessageAdvisoryTopic() 5. AdvisorySupport.getExpiredQueueMessageAdvisoryTopic() 6. AdvisorySupport.getNoTopicConsumersAdvisoryTopic() 7. AdvisorySupport.getNoQueueConsumersAdvisoryTopic() 以下是段使用 Advisory Messages 的程序代码: Java 代码 1. Destination advisoryDestination = AdvisorySupport.getProducerAd visoryTopic(destination) 2. MessageConsumer consumer = session.createConsumer(advisoryDesti nation); 3. consumer.setMessageListener(this); 4. ... 5. public void onMessage(Message msg){ 6. if (msg instanceof ActiveMQMessage){ 7. try { 8. ActiveMQMessage aMsg = (ActiveMQMessage)msg; 9. ProducerInfo prod = (ProducerInfo) aMsg.getDataStr ucture(); 10. } catch (JMSException e) { 11. log.error("Failed to process message: " + msg); 12. } 13. } 14.} 2.1.3.4 Command Agent 在介绍 Command Agent 前首先简要介绍一下 XMPP(Jabber) 协议 离婚协议模板下载合伙人协议 下载渠道分销协议免费下载敬业协议下载授课协议下载 ,XMPP 是一 种基于 XML 的即时通信协议,它由 Jabber 软件基金会开发。在配置文件中通过 增加 transportConnector 来支持 XMPP 协议: Xml 代码 1. 2. 3. ... 4. 5. 6. ActiveMQ 提供了 ActiveMQ messages 和 XMPP 之间的双向桥接: • 如果客户加入了一个聊天室,那么这个聊天室的名字会被映射到一个 JMS topic。 • 尝试在聊天室内发送消息会导致一个 JMS 消息被发送到这个 topic。 • 呆在一个聊天室中意味着这将保持一个对相应 JMS topic 的订阅。因此发 送到这个 topic 的 JMS 消息也会被发送到聊天室。 推荐 XMPP 客户端 Spark(http://www.igniterealtime.org/)。 从 4.2 版本起,ActiveMQ 支持 Command Agent。在配置文件中,通过设置 commandAgent 来启用 Command Agent: Xml 代码 1. 2. 3. ... 4. 5. 6. 启用了 Command Agent 的 broker 上会有一个来自 Command Agent 的连接, 它同时订阅 topic: ActiveMQ.Agent。在你启动 XMPP 客户端,加入到 ActiveMQ.Agent 聊天室后,就可以同 broker 进行交谈了。通过在 XMPP 客户端 中键入 help,可以得到帮助信息。 需要注意的是,ActiveMQ5.0 版本有个小 bug,如果 broker 没有采用缺省的 用户名和密码,那么 Command Agent 便无法正常启动。Apache 官方文档说,此 bug 已经被修正,预定在 5.2.0 版本上体现。修改方式如下: Xml 代码 1. 2.1.3.5 Visualization plugin ActiveMQ 支持以 broker 插件的形式生成 DOT 文件(可以用 agrviewer 来查 看),以图表的方式描述 connections、sessions、producers、consumers、 destinations 等信息。配置方式如下: Xml 代码 1. 2. ... 3. 4. 5. 6. 7. 需要注意的是,笔者认为 ActiveMQ5.0 版本的 Visualization Plugin 尚不稳 定,存在诸多问题。例如:如果使用 connectionDotFilePlugin,那么 brokerName 必须是 localhost;如果使用 destinationDotFilePlugin 可能会导致 ArrayStoreException。 2.2 Transport ActiveMQ 目前支持的 transport 有:VM Transport、TCP Transport、SSL Transport、Peer Transport、UDP Transport、Multicast Transport、HTTP and HTTPS Transport、Failover Transport、Fanout Transport、Discovery Transport、ZeroConf Transport 等。以下简单介绍其中的几种,更多请参考 Apache 官方文档。 2.2.1 VM Transport VM transport 允许在 VM 内部通信,从而避免了网络传输的开销。这时候采 用的连接不是 socket 连接,而是直接地方法调用。 第一个创建 VM 连接的客户 会启动一个 embed VM broker,接下来所有使用相同的 broker name 的 VM 连接 都会使用这个 broker。当这个 broker 上所有的连接都关闭的时候,这个 broker 也会自动关闭。 以下是配置语法: vm://brokerName?transportOptions 例如:vm://broker1?marshal=false&broker.persistent=false Transport Options 的可选值如下: Option Name Default Value Description Marshal false If true, forces each command sent over the transport to be marshlled and unmarshlled using a WireFormat wireFormat default The name of the WireFormat to use wireFormat.* All the properties with this prefix are used to configure the wireFormat create true If the broker should be created on demand if it does not allready exist. Only supported in ActiveMQ 4.1 broker.* All the properties with this prefix are used to configure the broker. See Configuring Wire Formats for more information 以下是高级配置语法: vm:(broker:(tcp://localhost)?brokerOptions)?transportOptions vm:broker:(tcp://localhost)?brokerOptions 例如: vm:(broker:(tcp://localhost:6000)?persistent=false)?marshal=false Transport Options 的可选值如下: Option Name Default Value Description marshal false If true, forces each command sent over the transport to be marshlled and unmarshlled using a WireFormat wireFormat default The name of the WireFormat to use wireFormat.* All the properties with this prefix are used to configure the wireFormat 使用配置文件的配置语法: vm://localhost?brokerConfig=xbean:activemq.xml 例如:vm:// localhost?brokerConfig=xbean:com/test/activemq.xml 使用 Spring 的配置: Xml 代码 1. 2. 3. 4. 5. 6. 7. 8. 如果 persistent 是 true,那么 ActiveMQ 会在当前目录下创建一个缺省值是 activemq-data 的目录用于持久化保存数据。需要注意的是,如果程序中启动了 多个不同名字的 VM broker,那么可能会有如下警告:Failed to start jmx connector: Cannot bind to URL [rmi://localhost:1099/jmxrmi]: javax.naming.NameAlreadyBoundException…可以通过在 transportOptions 中 追加 broker.useJmx=false 来禁用 JMX 来避免这个警告。 2.2.2 TCP Transport TCP transport 允许客户端通过 TCP socket 连接到远程的 broker。以下是 配置语法: tcp://hostname:port?transportOptions Transport Options 的可选值如下: Option Name Default Value Description minmumWireFormatVersion 0 The minimum version wireformat that is allowed trace false Causes all commands that are sent over the transport to be logged useLocalHost true When true, it causes the local machines name to resolve to "localhost". socketBufferSize 64 * 1024 Sets the socket buffer size in bytes soTimeout 0 sets the socket timeout in milliseconds connectionTimeout 30000 A non-zero value specifies the connection timeout in milliseconds. A zero value means wait forever for the connection to be established. Negative values are ignored. wireFormat default The name of the WireFormat to use wireFormat.* All the properties with this prefix are used to configure the wireFormat. See Configuring Wire Formats for more information 例如:tcp://localhost:61616?trace=false 2.2.3 Failover Transport Failover Transport 是一种重新连接的机制,它工作于其它 transport 的 上层,用于建立可靠的传输。它的配置语法允许制定任意多个复合的 URI。 Failover transport 会自动选择其中的一个 URI 来尝试建立连接。如果没有成 功,那么会选择一个其它的 URI 来建立一个新的连接。以下是配置语法: failover:(uri1,...,uriN)?transportOptions failover:uri1,...,uriN Transport Options 的可选值如下: Option Name Default Value Description initialReconnectDelay 10 How long to wait before the first reconnect attempt (in ms) maxReconnectDelay 30000 The maximum amount of time we ever wait between reconnect attempts (in ms) useExponentialBackOff true Should an exponential backoff be used between reconnect attempts backOffMultiplier 2 The exponent used in the exponential backoff attempts maxReconnectAttempts 0
本文档为【ActiveMQ in Action】,请使用软件OFFICE或WPS软件打开。作品中的文字与图均可以修改和编辑, 图片更改请在作品中右键图片并更换,文字修改请直接点击文字进行修改,也可以新增和删除文档中的内容。
该文档来自用户分享,如有侵权行为请发邮件ishare@vip.sina.com联系网站客服,我们会及时删除。
[版权声明] 本站所有资料为用户分享产生,若发现您的权利被侵害,请联系客服邮件isharekefu@iask.cn,我们尽快处理。
本作品所展示的图片、画像、字体、音乐的版权可能需版权方额外授权,请谨慎使用。
网站提供的党政主题相关内容(国旗、国徽、党徽..)目的在于配合国家政策宣传,仅限个人学习分享使用,禁止用于任何广告和商用目的。
下载需要: 免费 已有0 人下载
最新资料
资料动态
专题动态
is_732724
暂无简介~
格式:pdf
大小:552KB
软件:PDF阅读器
页数:0
分类:互联网
上传时间:2012-07-25
浏览量:26