77范文网 - 专业文章范例文档资料分享平台

ActiveMQ使用手册(3)

来源:网络收集 时间:2019-04-05 下载这篇文档 手机版
说明:文章内容仅供预览,部分内容可能不全,需要完整文档或者需要复制内容,请下载word后使用。下载word有问题请添加微信号:或QQ: 处理(尽可能给您提供完整文档),感谢您的支持与谅解。点击这里给我发消息

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 Runs a broker with two transport connectors and JMX enabled. activemq broker:(tcp://localhost:61616, tcp://localhost:5000)?useJmx=true Runs a broker with 1 activemq broker:(tcp://localhost:61616, transport connector and 1 network:tcp://localhost:5000)?persistent=fnetwork connector with alse persistence disabled. 2.3.2 Embedded Broker:

可以通过在应用程序中以编码的方式启动broker,例如: Java代码

BrokerService broker = new BrokerService(); broker.addConnector(\broker.start();

如果需要启动多个broker,那么需要为broker设置一个名字。例如: Java代码

BrokerService broker = new BrokerService(); broker.setName(\

broker.addConnector(\broker.start();

如果希望在同一个JVM内访问这个broker,那么可以使用VM Transport,URI是:vm://brokerName。关于更多的broker属性,可以参考Apache的官方文档。

此外,也可以通过BrokerFactory来创建broker,例如:

第8页

Java代码

BrokerService broker = BrokerFactory.createBroker(new URI(someURI)); someURI的可选值如下: URI Example scheme xbean: xbean:activemq.xml Description 查找运行环境(classpath)相对路径下的配置文件(如果在根目录下配置为---xbean:activemq.xml) 查找实例目录的broker配置文件(foo/bar/activemq.xml) file: file:foo/bar/activemq.xml broker: broker:tcp://localhost:61616 通过URL配置

当使用XBean的配置方式的时候,需要指定一个xml配置文件,例如: Java代码

BrokerService broker = BrokerFactory.createBroker(new URI(\/activemq.xml\

使用Spring的配置方式如下: Xml代码

2.4 ActiveMQ Broker的Transport

Transport 是Broker 数据传输使用的协议,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等。

第9页

下面介绍几种常用的Transport

2.4.1 TCP Transport

TCP transport 允许客户端通过TCP socket连接到远程的broker。以下是配置语法:

tcp://hostname:port?transportOptions Transport Options的可选值如下: Option Name Default Description Value The minimum version wireformat that is allowed Causes all commands that are sent over the transport to be logged When true, it causes the local machines name to resolve to \sets the socket timeout in milliseconds 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. All the properties with this prefix are used to configure the wireFormat. See Configuring Wire Formats for more information minmumWireFormatVersion 0 trace useLocalHost socketBufferSize soTimeout false true 64 * 1024 Sets the socket buffer size in bytes 0 connectionTimeout 30000 wireFormat default The name of the WireFormat to use wireFormat.* 2.4.2 Failover Transport

Failover Transport是一种重新连接的机制,它工作于其它transport的上层,

用于建立可靠的传输。它的配置语法允许制定任意多个复合的URI。 Failover transport会自动选择其中的一个URI来尝试建立连接。如果没有成功,那么会选择一个其它的URI来建立一个新的连接。以下是配置语法: failover:(uri1,...,uriN)?transportOptions failover:uri1,...,uriN

Transport Options的可选值如下:

第10页

Option Name initialReconnectDelay Default Value 10 Description How long to wait before the first reconnect attempt (in ms) maxReconnectDelay The maximum amount of time we ever 30000 wait between reconnect attempts (in ms) true 2.0 Should an exponential backoff be used btween reconnect attempts The exponent used in the exponential backoff attempts useExponentialBackOff reconnectDelayExponent maxReconnectAttempts From version 5.6 onwards: -1 is default and means retry forever, 0 means don't retry (only try connection once but no retry). Prior to version 5.6: 0 is default -1 | 0 and means retry forever. All versions: If set to >0, then this is the maximum number of reconnect attempts before an error is sent back to the client. If not 0, then this is the maximum number of reconnect attempts before an error is sent back to the client on the first attempt by the client to start a connection, once connected the maxReconnectAttempts option takes precedence. use a random algorithm to choose the the URI to use for reconnect from the list provided startupMaxReconnectAttempts 0 randomize true backup initialize and hold a second false transport connection - to enable fast failover Enables timeout on send operations (in miliseconds) without interruption of reconnection process keep a cache of in-flight messages that will flushed to a broker on timeout -1 trackMessages false 第11页

reconnect maxCacheSize 131072 size in bytes for the cache, if trackMessages is enabled Determines whether the client should accept updates to its list of known URIs from the connected broker. Added in ActiveMQ 5.4 A URL (or path to a local file) to a text file containing a comma separated list of URIs to use for reconnect in the case of failure. Added in ActiveMQ 5.4 Extra options to add to the nested URLs. Added in ActiveMQ 5.9 After every N reconnect attempts log a warning to indicate there is no connection but that we are still trying, set to <= 0 to disable. Added in ActiveMQ 5.10 Determines whether the client should respond to broker ConnectionControl events with a reconnect (see: rebalanceClusterClients) updateURIsSupported true updateURIsURL null nested.* null warnAfterReconnectAttempts.* 10 reconnectSupported true

例如:

failover:(tcp://localhost:61616,tcp://remotehost:61616)?initialReconnectDelay=100

2.4.3 Discover Transport

Discovery transport是可靠的tranport。它使用Discovery transport来定位用来连接的URI列表。以下是配置语法:

discovery:(discoveryAgentURI)?transportOptions discovery:discoveryAgentURI

Transport Options的可选值如下: Option Name Default Description Value 第12页

百度搜索“77cn”或“免费范文网”即可找到本站免费阅读全部范文。收藏本站方便下次阅读,免费范文网,提供经典小说综合文库ActiveMQ使用手册(3)在线全文阅读。

ActiveMQ使用手册(3).doc 将本文的Word文档下载到电脑,方便复制、编辑、收藏和打印 下载失败或者文档不完整,请联系客服人员解决!
本文链接:https://www.77cn.com.cn/wenku/zonghe/571712.html(转载请注明文章来源)
Copyright © 2008-2022 免费范文网 版权所有
声明 :本网站尊重并保护知识产权,根据《信息网络传播权保护条例》,如果我们转载的作品侵犯了您的权利,请在一个月内通知我们,我们会及时删除。
客服QQ: 邮箱:tiandhx2@hotmail.com
苏ICP备16052595号-18
× 注册会员免费下载(下载后可以自由复制和排版)
注册会员下载
全站内容免费自由复制
注册会员下载
全站内容免费自由复制
注:下载文档有可能“只有目录或者内容不全”等情况,请下载之前注意辨别,如果您已付费且无法下载或内容有问题,请联系我们协助你处理。
微信: QQ: