您的位置:首页 > 其它

异步消息总线hornetq学习-01基于maven的客户端程序框架搭建

2012-10-13 11:05 731 查看
hornetq是一个高性能的,支持集群配置的异步消息系统,完全支持jms,项目中使用hornetq作为异步消息服务器来使用,靠jms来进行系统间消息传递

项目中使用的hornetq的版本是2.3.0.Final,该软件的安装非常简单,直接解压即可,运行bin目录中的run.sh脚本启动服务(默认是非集群配置,standalong模式)

因为项目中使用maven作为项目管理工具,而hornetq默认带的example都是以ant作为构建工具的,因此,在找hornetq的客户端依赖时花了些时间,记录以下便于后期查找

根据hornetq的文档说明,其设计非常优雅,很少依赖第三方的其他组件,因此客户端的依赖也只有一下几个

hornetq-core-client -这个是client的核心

hornetq-jms-client -如果我们打算用hornetq的jms消息(hornetq中jms不是必须的组件)

netty-类似nio的东东,hornetq利用该机制分别装客户端与网络间的复杂操作,并且有很高的性能

spring-xxx,这个很容易理解,就是spring对jms的封装模板类

看一下一个完整的maven pom文件的定义

<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> <modelVersion>4.0.0</modelVersion>

<groupId>com.crazycoder2010</groupId>
<artifactId>hornetq</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>jar</packaging>

<name>hornetq</name>
<url>http://maven.apache.org</url>

<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<spring.version>3.2.4.RELEASE</spring.version>
</properties>

<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.11</version>
<scope>test</scope>
</dependency>
<!-- jnp-client包只有在通过jndi方式连接hornetq时候添加 -->
<dependency>
<groupId>jboss</groupId>
<artifactId>jnp-client</artifactId>
<version>4.2.2.GA</version>
</dependency>
<dependency>
<groupId>org.hornetq</groupId>
<artifactId>hornetq-jms-client</artifactId>
<version>2.3.0.Final</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-context</artifactId>
<version>${spring.version}</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-jms</artifactId>
<version>${spring.version}</version>
</dependency>
</dependencies>

<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.1</version>
<configuration>
<source>1.7</source>
<target>1.7</target>
<encoding>UTF-8</encoding>
</configuration>
</plugin>
</plugins>
</build>
</project>


这样一个项目的结构就搭建起来了,如图在eclipse中可以看到项目中添加的各个jar包

内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: 
相关文章推荐