关于activemq怎么下载的配备怎么解决

activeMQ&在linux配置启动
1 下载 activeMQ
2 解压 tar -zvxf ....tar
3 在 /etc/init.d新建 activemq 文件
# activemq
# chkconfig: 345 63 37
# description: activemq servlet container.
# processname: activemq 5.5
JAVA_HOME=/usr/local/jdkCLASSPATH=$JAVA_HOME/lib:$JAVA_HOME/jre/lib:$CATALINA_HOME/common/lib
export JAVA_HOME=/usr/local/jdk
export CATALINA_HOME=/usr/local/tomcat
CLASSPATH=$JAVA_HOME/lib:$JAVA_HOME/jre/lib:$CATALINA_HOME/common/lib
export JAVA_HOME CLASSPATH
. /etc/rc.d/init.d/functions
. /etc/sysconfig/network
case $1 in
sh /usr/local/apache-activemq-5.5.0/bin/avtivemq start
sh&&/usr/local/apache-activemq-5.5.0/bin/avtivemq
sh /usr/local/$CATALINA_HOME/bin/avtivemq stop
sh /usr/local/$CATALINA_HOME/bin/avtivemq start
4 chmod 755 activemq
5 在activeMQ 安装目录下新建start_activemq.sh
/etc/init.d/activemq start
新建stop_activemq.sh
/etc/init.d/activemq stop
chmod 755 start_activemq.sh
chmod 755 stop_activemq.sh
运行./start_activemq.sh 启动
./stop_activemq.sh 关闭
已投稿到:
以上网友发言只代表其个人观点,不代表新浪网的观点或立场。关于ActiveMQ的配置
关于ActiveMQ的配置
目前常用的消息队列组建无非就是MSMQ和ActiveMQ,至于他们的异同,这里不想做过多的比较。简单来说,MSMQ内置于微软操作系统之中,在部署
上包含一个隐性条件:Server需要是微软操作系统。(对于这点我并去调研过MSMQ是否可以部署在非微软系统,比如:Linux,只是拍脑袋想了想,
感觉上是不可以)。对于ActiveMQ,微软系统和Linux都是可以部署的。从功能方面来说,一般最常用的就是:消息的收/发,感觉差异不大。从性能
上来说,一般的说法是ActiveMQ略高。在稳定性上,个人感觉MSMQ更好。如果这两种常用队列都用过的同学,应该来说最大的差异在于:MSMQ如果
要访问远程队列(比如机器A上的程序访问机器B上的队列),会比较恶心。在数据量比较大的情况之下,一般来说队列服务器会专门的一台或者多台(多台的话,
用程序去做热备+负载比较方便,也不需要额外的硬件成本。简单来说做法可以这样:消息发送的时候随机向着多台队列服务器上发送消息;接受的时候开多个线程
去分别监听;热备方面,可以维护一个带状态的队列连接池,如果消息收发失败那么将状态置为不可用,然后起一个线程去定时监测坏的连接是否可用,这个过程一
般情况下可以不用加锁,为什么,大家根据各自需要去取舍吧)。最近搞完了短彩信的网关连接服务,这两种队列我均使用了。大致的过程是这样的:上层应用如果
要发端彩信,那么将消息直接发送至ActiveMQ(目前用的就是上面说的多台热备+负载,因为实际中下行量非常大5千万条/天以上),然后端彩信网关连
接服务部署多套,每套均依赖本机的MSMQ。为什么呢?用ActiveMQ的原因是:上层应用程序和网关连接服务彼此独立,消息需要跨机访问。用MSMQ
的原因是:ActiveMQ中的数据是一条不分省的大队列,网关连接服务需要按省流控,所以端彩信网关连接服务:首先把消息从ActiveMQ取出来,然
后存至本机上的分省MSMQ,这样做另外的一个好处就是:ActiveMQ不至于过多挤压,他的数据会分摊到N台短彩信网关连接服务所部署的机器上的
MSMQ之中,也就说MSMQ可以起到分摊数据和缓冲的作用。
&&&& 在之前的随笔中,已经介绍过MSMQ,现在先介绍一下ActiveMQ一些配置,目前好像ActiveMQ配置上的介绍还比较少。以下是自己总结一些相关资料,贴出来给大家共享
一)问题分析和解决
1)KahaDb和AMQ Message Store两种持久方式如何选择?
From 5.3 onwards - we recommend you use KahaDB - which offers
improved scalability and recoverability over the AMQ Message Store.
The AMQ Message Store which although faster than KahaDB - does not scales as well as KahaDB and recovery times take longer.
kaha文件系统实际上上是一个文件索引系统,有两部分组成,一个是数据文件系统,由一个个独立的文件组成,缺省文件大小是32M大(可配置),另
外一个是索引文件系统,记录消息在数据文件中的位置信息以及数据文件中的空闲块信息。数据文件是存储到硬盘上的,索引文件是缓存在内存中的。所以这个存储
系统对大消息存储有利,象我们的memberId之类的文本消息,实际上是浪费,索引比消息还大,哈。
我方分析:
推荐: Amq持久方式
理由:虽然官方推荐使用KahaDB持久方式,但其提到的优势:可伸缩性和恢复性较好,对于我们实际的应用意义不大。从我们自己的使用经验来
看,KahaDB持久方式,Data文件是一个大文件(感觉文件过大后,造成队列服务瘫死的可能性会增大),从官网的相关配置(附录1)也找不到哪里可以
设置数据的文件的最大Size。)而Amq持久方式可以设置Data文件最大Size,这样可以保证即时消息积压很多,Data文件也不至于过大。
2)错误:Channel was inactive for too long
解决方法:
在建立连接的Uri中加入: wireFormat.maxInactivityDuration=0
参考资源:
You can do the following to fix the issues:
1) Append max inactivity duration to your Uri in the format below: wireFormat.maxInactivityDuration=0
2) Use the same Uri at the client side as well as at the server side
如果不这样设置,对应的错误会出现:
09:22:56,343
[org.apache.activemq.ActiveMQConnection]-[WARN] Async exception with no
exception listener: org.apache.activemq.transport.InactivityIOException:
Channel was inactive for too long: localhost/127.0.0.1:61616
org.apache.activemq.transport.InactivityIOException: Channel was inactive for too long: localhost/127.0.0.1:61616
ActiveMQ的tcp
url:tcp://localhost:61616后面要加入?wireFormat.maxInactivityDuration=0
这样的参数,否则当一段时间没有消息发送时会抛出 "Channel was inactive for too long"异常
3)错误:Wire format negotiation timeout: peer did not send his wire format.
解决方法:
1)关闭ActiveMqLog4j
打开:conf/log4j.properties
将:log4j.rootLogger=INFO, console, logfile
修改为:log4j.rootLogger=OFF
2)在建立连接的Uri中加入: maxInactivityDurationInitalDelay=30000
例如北京的测试环境连接Uri:
tcp://192.168.199.80:61616?wireFormat.maxInactivityDuration=0&maxInactivityDurationInitalDelay=30000&connection.AsyncSend=true
参考资源:
If you get exception like this,it can mean one of three things:
1. You're connecting to the port not used by ActiveMQ TCP transport
Make sure to check that you're connecting to the appropriate host:port
2. You're using log4j JMS appender and doesn't filter out ActiveMQ log messages
Be sure to read How do I use log4j JMS appender with ActiveMQ and
more importantly to never send ActiveMQ log messages to JMS appender
3. Your broker is probably under heavy load (or network
connection is unreliable), so connection setup cannot be completed in a
reasonable time
If you experience sporadic exceptions like this, the best solution is
to use failover transport, so that your clients can try connecting
again if the first attempt fails. If you're getting these kind of
exceptions more frequently you can also try extending wire format
negotiation period (default 10 sec). You can do that by using
wireFormat.maxInactivityDurationInitalDelay property on the connection
URL in your client.
For example
tcp://localhost:61616?wireFormat.maxInactivityDurationInitalDelay=30000
will use 30 sec timeout.(貌似有问题!!!)
4)错误:Out of memory
解决方法:
1)& 设置Java最大内存限制为合适大小:
Bin/activemq.bat 中ACTIVEMQ_OPTS=-Xmx512M(默认是512)
2)Activemq.xml配置节:systemUsage/ systemUsage配置大小合适,并且特别注意:大于所有durable desitination设置的memoryUsage之和。
1)尖括号:“&”代表通配符
2)ACTIVEMQ_OPTS的配置〉=memoryUsage中配置〉=所有durable desitination设置之和
3)SystemUsage配置设置了一些系统内存和硬盘容量,当系统消耗超过这些容量设置时,amq会“slow down producer”,还是很重要的。
参考资料:
参考-- http://activemq.apache.org/javalangoutofmemory.html
&&&&&& 对于MQ的内容实用是可管理和可配置的。首先需要判断的是MQ的哪部分系统因内存不足而导致泄漏,是JVM,broker还是消费者、生产者?
&&&&&& 一、内存管理
&&&&&& JVM内存管理:
&&&&&& 1. 用bin/activemq命令在独立JVM中运行broker。用-Xmx和-Xss命令即可(activemq.bat文件中修改ACTIVEMQ_OPTS选项参数即可);
&&&&&& 2. 默认情况下,MQ用512M的JVM;
&&&&&& broker内存管理:
&&&&&& 1. broker使用的内存并不是由JVM的内存决定的。虽然受到JVM的限制,但broker确实独立管理器内存;
&&&&&& 2. systemUsage和destination的内存限制与broker内存息息相关;
&&&&&& 3. MQ中内存的关系是:JVM-&Broker-&
&&&&&& 4. 所有destination的内存总量不能超过broker的总内存;
&&&&&& 消费者:
&&&&&& 1. 由于消息大小可以配置,prefetch limit往往是导致内存溢出的主要原因;
&&&&&& 2. 减少prefetch limit的大小,会减少消费者内存中存储的消息数量;
&&&&&& 生产者:
&&&&&& 1. 除非消息数量超过了broker资源的限制,否则生产者不会导致内存溢出;
&&&&&& 2. 当内存溢出后,生产者会收到broker的阻塞信息提示;
&&&&&& 二、其他
&&&&&& 将消息缓冲之硬盘:
&&&&&& 1. 只有当消息在内存中存储时,才允许消息的快速匹配与分发,而当消费者很慢或者离开时,内存可能会耗尽;
&&&&&& 2. 当destination到达它的内存临界值时,broker会用消息游标来缓存非持久化的消息到硬盘。
&&&&&& 3. 临界值在broker中通过memoryUsage和systemUsage两个属性配置,请参考activemq.xml;
&&&&&& 4. 对于缓慢的消费者,当尚未耗尽内存或者转变为生产者并发控制模式前,这个特性允许生产者继续发送消息到broker;
&&&&&& 5. 当有多个destination的时候,默认的内存临界值可能被打破,而这种情况将消息缓存到硬盘就显得很有意义;
&&&&&& 6. precentUsage配置:使用百分比来控制内存使用情况;
&&&&&& 多个线程:
&&&&&& 1. 默认情况下,MQ每个destination都对应唯一的线程;
&&&&&& 2. -Dorg.apache.activema.UseDedicatedTaskRunner=false(activemq.bat文件中修改ACTIVEMQ_OPTS选项参数即可),用线程池来限制线程的数量,从而减少内存消耗;
&&&&&& 大数据传输:
&&&&&& 1. destination policies--maxPageSize:控制进入内存中的消息数量;lazyDispatch:增加控制使用当前消费者列表的预取值;
&&&&&& 2. 使用blogMessage或者streamsMessage类型来进行大量文件的传输;
&&&&&& 泄漏JMS资源:
&&&&&& 1. 当session或者producer或者consumer大量存在而没有关闭的时候;
&&&&&& 2. 使用PooledConnectionFactory;
5)采用failover方式连接导致卡死
解决方法:
不采用failover连接
采用failover方式连接,如果所要连接的服务器或者Activemq服务宕了,那么程序会一直处于等待状态,不超时,不报错。
1)KahaDB持久配置
property name
default value
activemq-data
the path to the directory to use to store the message store data and log files
indexWriteBatchSize
number of indexes written in a batch
indexCacheSize
number of index pages cached in memory
enableIndexWriteAsync
if set, will asynchronously write indexes
journalMaxFileLength
a hint to set the maximum size of the message data logs
enableJournalDiskSyncs
ensure every non transactional journal write is followed by a disk sync (JMS durability requirement)
cleanupInterval
time (ms) before checking for a discarding/moving message data logs that are no longer used
checkpointInterval
time (ms) before checkpointing the journal
ignoreMissingJournalfiles
If enabled, will ignore a missing message log file
checkForCorruptJournalFiles
If enabled, will check for corrupted Journal files on startup and try and recover them
checksumJournalFiles
create a checksum for a journal file - to enable checking for corrupted journals
Available since version 5.4:
archiveDataLogs
If enabled, will move a message data log to the archive directory instead of deleting it.
directoryArchive
Define the directory to move data logs to when they all the messages they contain have been consumed.
databaseLockedWaitDelay
time (ms) before trying to get acquire a the database lock (used by shared master/slave)
maxAsyncJobs
the maximum number of asynchronous messages that will be queued
awaiting storage (should be the same as the number of concurrent
MessageProducers)
concurrentStoreAndDispatchTopics
enable the dispatching of Topic messages to interested clients to happen concurrently with message storage
concurrentStoreAndDispatchQueues
enable the dispatching of Queue messages to interested clients to happen concurrently with message storage
2)AMQ持久配置
property name
default value
activemq-data
the path to the directory to use to store the message store data and log files
use NIO to write messages to the data logs
syncOnWrite
sync every write to disk
maxFileLength
a hint to set the maximum size of the message data logs
persistentIndex
use a persistent index for the message logs. If this is false, an in-memory structure is maintained
maxCheckpointMessageAddSize
the maximum number of messages to keep in a transaction before automatically committing
cleanupInterval
time (ms) before checking for a discarding/moving message data logs that are no longer used
indexBinSize
default number of bins used by the index. The bigger the bin size - the better the relative performance of the index
indexKeySize
the size of the index key - the key is the message id
indexPageSize
the size of the index page - the bigger the page - the better the write performance of the index
directoryArchive
the path to the directory to use to store discarded data logs
archiveDataLogs
if true data logs are moved to the archive directory instead of being deleted
3)systemUsage配置
property name
default value
memoryUsage
amq使用内存大小,照amq论坛上说,这个值应该大于所有durable desitination设置的
memoryUsage之和,否则会导致硬盘swap,影响性能。
storeUsage
kaha数据存储大小,如果设置不足,性能会下降到1个1个发
非persistent的消息存储在temp区域
4)其他配置
4.1)Failover Transport Options
Option Name
Description
transport.timeout
Time that a send operation blocks before failing.
transport.initialReconnectDelay
Time in Milliseconds that the transport waits before attempting to reconnect the first time.
transport.maxReconnectDelay
The max time in Milliseconds that the transport will wait before attempting to reconnect.
transport.backOffMultiplier
The amount by which the reconnect delay will be multiplied by if useExponentialBackOff is enabled.
transport.useExponentialBackOff
Should the delay between connection attempt grow on each try up to the max reconnect delay.
transport.randomize
Should the Uri to connect to be chosen at random from the list of available Uris.
transport.maxReconnectAttempts
Maximum number of time the transport will attempt to reconnect before failing (0 means infinite retries)
transport.startupMaxReconnectAttempts
Maximum number of time the transport will attempt to
reconnect before failing when there has never been a connection made. (0
means infinite retries) (included in NMS.ActiveMQ v1.5.0+)
transport.reconnectDelay
The delay in milliseconds that the transport waits before attempting a reconnection.
transport.backup
Should the Failover transport maintain hot backups.
transport.backupPoolSize
If enabled, how many hot backup connections are made.
transport.trackMessages
keep a cache of in-flight messages that will flushed to a broker on reconnect
transport.maxCacheSize
Number of messages that are cached if trackMessages is enabled.
transport.updateURIsSupported
Update the list of known brokers based on BrokerInfo messages sent to the client.
4.2)Connection Options
Option Name
Description
connection.AsyncSend
Are message sent Asynchronously.
connection.AsyncClose
Should the close command be sent Asynchronously
connection.AlwaysSyncSend
Causes all messages a Producer sends to be sent Asynchronously.
connection.CopyMessageOnSend
Copies the Message objects a Producer sends so that the client can reuse Message objects without affecting an in-flight message.
connection.ProducerWindowSize
The ProducerWindowSize is the maximum number of bytes in memory that a
producer will transmit to a broker before waiting for acknowledgement
messages from the broker that it has accepted the previously sent
messages. In other words, this how you configure the producer flow
control window that is used for async sends where the client is
responsible for managing memory usage. The default value of 0 means no
flow control at the client. See also
connection.useCompression
Should message bodies be compressed before being sent.
connection.sendAcksAsync
Should message acks be sent asynchronously
connection.messagePrioritySupported
Should messages be delivered to the client based on the value of the Message Priority header.
connection.dispatchAsync
Should the broker
to the connection's consumers.
4.3)OpenWire Options
Option Name
Description
wireFormat.stackTraceEnabled
Should the stack trace of exception that occur on the broker be sent to the client? Only used by openwire protocol.
wireFormat.cacheEnabled
Should commonly repeated values be cached so that less marshalling occurs? Only used by openwire protocol.
wireFormat.tcpNoDelayEnabled
Does not affect the wire format, but provides a hint to
the peer that TCP nodelay should be enabled on the communications
Socket. Only used by openwire protocol.
wireFormat.sizePrefixDisabled
Should serialized messages include a payload length prefix? Only used by openwire protocol.
wireFormat.tightEncodingEnabled
Should wire size be optimized over CPU usage? Only used by the openwire protocol.
wireFormat.maxInactivityDuration
The maximum inactivity duration (before which the socket
is considered dead) in milliseconds. On some platforms it can take a
long time for a socket to appear to die, so we allow the broker to kill
connections if they are inactive for a period of time. Use by some
transports to enable a keep alive heart beat feature. Set to a value
&= 0 to disable inactivity monitoring.
maxInactivityDurationInitalDelay
The initial delay in starting the maximum inactivity checks (and, yes, the word 'Inital' is supposed to be misspelled like that)
5)安全配置
1、控制台安全配置,打开conf/jetty.xml文件,找到
&&& &bean id="securityConstraint" class="org.eclipse.jetty.http.security.Constraint"&
&&&&&&& &property name="name" value="BASIC" /&
&&&&&&& &property name="roles" value="admin" /&
&&&&&&& &property name="authenticate" value="false" /&
&&& &/bean&
&& 将“false”改为“true”即可。用户名和密码存放在conf/jetty-realm.properties文件中。
2、生产者和消费者连接MQ需要密码
&& 打开conf/activemq.xml文件,在&broker&标签里的&systemUsage&标签前加入:
&& &plugins&&&
&simpleAuthenticationPlugin&&&
&authenticationUser username="${activemq.username}" password="${activemq.password}" groups="users,admins"/&&&
&/users&&&
&/simpleAuthenticationPlugin&&&
&& &/plugins&
&注意必须在&systemUsage&标签前,否则启动ActiveMQ会报错。
用户名和密码存放在conf/credentials.properties文件中
发表评论:
TA的最新馆藏博客访问: 69830
博文数量: 366
博客积分: 9600
博客等级: 上校
技术积分: 18103
注册时间:
IT168企业级官微
微信号:IT168qiye
系统架构师大会
微信号:SACC2013
分类: LINUX
安装java环境jre-6u30-linux-x64.bin./jre-6u30-linux-x64.bin& &cp -ar jre1.6.0_30 /usr/local/vim /etc/profileexport JAVA_HOME="/usr/local/jre1.6.0_30"export JRE_HOME="$JAVA_HOME/jre"export CLASSPATH="$JAVA_HOME/lib:$JRE_HOME/lib:$CLASSPATH"export PATH="$JAVA_HOME/bin:$JRE_HOME/bin:$PATH"source /etc/profile安装 apache-activemqtar -xzvf apache-activemq-5.5.0-bin.tar.gz -C /usr/local/mv /usr/local/apache-activemq-5.5.0 /usr/local/activemqcd /usr/local/activemq/bin/vim activemq更改ACTIVEMQ_OPTS_MEMORY的配置为ACTIVEMQ_OPTS_MEMORY="-Xms256M -Xmx384M -XX:PermSize=256M -XX:MaxPermSize=384M"/usr/local/activemq/bin/activemq startnetstat -lnp|grep 61616完成后添加/usr/local/activemq/bin/activemq start到自启动配置好后可以登录监控管理页面去看队列情况&http://192.168.100.15:8161/admin/queues.jsp
阅读(11509) | 评论(0) | 转发(1) |
相关热门文章
给主人留下些什么吧!~~
请登录后评论。二次元同好交流新大陆
扫码下载App
温馨提示!由于新浪微博认证机制调整,您的新浪微博帐号绑定已过期,请重新绑定!&&|&&
LOFTER精选
网易考拉推荐
用微信&&“扫一扫”
将文章分享到朋友圈。
用易信&&“扫一扫”
将文章分享到朋友圈。
一、前言在前一篇《&&》中,大概介绍了项目中使用ActiveMQ的场景,并贴了相关的代码,因本人也是初学者,对ActiveMQ没有深入的研究,只是在项目当中使用了,写些文章,分享一下我的经历。在《&&》中贴的代码,因为木有对消息进行持久化,有时候会造成消息的丢失,在我项目使用过程中,如果Web应用部署到我本机子上,而ActiveMQ的Server是远程的,则同时发送两条消息时,消息不会造成丢失,而部署了Server上面之后,经测试人员反馈,发现同时发送两条数据时候,消费者只能接收到一条消息,本来也查了一下原因,实在是搞不明白,后经与技术群讨论,才发现是消息没有持久化造成的,后经修改,重新部署之后,暂时还木有发现消息丢失的情况,现将配置代码贴了,分享一下。&二、配置1、消息发送方在消息发送时,需要为消息发送方配置一个clientIDPrefix的一个属性,该属性来表示那个消费者可以获得此消息,配置文件如下:&!-- 配置connectionFactory --&
&bean id="jmsSenderFactory" class="org.apache.activemq.pool.PooledConnectionFactory"
destroy-method="stop"&
&property name="connectionFactory"&
&bean class="org.apache.activemq.ActiveMQConnectionFactory"&
&property name="brokerURL" value="${jms.sendBrokerURL}"&
&/property&
&property name="useAsyncSend" value="true"&&/property&
&!-- clinetIDPrefix属性 --&
&property name="clientIDPrefix" value="${jms.senderClientIDPrefix)"&&/property&
&/property&
&property name="maxConnections" value="100"&&/property&
&/bean&clientIDPrefix:指定了consumer的clientID的前缀,符合此前缀规则的consumer将成为该TOPIC的持久订阅者。2、消息接收者&!--异步调用消息 --&
&bean id="receive"
class="org.springframework.jms.listener.DefaultMessageListenerContainer"&
&property name="connectionFactory" ref="jmsReceiverFactory"&&/property&
&property name="destinationName" value="${jms.receiveDestinationName}"&&/property&
&property name="messageListener" ref="messageListener"&&/property&
&property name="sessionAcknowledgeMode" value="1"&&/property&
&property name="subscriptionDurable" value="true"&&/property&
&property name="pubSubDomain" value="true"&&/property&
&property name="clientId" value="${jms.receiverClientId}"&&/property&
&property name="durableSubscriptionName" value="${jms.receiverClientId}"&&/property&
&/bean&Durable Subscription:对于通常的消息订阅来说, JMS Provider会对这类消息订阅者“一视同仁”,你来了,我就给你消息,你走了,我就不管你了。 当消息到达指定Topic之后,JMS Provider只会为已经连接并且订阅了该指定Topic的消息订阅者发送消息, 如果消息到达之后你恰好不在,那不好意思,你将接收不到这一消息。这就好像现在的商场促销活动,礼品(消息)有限,虽然你(相当于消息订阅者)也想获得相应的礼品, 但当发送礼品的时候你不在礼品派发现场的话,你将失去这一获得礼品(消息)的机会,因为商场可不会管你是何方神圣,对于JMS Provider来说, 也是同样道理,只要我(JMS Provider)派发消息的时候你不在,你收不到消息是你自己找的,跟我没有关系。 也就是说,JMS Provider不会“耗费脑筋”去记下谁还没有来接收消息,就跟商场不会纪录到底谁的礼品还没有来领取一样, 因为对于这种情况来说,耗费资源去这些不确定的client, 完全就是non-sense的,不是嘛? JMS Provider或者说商场,根本就不会知道谁会来领取消息或者礼品。当我们转到Durable Subscription的时候,情况就完全不同了。如果消息订阅者通过Durable Subscription的方式来订阅消息, 那么JMS Provider将会费点儿脑筋来记下这个Durable Subscription的消息订阅者是谁,即使当消息到达之后,该Durable Subscription消息订阅者不在, JMS Provider也会保证, 该Durable Subscription消息订阅者重新回来之后,之前到达而该Durable Subscription消息订阅者还没有处理的消息,将被一个不少的发送给它。clientId:是在连接时必须提供的,做为subscriptionDurable为ture,必须提供该属性,这个clientId会与JMS Provider的clientPrefixID匹配,才能接到相应的消息单凭Client Id还不足以唯一标志某一个Durable Subscription,就跟我凭一个身份证,可以预定多个房间一样。 同一个连接里,你可以创建多个MessageConsumer去订阅不同Topic的消息,如果下回回来,你只想继续接受某一个Topic消息的话,JMS Provider如何知道是哪一个? 所以,为了区分同一个Connection中不同的Durable Subscription,我们还需要进一步的标志物,这就是Subscriber Name!&这就是关于subscriptionDurable、clientId、durableSbscriptionName的解释,具体可参阅&&三、小结ActiveMQ只是在项目中临时使用,原来项目使用Oracle Service Bus来实现的,时间原因临时采用了JMS,这只是本人在项目中使用过程中所能分享的,当然没有对JMS深入的研究,待以后有时间再研究再分享出来,若有问题,可讨论,一起学习、一起分享。这里面只需注意一个问题:其中&property name="clientIDPrefix" value="www"/&配置指明每个连接到jms服务器的连接的clientId的前缀是www,然后具体这个配置的用处现在还不清楚,之前网上说这个配置表明只有当连接的jms服务器的客户端的clientId名的前缀与这个配置一致时,该连接才能实现持久化订阅,但实际情况是这里不管要不要这个配置,订阅者只要指定任意的clientId值都可以实现持久订阅。附:简单的配置:
&bean id="listenerContainer"
class="org.springframework.jms.listener.DefaultMessageListenerContainer"&
&property name="connectionFactory"
ref="jmsFactory" /&
&property name="destination"
ref="destination" /&
&property name="messageListener"
ref="messageReceiver" /&
&property name="subscriptionDurable" value="true"&&/property&
&property name="clientId" value="${jms.receiverClientId}"&&/property&
&bean id="messageReceiver" class="com.panfu.biz.impl.MessageReceiverImpl"&
&/bean&public class MessageReceiverImpl implements MessageListener {
public void onMessage(Message m){
// TODO Auto-generated method stub
TextMessage tm = (TextMessage)(m);
System.out.println("ok-------------------");
System.out.println(Thread.currentThread().getId());
System.out.println(tm.getText());
} catch (JMSException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} }}这样,当设置为subscriptionDurable时,我们通过clientId就实现了消息的持久化补发机制
阅读(4226)|
用微信&&“扫一扫”
将文章分享到朋友圈。
用易信&&“扫一扫”
将文章分享到朋友圈。
历史上的今天
在LOFTER的更多文章
loftPermalink:'',
id:'fks_',
blogTitle:'activeMq配置详解(大部分是转的)',
blogAbstract:'基于ActiveMQ的Topic的数据同步——消费者持久化时间 14:08:02&',
blogTag:'',
blogUrl:'blog/static/',
isPublished:1,
istop:false,
modifyTime:0,
publishTime:3,
permalink:'blog/static/',
commentCount:0,
mainCommentCount:0,
recommendCount:0,
bsrk:-100,
publisherId:0,
recomBlogHome:false,
currentRecomBlog:false,
attachmentsFileIds:[],
groupInfo:{},
friendstatus:'none',
followstatus:'unFollow',
pubSucc:'',
visitorProvince:'',
visitorCity:'',
visitorNewUser:false,
postAddInfo:{},
mset:'000',
remindgoodnightblog:false,
isBlackVisitor:false,
isShowYodaoAd:false,
hostIntro:'',
hmcon:'1',
selfRecomBlogCount:'0',
lofter_single:''
{list a as x}
{if x.moveFrom=='wap'}
{elseif x.moveFrom=='iphone'}
{elseif x.moveFrom=='android'}
{elseif x.moveFrom=='mobile'}
${a.selfIntro|escape}{if great260}${suplement}{/if}
{list a as x}
推荐过这篇日志的人:
{list a as x}
{if !!b&&b.length>0}
他们还推荐了:
{list b as y}
转载记录:
{list d as x}
{list a as x}
{list a as x}
{list a as x}
{list a as x}
{if x_index>4}{break}{/if}
${fn2(x.publishTime,'yyyy-MM-dd HH:mm:ss')}
{list a as x}
{if !!(blogDetail.preBlogPermalink)}
{if !!(blogDetail.nextBlogPermalink)}
{list a as x}
{if defined('newslist')&&newslist.length>0}
{list newslist as x}
{if x_index>7}{break}{/if}
{list a as x}
{var first_option =}
{list x.voteDetailList as voteToOption}
{if voteToOption==1}
{if first_option==false},{/if}&&“${b[voteToOption_index]}”&&
{if (x.role!="-1") },“我是${c[x.role]}”&&{/if}
&&&&&&&&${fn1(x.voteTime)}
{if x.userName==''}{/if}
网易公司版权所有&&
{list x.l as y}
{if defined('wl')}
{list wl as x}{/list}

我要回帖

更多关于 activemq怎么一直监听 的文章

 

随机推荐