??xml version="1.0" encoding="utf-8" standalone="yes"?>
关键?ActiveMQ,实践
一.安装ActiveMQ
首先?a >http://activemq.apache.org/download.html 下蝲最新版?.1.0release (http://activemq.apache.org/activemq-410-release.html),
解压apache-activemq-4.1-incubator.zip(或者apache-activemq-4.1-incubator.tar.gz)目录如下:
+bin (windows下面的bat和unix/linux下面的sh)
+conf (activeMQ配置目录,包含最基本的activeMQ配置文g)
+data (默认是空?
+docs (index,replease版本里面没有文档,-.-b不知道ؓ啥不?
+example (几个例子
+lib (activemMQ使用到的lib)
-apache-activemq-4.1-incubator.jar (ActiveMQ的binary)
-LICENSE.txt
-NOTICE.txt
-README.txt
-user-guide.html
你可以用bin\activemq.bat(activemq) 启动,如果一切顺?你就会看见类g面的信息
(l节可能不一?比如路径,或者jmx,jdbc信息)
ACTIVEMQ_HOME: D:\java\framework_and_lib\activemq\apache-activemq-4.1-incubator\
bin\..
Loading message broker from: xbean:activemq.xml
INFO BrokerService - ActiveMQ null JMS Message Broker (localho
st) is starting
INFO BrokerService - For help or more information please see:
http://incubator.apache.org/activemq/
INFO ManagementContext - JMX consoles can connect to service:jmx:r
mi:///jndi/rmi://localhost:1099/jmxrmi
INFO JDBCPersistenceAdapter - Database driver recognized: [apache_derby
_embedded_jdbc_driver]
INFO DefaultDatabaseLocker - Attempting to acquire the exclusive lock
to become the Master broker
INFO DefaultDatabaseLocker - Becoming the master on dataSource: org.ap
ache.derby.jdbc.EmbeddedDataSource@1d840cd
INFO JournalPersistenceAdapter - Journal Recovery Started from: Active Jou
rnal: using 5 x 20.0 Megs at: D:\java\framework_and_lib\activemq\apache-activemq
-4.1-incubator\activemq-data\journal
INFO JournalPersistenceAdapter - Journal Recovered: 0 message(s) in transa
ctions recovered.
INFO TransportServerThreadSupport - Listening for connections at: tcp://P-SUW
EI:61616
WARN MulticastDiscoveryAgent - brokerName not set
INFO TransportConnector - Connector default Started
INFO TransportServerThreadSupport - Listening for connections at: stomp://P-S
UWEI:61613
INFO TransportConnector - Connector stomp Started
INFO NetworkConnector - Network Connector default Started
INFO BrokerService - ActiveMQ JMS Message Broker (localhost, I
D:P-SUWEI-1207-1170916242296-1:0) started
*。几个小提示
1. q个仅仅是最基础的ActiveMQ的配|?很多地方都没有配|因此不要直接用这个配|用于生产系l?br /> 2. 有的时候由于端口被占用,DActiveMQ错误,ActiveMQ可能需要以下端?099(JMX),61616(默认的TransportConnector)
3. 如果没有物理|卡,或者MS的LoopBackAdpater Multicast会报一个错?/p>
? 试你的ActiveMQ
׃ActiveMQ是一个独立的jms provider,所以我们不需要其他Q何第三方服务器就可以马上做我们的试?~译
example目录下面的程?br />
ProducerTool/ConsumerTool 是JMS参考里面提到的典型应用,Producer产生消息,Consumer消费消息
而且q个例子q可以加入参数帮助你试刚才启动的本地ActiveMQ或者是q程的ActiveMQ
ProducerTool [url] broker的地址,默认的是tcp://localhost:61616
[true|flase] 是否使用topic,默认是false
[subject] subject的名?默认是TOOL.DEFAULT
[durabl] 是否持久化消?默认是false
[messagecount] 发送消息数?默认?0
[messagesize] 消息长度,默认?55
[clientID] durable为true的时?需要配|clientID
[timeToLive] 消息存活旉
[sleepTime] 发送消息中间的休眠旉
[transacte] 是否采用事务
ConsumerTool [url] broker的地址,默认的是tcp://localhost:61616
[true|flase] 是否使用topic,默认是false
[subject] subject的名?默认是TOOL.DEFAULT
[durabl] 是否持久化消?默认是false
[maxiumMessages] 接受最大消息数?0表示不限?br />
[clientID] durable为true的时?需要配|clientID
[transacte] 是否采用事务
[sleepTime] 接受消息中间的休眠时?默认?,onMeesageҎ不休?br /> [receiveTimeOut] 接受时
我们q样可以使用:
java -classpath .\apache-activemq-4.1-incubator.jar;example\bin ProducerTool tcp://192.168.3.142:61616 test.mysubject
java -classpath .\apache-activemq-4.1-incubator.jar;example\bin ConsumerTool tcp://192.168.3.142:61616 test.mysubject
当然你可以用上面的参数q行更复杂的试,持久,事务
如果出现下面的信?恭喜?你的ActiveMQ已经能够工作?br />
Connecting to URL: tcp://192.168.3.142:61616
Publishing a Message with size 255 to queue: TOOL.DEFAULT
Using non-durable publishing
Sleeping between publish 0 ms
Sending message: Message: 0 sent at: Thu Feb 08 15:05:34 CST 2007 ...
Sending message: Message: 1 sent at: Thu Feb 08 15:05:34 CST 2007 ...
。。。。。。。?/p>
Connecting to URL: tcp://192.168.3.142:61616
Consuming queue: test.mysubject
Using non-durable subscription
Received: Message: 0 sent at: Thu Feb 08 14:51:34 CST 2007 ...
Received: Message: 1 sent at: Thu Feb 08 14:51:34 CST 2007 ...
。。。?/p>
?结
我们已经下蝲,启动,q且用程序测试了我们的ActiveMQ,而后面将在这个能跑得ActiveMQq一步的C?一步一步展CActiveMQ的高U特性?/p>
ActiveMQ 是一个完全支持JMS1.1和J2EE 1.4规范?JMS Provider实现,管JMS规范出台
已经是很久的事情?但是JMS在当今的J2EE应用中间仍然扮演着Ҏ的地位?br /> 下面是它的特性列?(详细的特性清单请参?a >http://activemq.apache.org/features.html)
1.多种语言和协议编写客L
语言: Java, C, C++, C#, Ruby, Perl, Python, PHP
应用协议: OpenWire,Stomp REST,WS Notification,XMPP,AMQP
2.完全支持JMS1.1和J2EE 1.4规范 (持久?XA消息,事务)
3.对Spring的支?ActiveMQ可以很容得内嵌到使用Spring的系l里面去,而且也支持Spring2.0的特?br /> 4.通过了常见J2EE服务??Geronimo,JBoss 4, GlassFish,WebLogic)的测?其中通过JCA 1.5 resource adaptors的配|?
可以让ActiveMQ可以自动的部|到M兼容J2EE 1.4 商业服务器上
5.支持多种传送协?in-VM,TCP,SSL,NIO,UDP,JGroups,JXTA
6.支持通过JDBC和journal提供高速的消息持久?br /> 7.从设计上保证了高性能的集?客户?服务?点对?br /> 8.支持Ajax
9.支持与Axis的整?br /> 10.可以很容易得调用内嵌JMS provider,q行试
?ActiveMQ的竞争者 ?
1.其他开?JMS provider(资料来自 java-source.net) :
jbossmq(jboss 4)
jboss messaging (jboss 5)
joram-4.3.21 2006-09-22
openjms-0.7.7-alpha-3.zip December 26, 2005
mantamq 官网暂时无法讉K
ubermq 官网暂时无法讉K
SomnifugiJMS 2005-7-27
开源的JMS Provider大部分都已经停止发展?剩下的几个都是找C东家,和某UJ2EE 服务器挂?
比如jboss mq 与jboss,joram与jonas(objectwebl织),ActiveMQ 与Geronimo(ASF APACHE基金l织),
而在q?个之_从网l底层来?只有ActiveMQ使用了NIO,单从q个角度来看ActiveMQ在性能上会?br /> 一定的优势
2.商业JMS provider
IBM WebSphere MQ
BEA WebLogic JMS
Oracle AQ
NonStop Server for Java Message Service(JMS)
Sun Java System Message Queue
Sonic jms
TIBCO Enterprise For JMS
iLinkMQ (国内)
现在的商业J2EE 应用服务器大部分都会有JMS Provider的实?毕竟应用服务器都已经p不薄,也不在乎
在里面送一个JMS Provider?当然q是有独立的比如IBM WebSphere MQ,Sonic JMS ,前者肯定是商用MQ
Q这个概念不仅仅是JMS Provier了,只能说JMS 只是它提供的一个应用)中间的巨无霸了?br />
从这Ҏ?ActiveMQ明显的竞争者ƈ不多,因ؓ它是作ؓ独立的开源JMS Provider出现?很容易被用于多种l构设计中,
使用ActiveMQ作ؓ默认JMS Provider的开源项目有ServiceMix,Geronimo.
(待箋)
P.S
Monday, February 5, 2007
Apache ActiveMQ graduates from the incubator
Apache ActiveMQ has now graduated to become a top level project (TLP) at Apache! Its new site is now hosted at http://activemq.apache.org/. Many thanks to all those in the Incubator and ActiveMQ communities for making this happen!
RewriteLog "logs/rewrite.log"
RewriteLogLevel 3
关键字段:
RewriteCond 表示如果条g满则用下面的Rewriterule
Rewriterule 是采用具体的正则表辑ּ来匹配?br /> Rewriterule 后面q可以带有参?br />
见apache参?br /> http://httpd.apache.org/docs/2.2/mod/mod_rewrite.html
chain|C
' (chained with next rule).www
'' part, inside a per-directory rule set, when you let an external redirect happen (where the ``.www
'' part should not occur!).
cookie|CO=
NAME:VAL:domain[:lifetime[:path]]' (set cookie)env|E=
VAR:VAL' (set environment variable)$N
and %N
) which will be expanded. You can use this flag more than once, to set more than one variable. The variables can later be dereferenced in many situations, most commonly from within XSSI (via <!--#echo var="VAR"-->
) or CGI ($ENV{'VAR'}
). You can also dereference the variable in a later RewriteCond pattern, using %{ENV:VAR}
. Use this to strip information from URLs, while maintaining a record of that information.
forbidden|F
' (force URL to be forbidden)gone|G
' (force URL to be gone)handler|H
=Content-handler' (force Content handler)mod_alias
directive ScriptAlias
, which internally forces all files inside the mapped directory to have a handler of ``cgi-script
''.
last|L
' (last rule)last
command or the break
command in C. Use this flag to prevent the currently rewritten URL from being rewritten further by following rules. For example, use it to rewrite the root-path URL ('/
') to a real one, e.g., '/e/www/
'.
next|N
' (next round)next
command or the continue
command in C. Use this flag to restart the rewriting process - to immediately go to the top of the loop.nocase|NC
' (no case)noescape|NE
' (no URI escaping of output)RewriteRule /foo/(.*) /bar?arg=P1\%3d$1 [R,NE]
/foo/zed
' into a safe request for '/bar?arg=P1=zed
'.
nosubreq|NS
' (not for internal sub-requests)mod_include
tries to find out information about possible directory default files (index.xxx
files). On sub-requests it is not always useful, and can even cause errors, if the complete set of rules are applied. Use this flag to exclude some rules.proxy|P
' (force proxy)http://
hostname) which can be handled by the Apache proxy module. If not, you will get an error from the proxy module. Use this flag to achieve a more powerful implementation of the ProxyPass directive, to map remote content into the namespace of the local server.
Note: mod_proxy
must be enabled in order to use this flag.
passthrough|PT
' (pass through to next handler)uri
field of the internal request_rec
structure to the value of the filename
field. This flag is just a hack to enable post-processing of the output of RewriteRule
directives, using Alias
, ScriptAlias
, Redirect
, and other directives from various URI-to-filename translators. For example, to rewrite /abc
to /def
using mod_rewrite
, and then /def
to /ghi
using mod_alias
:
RewriteRule ^/abc(.*) /def$1 [PT]
Alias /def /ghi
PT
flag, mod_rewrite
will rewrite uri=/abc/...
to filename=/def/...
as a full API-compliant URI-to-filename translator should do. Then mod_alias
will try to do a URI-to-filename transition, which will fail.
Note: You must use this flag if you want to mix directives from different modules which allow URL-to-filename translators. The typical example is the use of mod_alias
and mod_rewrite
.
qsappend|QSA
' (query string append)redirect|R
[=code]' (force redirect)http://thishost[:thisport]/
(which makes the new URL a URI) to force a external redirection. If no code is given, a HTTP response of 302 (MOVED TEMPORARILY) will be returned. If you want to use other response codes in the range 300-400, simply specify the appropriate number or use one of the following symbolic names: temp
(default), permanent
, seeother
. Use this for rules to canonicalize the URL and return it to the client - to translate ``/~
'' into ``/u/
'', or to always append a slash to /u/
user, etc.http://thishost[:thisport]/
to the URL, and rewriting will continue. Usually, you will want to stop rewriting at this point, and redirect immediately. To stop rewriting, you should add the 'L' flag.
skip|S
=num' (skip next rule(s))skip=N
, where N is the number of rules in the else-clause. (This is not the same as the 'chain|C' flag!)
type|T
=MIME-type' (force MIME type).php
files to be displayed by mod_php
if they are called with the .phps
extension:
RewriteRule ^(.+\.php)s$ $1 [T=application/x-httpd-php-source]
会在next,或者remove的时候检查当前集合是否会在修改状?如果是的?br />׃抛出 ConcurrentModificationException,而他自己remove则是使用了同步的Ҏ
而且同步了modCount;expectedModCount;
public T next() {
if (modCount != expectedModCount)
throw new ConcurrentModificationException();
return nextElement();
}
public void remove() {
if (!iterator)
throw new UnsupportedOperationException();
if (lastReturned == null)
throw new IllegalStateException("Hashtable Enumerator");
if (modCount != expectedModCount)
throw new ConcurrentModificationException();
synchronized(Hashtable.this) {
Entry[] tab = Hashtable.this.table;
int index = (lastReturned.hash & 0x7FFFFFFF) % tab.length;
for (Entry<K,V> e = tab[index], prev = null; e != null;
prev = e, e = e.next) {
if (e == lastReturned) {
modCount++;
expectedModCount++;
if (prev == null)
tab[index] = e.next;
else
prev.next = e.next;
count--;
lastReturned = null;
return;
}
}
throw new ConcurrentModificationException();
}
}
}
而自己在next的同?修改了这个集?D了这个错误的出现
If you are using the XSD-style for Spring 2.0 XML configuration and deploying to v.3 of Caucho's Resin application server, you will need to set some configuration options prior to startup so that an XSD-aware parser is available to Spring.
Please do read this resource
而resinl出来的参考就是他默认不是使用xerces和xalan作ؓxml和xslt的默认解析器
正是׃他默认不是采用以上作为xml,xstl的解析器,D了在resin下面 使用spring 2.0 新xsd配置方式会报错误
(主要是xml中的attribute和propertie 他取不到)
解决的方法就是让resin使用xerces和xalan作ؓxml和xslt的默认解析器
配置Q?/p>
在resin.conf?lt;web-app>或?lt;server>节点下添?/p>
<!-- xml -->
<system-property javax.xml.parsers.DocumentBuilderFactory=
"org.apache.xerces.jaxp.DocumentBuilderFactoryImpl"/>
<system-property javax.xml.parsers.SAXParserFactory=
"org.apache.xerces.jaxp.SAXParserFactoryImpl"/>
<!-- xslt -->
<system-property javax.xml.transform.TransformerFactory=
"org.apache.xalan.processor.TransformerFactoryImpl"/>
然后把相应的jar加入%RESIN_HOME%/lib 目录,q里需要说明的是我在测试activemq的时?/p>
加入xerces和xalan?他包其他class无法扑ֈ,感觉好像是默认的web-app目录下的jar无效?我暂时直接加入系lclasspath解决?/p>
q点不知道是不是我自qq_问题?/p>
l过试 resin 3.0.22+spring 2.0+activemq xsd配置方式ok?
ps. ^.^ 以前的resin下面目没有?.0配置,自己也学习到了新东西
google到的其他人同L问题描述
http://www.mail-archive.com/user@struts.apache.org/msg51847.html
我自q配置
struts-config-action.xml中配|?br />
q行所有跟q个form有关的页面都会出?
[ValidatorResources]2006-12-10 00:07:23 WARN : Form 'dynamicForm' not found for locale 'zh_CN'
我即使在messageResource_zh_CN.propertiesd了对应的key/name也不?
解决Ҏ,参考其他帖?我首先升Ustrut ?.3.x,commons-validator也升U到1.3.0
然后
在validation-user.xml d一个formp?br />
不再有这?font color="#ff0033">WARN 了?/font>
FAQ:
Error: Expected fromat '3' of repository;found format '5'
use "--pre-1.4-compatible", default format is "5" !!
Integrate Guide:
I use other complie svn module for apache 2.2.3 ,
Step1:
copy *.dll to %APACHE_HOME%\bin
copy *.so to %APACHE_HOME%\modules
Step2:
edit %APACHE_HOME%\conf\httpd.conf
find:
#LoadModule dav_module modules\mod_dav.so
#LoadModule dav_fs_module modules\mod_dav_fs.so
change: "#" to ""
LoadModule dav_module modules\mod_dav.so
LoadModule dav_fs_module modules\mod_dav_fs.so
and add SVN Module:
#SVN
LoadModule dav_svn_module modules\mod_dav_svn.so
LoadModule authz_svn_module modules\mod_authz_svn.so
Step3:
config SVN auth,add httpd.conf
use apache basic auth,gen password file
%APACHE_HOME%\bin\htpasswd -cm D:/server/webservice/clear/Apache2.2/svn-auth/svn-auth-file harry
<IfModule dav_svn_module>
<Location /svn>
DAV svn
SVNParentPath D:/SubversionRoot
AuthTypeBasic
AuthName "Subversion Repository"
AuthUserFile D:/server/webservice/clear/Apache2.2/svn-auth/svn-auth-file
Require valid-user
</Location>
</IfModule>
主要是svn官方的win binary不支持apache 2.2的新module调用?br />
也就是在IBatis里面配置一个statment,L行多个查?充分利用了map映射的特?
L行多个查询?/p>
比如
select * from myexample
select * from mywork
使用"*" 而且没有用resultClass 指定q回
但是在默认配|下,在用的时候的时?br />
2ơ以上传入不同的$dbName$,$tabeName$ 调用q个useAutoResultMapExample,
p报java.sql.SQLException: Invalid column name错误
因ؓiBatis自己?AutoResultMap的cache,管你传入的$tableName$不同Q但是他L
用第一个徏立的AutoResultMap的cached配以后的$tableName$当然有错误了
解决Ҏ: 使用多个statment或者?remapResults="true" (Z效率他默认的是false)
以上׃效率问题,q是采用多个statement 映射C同的model上面?不徏议生产系l也q么使用?/font>