In the Java field, it is very common to integrate a product into the application server, and it is more common to integrate the message middleware into the application server.
Currently, open-source application servers are widely used in Geronimo and JBoss. The default JMS provider of Geronimo is activemq, while the default JMS provider of JBoss application server is jbossmq. Integrating activemq into JBoss is a common requirement. If you need to integrate activemq into JBoss, please read the following content carefully. The integration method described in this article is applicable to Windows, Solaris, and UNIX platforms.
1. environment required for Integration
Sun Java jdk1.5 +
RedHat JBoss-4.0.5.GA +
Apache apache-activemq-4.1.1.zip
Note:
1. JDK must be of version 1.5 or later. If JDK is of version 1.4 or earlier, an exception is thrown in the console, prompting that some classes cannot be found.
2.apache-activemq-4.1.1.zip is a compressed package downloaded from the Apache website and should be decompressed first. Find activemq-rar-4.1.1.rar in the unzipped/apache-activemq-4.1.1/lib/optionalfolder, which is the package we use for integration with jbossmq.
3. Ensure that JBoss can be started correctly before activemq is integrated into JBoss.
II. Specific integration steps
1. Install jdk1.5
Install jdk1.5 and ensure that it runs correctly.
2. Install the JBoss Application Server
Install the JBoss application server and make it run properly before activemq is integrated.
Run the following command to start the JBoss Server:
$ Jboss-4.0.5.GA CD
$./Bin/run. Sh-C default
After JBoss is started normally, the console prints the following information:
========================================================== ======================================
JBoss Bootstrap Environment
Jboss_home:/opt/jboss-4.0.5.GA
Java: Java
Java_opts:-server-xms128m-xmx512m-dsun. RMI. DGC. Client. gcinterval = 3600000-dsun. RMI. DGC. server. gcinterval = 3600000-dprogram. Name = run. Sh
Classpath:/opt/jboss-4.0.5.GA/bin/run. jar:/lib/tools. Jar
========================================================== ======================================
15:34:47, 999 info [server] Starting JBoss (MX microkernel )...
15:34:48, 001 info [server] Release ID: JBoss [Zion] 4.0.5.ga (Build: cvstag = jboss_4_0_4_ga date = 200605151000)
15:34:48, 004 info [server] Home dir:/opt/jboss-4.0.5.GA
15:34:48, 005 info [server] Home URL: file:/opt/jboss-4.0.5.GA/
15:34:48, 007 info [server] patch URL: NULL
15:34:48, 007 info [server] server name: Default
15:34:48, 007 info [server] server home dir:/opt/jboss-4.0.5.GA/Server/Default
15:34:48, 011 info [server] server home URL: file:/opt/jboss-4.0.5.GA/Server/default/
15:34:48, 012 info [server] server log dir:/opt/jboss-4.0.5.GA/Server/default/log
15:34:48, 017 info [server] server temp dir:/opt/jboss-4.0.5.GA/Server/default/tmp
15:34:48, 022 info [server] root deployment filename: jboss-service.xml
...
15:35:17, 360 info [server] JBoss (MX microkernel) [4.0.5.ga (Build: cvstag = jboss_4_0_4_ga date = 200605151000)] started in 22 s: 238 Ms
3. Integrate activemq
3.1 decompress activemq-rar-4.1.1.rar
Extract activemq-rar-4.1.1.rarto the folder activemq-ra.rar (Note: activemq-ra.raris under the folder name. The activemq-ra.rar folder contains the following content:
META-INF
Activeio-core-3.0.0-incubator.jar
Activemq-core-4.1.1.jar
Activemq-ra-4.1.1.jar
Backport-util-concurrent-2.1.jar
Broker-config.xml
Commons-logging-1.0.3.jar
Derby-10.1.1.0.jar
Geronimo-j2ee-management_1.0_spec-1.0.jar
Log4j-1.2.12.jar
Spring-2.0.jar
Xbean-spring-2.8.jar
Copy the activemq-ra.rar folder to the jboss-4.0.5.GA/Server/default/deploy/directory of the JBoss server.
3.2 modify the META-INF/ra. xml file in the activemq-ra.rar File
Modify the META-INF/ra. xml file in the activemq-ra.rar file as follows:
Initial Configuration:
<! -- Note disable the following property if you do not wish to deploy an embedded broker -->
<Config-property>
<Description>
......
</Description>
<Config-property-Name> brokerxmlconfig </config-property-Name>
<Config-property-type> JAVA. Lang. String </config-property-type>
<Config-property-value> </config-property-value>
<! --
<Config-property-value> xbean: broker-config.xml </config-property-value>
-->
</Config-property>
Modified Configuration:
<! -- Note disable the following property if you do not wish to deploy an embedded broker -->
<Config-property>
<Description>
......
</Description>
<Config-property-Name> brokerxmlconfig </config-property-Name>
<Config-property-type> JAVA. Lang. String </config-property-type>
<! -- Config-property-value> </config-property-Value -->
<Config-property-value> xbean: broker-config.xml </config-property-value>
</Config-property>
By modifying the <config-property> setting of the RA. xml file, let jbossuse the broker-config.xml under the activemq-ra.rar folder as the default configuration file to configure activemq
3.3 modify borker-config.xml under activemq-ra.rar folder
The borker-config.xml is modified as follows:
Initial Configuration:
<Beans xmlns = "http://activemq.org/config/1.0">
<Broker usejmx = "true">
Modified Configuration:
<Beans>
<Broker usejmx = "true" xmlns = "http://activemq.org/config/1.0">
3.4 copy the xbean-spring-2.8.jar in the activemq-ra.rar folder to the jboss-4.0.5.GA/Server/default/lib directory of the JBoss Server
3.5 write activemq-ds.xml files, placed in the jboss-4.0.5.GA/Server/default/depoly/directory of the JBoss Application Server
The activemq-ds.xml code is as follows:
<? XML version = "1.0" encoding = "UTF-8"?>
<! Doctype connection-factories
Public "-// JBoss // DTD JBoss JCA config 1.5 // en"
Http://www.jboss.org/j2ee/dtd/jboss-ds_1_5.dtd>
<Connection-factories>
<TX-connection-factory>
<JNDI-Name> activemq/queueconnectionfactory </JNDI-Name>
<XA-transaction/>
<Track-connection-by-TX/>
<Rar-Name> activemq-ra.rar </RAR-Name>
<Connection-definition> javax. JMS. queueconnectionfactory </connection-definition>
<Serverurl> TCP: // localhost: 61616 </serverurl>
<Min-pool-size> 1 </min-pool-size>
<Max-pool-size> 200 </max-pool-size>
<Blocking-timeout-millis> 30000 </blocking-timeout-millis>
<Idle-timeout-minutes> 3 </idle-timeout-minutes>
</TX-connection-factory>
<TX-connection-factory>
<JNDI-Name> activemq/topicconnectionfactory </JNDI-Name>
<XA-transaction/>
<Track-connection-by-TX/>
<Rar-Name> activemq-ra.rar </RAR-Name>
<Connection-definition> javax. JMS. topicconnectionfactory </connection-definition>
<Serverurl> TCP: // localhost: 61616 </serverurl>
<Min-pool-size> 1 </min-pool-size>
<Max-pool-size> 200 </max-pool-size>
<Blocking-timeout-millis> 30000 </blocking-timeout-millis>
<Idle-timeout-minutes> 3 </idle-timeout-minutes>
</TX-connection-factory>
<Mbean code = "org. JBoss. Resource. Deployment. adminobject" name = "activemq. queue: Name = outboundqueue">
<Attribute name = "jndiname"> activemq/queue/outbound </attribute>
<Depends optional-Attribute-name = "rarname"> JBoss. JCA: service‑rardeployment,name='activemq-ra.rar & apos; </depends>
<Attribute name = "type"> javax. JMS. Queue </attribute>
<Attribute name = "properties"> physicalname = queue. Outbound </attribute>
</Mbean>
<Mbean code = "org. JBoss. Resource. Deployment. adminobject" name = "activemq. Topic: Name = inboundtopic">
<Attribute name = "jndiname"> activemq/topic/inbound </attribute>
<Depends optional-Attribute-name = "rarname"> JBoss. JCA: service‑rardeployment,name='activemq-ra.rar & apos; </depends>
<Attribute name = "type"> javax. JMS. Topic </attribute>
<Attribute name = "properties"> physicalname = topic. Inbound </attribute>
</Mbean>
</Connection-factories>
3. Restart JBoss to check whether the configuration is successful.
Restart JBoss and you will see the following information in the console:
========================================================== ======================================
JBoss Bootstrap Environment
Jboss_home:/opt/JBoss
Java: Java
Java_opts:-server-xms128m-xmx512m-dsun. RMI. DGC. Client. gcinterval = 3600000-dsun. RMI. DGC. server. gcinterval = 3600000-dprogram. Name = run. Sh
Classpath:/opt/JBoss/bin/run. jar:/lib/tools. Jar
========================================================== ======================================
22:55:48, 686 info [server] Starting JBoss (MX microkernel )...
22:55:48, 688 info [server] Release ID: JBoss [Zion] 4.0.5.ga (Build: cvstag = jboss_4_0_5_ga date = 200605151000)
22:55:48, 690 info [server] Home dir:/opt/jboss-4.0.5.GA
22:55:48, 692 info [server] Home URL: file:/opt/jboss-4.0.5.GA/
22:55:48, 695 info [server] patch URL: NULL
22:55:48, 697 info [server] server name: Default
22:55:48, 698 info [server] server home dir:/opt/jboss-4.0.5.GA/Server/Default
22:55:48, 701 info [server] server home URL: file:/opt/jboss-4.0.5.GA/Server/default/
22:55:48, 702 info [server] server log dir:/opt/jboss-4.0.5.GA/Server/default/log
22:55:48, 704 info [server] server temp dir:/opt/jboss-4.0.5.GA/Server/default/tmp
22:55:48, 706 info [server] root deployment filename: jboss-service.xml
22:55:49, 092 info [serverinfo] Java version: 1.5.0 _ 06, Apple Computer, Inc.
22:55:49, 101 info [serverinfo] Java VM: Java hotspot (TM) server VM 1.5.0 _ 06-64, "Apple Computer, Inc ."
22:55:49, 102 info [serverinfo] OS-system: Mac OS X 10.4.8, i386
22:55:49, 803 info [server] Core System initialized.
22:55:53, 379 info [WebService] using RMI server codebase: http: // rattlesnake: 8083/
22:55:53, 400 info [log4jservice $ urlwatchtimertask] refreshing ing from URL: Resource: log4j. xml
22:55:54, 034 info [namingservice] JNDI Bootstrap jnp =/0.0.0.0: 1099, RMI =/0.0.0.0: 1098, backlog = 50, no client socketfactory, server socketfactory = Class
Org.jboss.net. sockets. defaultsocketfactory
22:55:58, 475 info [embedded] Catalina naming disabled
22:55:58, 566 info [clusterrulesetfactory] unable to find a cluster rule set in the classpath. will load the default rule set.
22:55:58, 569 info [clusterrulesetfactory] unable to find a cluster rule set in the classpath. will load the default rule set.
22:55:59, 110 info [http11baseprotocol] initializing coyote HTTP/1.1 on http-0.0.0.0-8080
22:55:59, 114 info [Catalina] initialization processed in 545 MS
22:55:59, 116 info [standardservice] Starting service JBoss. Web
22:55:59, 121 info [standardengine] Starting Servlet Engine: Apache Tomcat/5.5.17
22:55:59, 179 info [standardhost] XML validation disabled
22:55:59, 221 info [Catalina] server startup in 105 MS
22:55:59, 600 info [tomcatdeployer] deploy, ctxpath =/invoker, warurl =.../deploy/http-invoker.sar/invoker. War/
22:55:59, 874 info [webapploader] dual registration of JNDI stream handler: factory already defined
22:56:00, 899 info [tomcatdeployer] deploy, ctxpath =/, warurl =.../deploy/jbossweb-tomcat55.sar/root. War/
22:56:01, 700 info [tomcatdeployer] deploy, ctxpath =/jbossws, warurl =.../tmp/deploy/tmp60528jbossws-exp.war/
22:56:01, 891 info [subscriptionmanager] Bound event dispatcher to Java:/eventdispatcher
22:56:02, 203 info [tomcatdeployer] deploy, ctxpath =/jbossmq-httpil, warurl =.../deploy/JMS/jbossmq-httpil.sar/jbossmq-httpil.war/
22:56:04, 546 info [tomcatdeployer] deploy, ctxpath =/Web-console, warurl =.../deploy/management/console-mgr.sar/web-console.war/
22:56:05, 690 info [mailservice] Mail Service bound to Java:/mail
22:56:07, 215 info [rardeployment] required license terms exist, view META-INF/ra. XML in.../deploy/activemq-ra.rar/
22:56:07, 452 info [xbeanxmlbeandefinitionreader] Loading XML bean definitions from class path resource [broker-config.xml]
22:56:07, 750 info [classpathxmlapplicationcontext] Bean Factory for application context [org. Apache. xbean. Spring. Context. classpathxmlapplicationcontext; hashcode = 13887543]:
Org. springframework. Beans. Factory. Support. defaultlistablebeanfactory defining
Beans [org. Apache. activemq. xbean. xbeanbrokerservice]; root of beanfactory hierarchy
22:56:07, 765 info [classpathxmlapplicationcontext] 1 beans defined in application context
[Org. Apache. xbean. Spring. Context. classpathxmlapplicationcontext; hashcode = 13887543]
22:56:07, 773 info [collectionfactory] JDK 1.4 + collections available
22:56:07, 778 info [classpathxmlapplicationcontext] unable to locate messagesource with name & apos; messagesource & apos;: Using default
[Org. springframework. Context. Support. delegatingmessagesource @ 5fee96]
22:56:07, 781 info [classpathxmlapplicationcontext] unable to locate applicationeventmulticaster with name & apos; applicationeventmulticaster & apos;: Using default
[Org. springframework. Context. event. simpleapplicationeventmulticaster @ 78c714]
22:56:07, 783 info [defalistlistablebeanfactory] pre-instantiating singletons in factory [org. springframework. Beans. Factory. Support. defaultlistablebeanfactory
Defining beans [org. Apache. activemq. xbean. xbeanbrokerservice]; root of beanfactory hierarchy]
22:56:08, 181 info [brokerservice] activemq 4.0.2 JMS Message Broker (Bruce. broker1) is starting
22:56:08, 181 info [brokerservice] for help or more information please see: http://incubator.apache.org/activemq/
22:56:09, 989 info [jdbcpersistenceadapter] database driver recognized: [apache_derby_embedded_jdbc_driver]
22:56:11, 026 info [journalpersistenceadapter] journal recovery started from: active journal: Using 5x20.0 megs at:/opt/jboss-4.0.5.GA/activemq-data/Journal
22:56:11, 169 info [journalpersistenceadapter] journal recovered: 0 message (s) in transactions recovered.
22:56:11, 489 info [transportserverthreadsupport] Listening for connections at: TCP: // rattlesnake: 61616
22:56:11, 491 warn [multicastdiscoveryagent] brokername not set
22:56:11, 519 info [transportctor] connector Bruce. broker1 started
22:56:11, 522 info [networkconnector] network connector bridge started
22:56:11, 522 info [brokerservice] activemq JMS Message Broker (Bruce. broker1, ID: rattlesnake-59052-1161060967859-1: 0) started
22:56:11, 556 info [rardeployment] required license terms exist, view META-INF/ra. XML in.../deploy/jboss-ha-local-jdbc.rar
22:56:11, 599 info [rardeployment] required license terms exist, view META-INF/ra. XML in.../deploy/jboss-ha-xa-jdbc.rar
22:56:11, 623 info [rardeployment] required license terms exist, view META-INF/ra. XML in.../deploy/jboss-local-jdbc.rar
22:56:11, 647 info [rardeployment] required license terms exist, view META-INF/ra. XML in.../deploy/jboss-xa-jdbc.rar
22:56:11, 737 info [rardeployment] required license terms exist, view META-INF/ra. XML in.../deploy/JMS/jms-ra.rar
22:56:11, 847 info [rardeployment] required license terms exist, view META-INF/ra. XML in.../deploy/mail-ra.rar
22:56:12, 251 info [connectionfactorybindingservice] bound connectionmanager & apos; JBoss. JCA: service = connectionfactorybinding, name = activemq/queueconnectionfactory & apos;
JNDI name & apos; Java: activemq/queueconnectionfactory & apos;
22:56:12, 258 info [connectionfactorybindingservice] bound connectionmanager & apos; JBoss. JCA: service = connectionfactorybinding, name = activemq/topicconnectionfactory & apos;
JNDI name & apos; Java: activemq/topicconnectionfactory & apos;
22:56:12, 265 info [adminobject] bound admin object & apos; org. Apache. activemq. Command. activemqqueue & apos; at & apos; activemq/queue/outbound & apos;
22:56:12, 330 info [adminobject] bound admin object & apos; org. Apache. activemq. Command. activemqtopic & apos; at & apos; activemq/topic/Inbound & apos;
22:56:13, 246 info [connectionfactorybindingservice] bound connectionmanager & apos; JBoss. JCA: service = performancebinding, name = defaultds & apos; To JNDI name & apos; Java: defaultds & apos;
22:56:13, 842 info [a] bound to JNDI name: queue/
22:56:13, 845 info [B] bound to JNDI name: queue/B
22:56:13, 846 info [c] bound to JNDI name: queue/C
22:56:13, 848 info [d] bound to JNDI name: queue/d
22:56:13, 850 info [Ex] bound to JNDI name: queue/ex
22:56:13, 876 info [testtopic] bound to JNDI name: Topic/testtopic
22:56:13, 879 info [securedtopic] bound to JNDI name: Topic/securedtopic
22:56:13, 880 info [testdurabletopic] bound to JNDI name: Topic/testdurabletopic
22:56:13, 883 info [testqueue] bound to JNDI name: queue/testqueue
22:56:13, 994 info [uilserverilservice] jbossmq UIL service available at:/0.0.0.0: 8093
22:56:14, 055 info [dlq] bound to JNDI name: queue/dlq
22:56:14, 375 info [connectionfactorybindingservice] bound connectionmanager & apos; JBoss. JCA: service = connectionfactorybinding, name = jmsxa & apos; To JNDI name & apos; Java: jmsxa & apos;
22:56:14, 525 info [tomcatdeployer] deploy, ctxpath =/JMX-console, warurl =.../deploy/jmx-console.war/
22:56:14, 991 info [http11baseprotocol] Starting coyote HTTP/1.1 on http-0.0.0.0-8080
22:56:15, 071 info [channelsocket] JK: ajp13 listening on/0.0.0.0: 8009
22:56:15, 082 info [jkmain] JK running id = 0 time = 0/25 Config = NULL
22:56:15, 108 info [server] JBoss (MX microkernel) [4.0.5.ga (Build: cvstag = jboss_4_0_5_ga date = 200605151000)] started in 26 S: 398 Ms
If you see the above Code on the JBoss console, activemq has been successfully integrated into JBoss.
You can use your own JMS test code to test the Integrated Application Server. The specific test code will be provided in the following article.
References:
[1] integrating Apache activemq with JBoss
[2] JBoss Integration
[3] activemq Practices (3) activemq 4_x + JBoss 4_x Integration