- 浏览: 1589114 次
- 性别:
- 来自: 上海
文章分类
- 全部博客 (289)
- java 语法基础 (51)
- spring (8)
- mvc struct /Ant --build.xml (8)
- SOA (0)
- oracle 9i/10g (23)
- sql server 2000-2005 (3)
- 数据库基础知识 (6)
- 设计模式与软件架构 (10)
- Hibernate 持久化 (9)
- J2SE/J2EE/J2ME/AJAX 技术 (8)
- JSF 技术 (3)
- JAVA 图形化 (0)
- JMS (40)
- Eclipse 3.2 IDE 开发技巧 (13)
- 项目处理方法集合 (2)
- html/jsp/javascript (2)
- Unix/Linux (9)
- j2me/ARM/windriver/嵌入式 (4)
- 电信科学 (8)
- jsp (1)
- c/c++ (1)
- LZW压缩算法(java) (2)
- Android (77)
- 版本管理git/svn (2)
最新评论
-
huihai:
有demo吗?
NamingStrategy实现动态表名映射 -
cangbaotu:
推荐给大家一些有用的爬虫源码:https://github.c ...
网络爬虫(源代码参考) -
tuspark:
除了.classpath文件以外,.project文件也应该了 ...
Eclipse .classpath文件浅谈 -
tuspark:
造成eclipse自动关闭的原因有很多,这里有很多介绍:ecl ...
eclipse 自动关闭 解决方案 -
DEMONU:
网上都是这些,这种文章。。。
ActiveMQ中的消息持久性
package askyaya.entity;
import java.io.Serializable;
import org.apache.commons.lang.builder.EqualsBuilder;
import org.apache.commons.lang.builder.HashCodeBuilder;
import org.apache.commons.lang.builder.ReflectionToStringBuilder;
import org.apache.commons.lang.builder.ToStringBuilder;
public class BaseEntity implements Serializable {
/**
public String toString() {
return ReflectionToStringBuilder.toString(this);
}
public boolean equals(Object other) {
if ( (this == other ) ) return true;
return EqualsBuilder.reflectionEquals(this, other);
}
public int hashCode() {
return HashCodeBuilder.reflectionHashCode(this);
}
}
----------------------------
定义bean
package askyaya.entity;
import java.util.Date;
public class VisitStatInfoBean extends BaseEntity {
/**
*
*/
private static final long serialVersionUID = 1L;
String visitor_ip;
String server_ip;
String page_url;
String parameter;
String Referer_page;
int Visitor_type;
int server_id;
int column_id;
int page_id;
int Visit_count;
int User_id;
int Product_id;
int Seller_id;
Date info_date;
public Date getInfo_date() {
return info_date;
}
public void setInfo_date(Date info_date) {
this.info_date = info_date;
}
public int getColumn_id() {
return column_id;
}
public void setColumn_id(int column_id) {
this.column_id = column_id;
}
public int getPage_id() {
return page_id;
}
public void setPage_id(int page_id) {
this.page_id = page_id;
}
public String getPage_url() {
return page_url;
}
public void setParameter(String parameter) {
this.parameter = parameter;
}
public String getParameter() {
return parameter;
}
public void setPage_url(String parameter) {
this.parameter = parameter;
}
public int getProduct_id() {
return Product_id;
}
public void setProduct_id(int product_id) {
Product_id = product_id;
}
public String getReferer_page() {
return Referer_page;
}
public void setReferer_page(String referer_page) {
Referer_page = referer_page;
}
public int getSeller_id() {
return Seller_id;
}
public void setSeller_id(int seller_id) {
Seller_id = seller_id;
}
public int getServer_id() {
return server_id;
}
public void setServer_id(int server_id) {
this.server_id = server_id;
}
public String getServer_ip() {
return server_ip;
}
public void setServer_ip(String server_ip) {
this.server_ip = server_ip;
}
public int getUser_id() {
return User_id;
}
public void setUser_id(int user_id) {
User_id = user_id;
}
public int getVisit_count() {
return Visit_count;
}
public void setVisit_count(int visit_count) {
Visit_count = visit_count;
}
public String getVisitor_ip() {
return visitor_ip;
}
public void setVisitor_ip(String visitor_ip) {
this.visitor_ip = visitor_ip;
}
public int getVisitor_type() {
return Visitor_type;
}
public void setVisitor_type(int visitor_type) {
Visitor_type = visitor_type;
}
@Override
public int hashCode() {
final int PRIME = 31;
int result = super.hashCode();
result = PRIME * result + Product_id;
result = PRIME * result + ((Referer_page == null) ? 0 : Referer_page.hashCode());
result = PRIME * result + Seller_id;
result = PRIME * result + User_id;
result = PRIME * result + Visit_count;
result = PRIME * result + Visitor_type;
result = PRIME * result + column_id;
result = PRIME * result + ((info_date == null) ? 0 : info_date.hashCode());
result = PRIME * result + page_id;
result = PRIME * result + ((page_url == null) ? 0 : page_url.hashCode());
result = PRIME * result + server_id;
result = PRIME * result + ((server_ip == null) ? 0 : server_ip.hashCode());
result = PRIME * result + ((visitor_ip == null) ? 0 : visitor_ip.hashCode());
return result;
}
@Override
public boolean equals(Object obj) {
if (this == obj)
return true;
if (!super.equals(obj))
return false;
if (getClass() != obj.getClass())
return false;
final VisitStatInfoBean other = (VisitStatInfoBean) obj;
if (Product_id != other.Product_id)
return false;
if (Referer_page == null) {
if (other.Referer_page != null)
return false;
} else if (!Referer_page.equals(other.Referer_page))
return false;
if (Seller_id != other.Seller_id)
return false;
if (User_id != other.User_id)
return false;
if (Visit_count != other.Visit_count)
return false;
if (Visitor_type != other.Visitor_type)
return false;
if (column_id != other.column_id)
return false;
if (info_date == null) {
if (other.info_date != null)
return false;
} else if (!info_date.equals(other.info_date))
return false;
if (page_id != other.page_id)
return false;
if (page_url == null) {
if (other.page_url != null)
return false;
} else if (!page_url.equals(other.page_url))
return false;
if (server_id != other.server_id)
return false;
if (server_ip == null) {
if (other.server_ip != null)
return false;
} else if (!server_ip.equals(other.server_ip))
return false;
if (visitor_ip == null) {
if (other.visitor_ip != null)
return false;
} else if (!visitor_ip.equals(other.visitor_ip))
return false;
return true;
}
}
----------------------------
public static void recordVisit_JMS_Info(String visitor_ip,String server_ip,String page_url, String parameter, String Referer_page,
int Visitor_type,int server_id,int column_id,int page_id,int Visit_count,int User_id,
int Product_id,int Seller_id)
{
//从页面上record_visit.jsp 点击中,触发了这个方法
VisitStatInfoBean visitStatInfoBean=new VisitStatInfoBean();
visitStatInfoBean.setVisitor_ip(visitor_ip);
visitStatInfoBean.setServer_ip(server_ip);
visitStatInfoBean.setPage_url(page_url);
visitStatInfoBean.setReferer_page(Referer_page);
visitStatInfoBean.setVisitor_type(Visitor_type);
visitStatInfoBean.setServer_id(server_id);
visitStatInfoBean.setColumn_id(column_id);
visitStatInfoBean.setPage_id(page_id);
visitStatInfoBean.setVisit_count(Visit_count);
visitStatInfoBean.setUser_id(User_id);
visitStatInfoBean.setProduct_id(Product_id);
visitStatInfoBean.setSeller_id(Seller_id);
visitStatInfoBean.setInfo_date(new Date());
//VisitLogSender producer=new VisitLogSender();
try {
VisitLogSender visitLogSender = VisitLogSender.getVisitLogSender();
visitLogSender.sendMessage(visitStatInfoBean);
//producer.close();
} catch (Exception e) {
e.printStackTrace();
// TODO: handle exception
}
}
..............
关键点是下面的
VisitLogSender visitLogSender = VisitLogSender.getVisitLogSender(); //单例
visitLogSender.sendMessage(visitStatInfoBean); //发送消息
..........
------------------------
package askyaya.jms;
import javax.jms.Connection;
import javax.jms.DeliveryMode;
import javax.jms.Destination;
import javax.jms.JMSException;
import javax.jms.MessageProducer;
import javax.jms.ObjectMessage;
import javax.jms.Session;
import org.apache.activemq.ActiveMQConnectionFactory;
import askyaya.entity.VisitStatInfoBean;
import askyaya.visitlog.GetJmsUrl;
/**
* @author 作者 Administrator:金果
* @version 创建时间:
* 类说明:
*/
public class VisitLogSender {
private static String subject = "askyaya.visit.log";
private static Destination destination = null; //消息的目的地
private static Connection connection = null; //JMS 客户端到JMS Provider 的连接
private static Session session = null; //一个发送或接收消息的线程
private static MessageProducer producer = null; //由Session 对象创建的用来发送消息的对象
private static VisitLogSender visitLogSender = null;
public static VisitLogSender getVisitLogSender(){
if(visitLogSender == null){
visitLogSender = new VisitLogSender();
try{
visitLogSender.initialize();
}catch(Exception e)
{e.printStackTrace();}
}
return visitLogSender;
}
public void initialize() throws JMSException, Exception {
System.out.println("url----------->"+GetJmsUrl.getUrl());
ActiveMQConnectionFactory connectionFactory=new ActiveMQConnectionFactory("","",GetJmsUrl.getUrl());
connection = connectionFactory.createConnection();
connection.start();
session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE); //不用事务了,session以自动方式接收,通用性好
destination = session.createQueue(subject);
producer = session.createProducer(destination);
producer.setDeliveryMode(DeliveryMode.PERSISTENT); //以持久的方式到队列oracle 数据库
}
//发送消息
public void sendMessage(VisitStatInfoBean message) throws JMSException,Exception {
ObjectMessage msg=session.createObjectMessage();
msg.setObject(message);
System.out.println("Producer:->Sending askyaya_2007 message:"+message);
System.out.println("Producer:->Sending askyaya_2007 msg:"+msg);
producer.send(msg);
System.out.println("Producer:->askyaya_2007 Message sent complete!");
}
// 关闭连接
public void close() throws JMSException {
System.out.println("Producer:->Closing connection");
if (producer != null)
producer.close();
if (session != null)
session.close();
if (connection != null)
connection.close();
}
}
----------------------------------------------
开始收了啊
我是另外建了工程
package askyaya.jms;
import javax.jms.Connection;
import javax.jms.Destination;
import javax.jms.JMSException;
import javax.jms.Message;
import javax.jms.MessageConsumer;
import javax.jms.MessageListener;
import javax.jms.ObjectMessage;
import javax.jms.Session;
import org.apache.activemq.ActiveMQConnection;
import org.apache.activemq.ActiveMQConnectionFactory;
import askyaya.dao.VisitStatInfoDao;
import askyaya.entity.VisitStatInfoBean;
import askyaya.util.GetJmsUrl;
/**
* @author 作者 Administrator:jinguo
* @version 创建时间:2008-8-30 上午10:55:47
* 类说明:
*/
public class ReceiveVisitLog implements MessageListener{
// private String user =ActiveMQConnection.DEFAULT_USER;
// private String password=ActiveMQConnection.DEFAULT_PASSWORD;
// private String url=ActiveMQConnection.DEFAULT_BROKER_URL;
private static String subject = "askyaya.visit.log";
private static Destination destination = null;
private static Connection connection = null;
private static Session session = null;
private static MessageConsumer consumer = null;
// private MessageProducer replyProducer; //反馈信息
//连接connection,get session
private static ReceiveVisitLog receivevisitlog=null;
public static ReceiveVisitLog getReceiveVisitLog(){
if(receivevisitlog==null){
receivevisitlog=new ReceiveVisitLog();
try {
initialize();
} catch (Exception e) {
e.printStackTrace();
// TODO: handle exception
}
}
return receivevisitlog;
}
private static void initialize() throws JMSException{
GetJmsUrl url=new GetJmsUrl();
//ActiveMQConnectionFactory connectionFactory = new ActiveMQConnectionFactory(user,password,url);
System.out.println("url---M:"+url.getUrl());
ActiveMQConnectionFactory connectionFactory=new ActiveMQConnectionFactory("","",url.getUrl());
System.out.println("connect to tcp:192.168.0.245 ");
Connection connection=connectionFactory.createConnection();
connection.start();
session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
destination=session.createQueue(subject);
// Destination advisoryDestination = AdvisorySupport.getProducerAdvisoryTopic(destination)
consumer=session.createConsumer(destination);
}
// 消费消息
public void consumeMessage() throws JMSException,Exception {
//开始监听
// MessageListenerForOrgMsg msgListener=new MessageListenerForOrgMsg();
consumer.setMessageListener(this);
System.out.println("Consumer:->after listener message...");
//如果想要去想主动的去接受消息,起用下面的
//Message message=consumer.receiveNoWait();
//TextMessage message=(TextMessage)consumer.receive(1000);
}
// 消息处理函数(onMessage是个构造函数继承,consumerTool开始执行的时候,先要初始化它,然后才initialze())
//由 container 选择一个实例
public void onMessage(Message message){
try {
System.out.println("Consumer:->Begin receive message--->:"+message);
if(message!=null){
if(message instanceof ObjectMessage){
ObjectMessage objmsg=(ObjectMessage)message;
//从消息中提取对象,转化为bean对象
VisitStatInfoBean visitinfo=(VisitStatInfoBean)objmsg.getObject();
//隔离对数据库的直接访问,
VisitStatInfoDao vistdao=new VisitStatInfoDao();
//向数据库中插入消息
vistdao.insert(visitinfo);
System.out.println("Consumer:->after insert messagedb");
}
}
//消费消息中在onMessage()方法中接收producer发送过来的消息进行处理,并可以通过replyProducer反馈信息给producer
/*if(message.getJMSReplyTo()!=null){
replyProducer.send(message.getJMSReplyTo(),session.createTextMessage("Reply: "+message.getJMSMessageID()));
}*/
} catch (Exception e) {
e.printStackTrace();
}
}
// 关闭连接
public void close() throws JMSException {
System.out.println("Consumer:->Closing connection");
if (consumer != null)
consumer.close();
if (session != null)
session.close();
if (connection != null)
connection.close();
}
public static void main(String[] args) {
//取得接收信息
ReceiveVisitLog receiveVisitLog = ReceiveVisitLog.getReceiveVisitLog();
GetJmsUrl url=new GetJmsUrl();
//接收信息时间间隔
//int sleepTime = 30*1000;
int sleepTime=Integer.parseInt(url.getSleepTime());
while (true){
try {
System.out.println("睡眠" + sleepTime/1000 + "秒之后, 开始接收消息......");
receiveVisitLog.consumeMessage();
Thread.sleep(sleepTime);
System.out.println("接收消息完毕.");
} catch (Exception e) {
e.printStackTrace();
}
}
}
}
--------------------------------
为了方便大家 我把dao 方法也贴了出来
package askyaya.dao;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
import askyaya.entity.VisitStatInfoBean;
public class VisitStatInfoDao {
public void insert(VisitStatInfoBean vfBean)throws SQLException{
Connection ApplicationConn=askyaya.util.DBManager.getconn();
String strsql="insert into tbl_visit_stat_info(visitor_ip,server_id,server_ip,column_id,"
+ "page_id,page_url, parameter, Visit_count,User_id,Visitor_type,Product_id,Seller_id,"
+ "Info_date,visit_date,Referer_page) values(?,?,?,?,?,?,?,?,?,?,?,?,Sysdate,to_char(Sysdate,'yyyy-mm-dd'),?)";
PreparedStatement pstmt = null;
ApplicationConn.setAutoCommit(false);
try {
pstmt = ApplicationConn.prepareStatement(strsql);
//VisitStatInfoBean vfBean=new VisitStatInfoBean();
pstmt.setString(1,vfBean.getVisitor_ip());
pstmt.setInt(2, vfBean.getServer_id());
pstmt.setString(3,vfBean.getServer_ip());
pstmt.setInt(4,vfBean.getColumn_id());
pstmt.setInt(5,vfBean.getPage_id());
pstmt.setString(6,vfBean.getPage_url());
pstmt.setString(7,vfBean.getParameter());
pstmt.setInt(8, vfBean.getVisit_count());
pstmt.setInt(9,vfBean.getUser_id());
pstmt.setInt(10,vfBean.getVisitor_type());
pstmt.setInt(11,vfBean.getProduct_id());
pstmt.setInt(12,vfBean.getSeller_id());
pstmt.setString(13,vfBean.getReferer_page());
pstmt.executeUpdate();
ApplicationConn.commit();
// System.out.println("insert the tbl_visit_stat_info is end ");
} catch (SQLException sqle) {
int errcode = sqle.getErrorCode();
// System.err.println("aq.executeQuery: " + sqle.getMessage()+":;");
//违反唯一约束
if(errcode == 1){}
else{
// System.err.println("aq.executeQuery: " + sqle.getMessage()+":;");
}
ApplicationConn.rollback();
}finally {
try {
pstmt.close();
ApplicationConn.close();
} catch (Exception ex) {
ex.printStackTrace();
}
}
}
}
---------------------------------
得到地址的通用方法
package askyaya.util;
import java.io.InputStream;
import java.util.Properties;
public class GetJmsUrl {
private final static String strUrl=null;
private final static String sleeptime=null;
private final Properties props=new Properties();
private final String url="askyayaJmsConstant.properties";
public GetJmsUrl(){
}
public String getUrl(){
InputStream is=getClass().getResourceAsStream(url);
try {
if(strUrl==null){
props.load(is);
}
} catch (Exception e) {
System.err.println("Can not read the Properties file " + url);
}
String strUrl= props.getProperty("hostname");
return strUrl;
}
public String getSleepTime(){
InputStream is=getClass().getResourceAsStream(url);
try {
if(sleeptime==null){
props.load(is);
}
} catch (Exception e) {
e.printStackTrace();
// TODO: handle exception
}
String strSleepTime= props.getProperty("sleepTime");
return strSleepTime;
}
}
------------------------
askyayaJmsConstant.properties
设置如下:
hostname=tcp://192.168.0.245:61616?wireFormat.maxInactivityDuration=0
sleepTime=30000
---------------
我把服务器的activemq.xml 配置也贴出来把,很关键的哟,不懂可以问我.
<!--
Licensed to the Apache Software Foundation (ASF) under one or more
contributor license agreements. See the NOTICE file distributed with
this work for additional information regarding copyright ownership.
The ASF licenses this file to You under the Apache License, Version 2.0
(the "License"); you may not use this file except in compliance with
the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-->
<!-- START SNIPPET: example -->
<beans
xmlns="http://www.springframework.org/schema/beans"
xmlns:amq="http://activemq.apache.org/schema/core"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.0.xsd
http://activemq.apache.org/schema/core http://activemq.apache.org/schema/core/activemq-core.xsd
http://activemq.apache.org/camel/schema/spring http://activemq.apache.org/camel/schema/spring/camel-spring.xsd">
<!-- Allows us to use system properties as variables in this configuration file -->
<bean class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer"/>
<broker xmlns="http://activemq.apache.org/schema/core" brokerName="localhost" dataDirectory="${activemq.base}/data">
<!-- Destination specific policies using destination names or wildcards -->
<destinationPolicy>
<policyMap>
<policyEntries>
<policyEntry queue=">" memoryLimit="5mb"/>
<policyEntry topic=">" memoryLimit="5mb">
<dispatchPolicy>
<strictOrderDispatchPolicy/>
</dispatchPolicy>
<subscriptionRecoveryPolicy>
<lastImageSubscriptionRecoveryPolicy/>
</subscriptionRecoveryPolicy>
</policyEntry>
</policyEntries>
</policyMap>
</destinationPolicy>
<!-- Use the following to configure how ActiveMQ is exposed in JMX -->
<managementContext>
<managementContext createConnector="false"/>
</managementContext>
<!-- The store and forward broker networks ActiveMQ will listen to -->
<networkConnectors>
<!-- by default just auto discover the other brokers -->
<networkConnector name="default-nc" uri="multicast://default"/>
<!-- Example of a static configuration:
<networkConnector name="host1 and host2" uri="static://(tcp://host1:61616,tcp://host2:61616)"/>
-->
</networkConnectors>
<!--
<persistenceAdapter>
<amqPersistenceAdapter syncOnWrite="false" directory="${activemq.base}/data" maxFileLength="20 mb"/>
</persistenceAdapter>
-->
<!-- Use the following if you wish to configure the journal with JDBC -->
<!--
<persistenceAdapter>
<journaledJDBC dataDirectory="${activemq.base}/data" dataSource="#postgres-ds"/>
</persistenceAdapter>
-->
<!-- Or if you want to use pure JDBC without a journal -->
<persistenceAdapter>
<jdbcPersistenceAdapter dataSource="#oracle-ds"/>
</persistenceAdapter>
<!-- The maximum about of space the broker will use before slowing down producers -->
<systemUsage>
<systemUsage>
<memoryUsage>
<memoryUsage limit="20 mb"/>
</memoryUsage>
<storeUsage>
<storeUsage limit="1 gb" name="foo"/>
</storeUsage>
<tempUsage>
<tempUsage limit="100 mb"/>
</tempUsage>
</systemUsage>
</systemUsage>
<!-- The transport connectors ActiveMQ will listen to -->
<transportConnectors>
<transportConnector name="openwire" uri="tcp://192.168.0.245:61616?wireFormat.maxInactivityDuration=0" discoveryUri="multicast://default"/>
<transportConnector name="ssl" uri="ssl://192.168.0.245:61617"/>
<transportConnector name="stomp" uri="stomp://192.168.0.245:61613"/>
<transportConnector name="xmpp" uri="xmpp://192.168.0.245:61222"/>
</transportConnectors>
</broker>
<!--
** Lets deploy some Enterprise Integration Patterns inside the ActiveMQ Message Broker
** For more details see
**
** http://activemq.apache.org/enterprise-integration-patterns.html
-->
<camelContext id="camel" xmlns="http://activemq.apache.org/camel/schema/spring">
<!-- You can use a <package> element for each root package to search for Java routes -->
<package>org.foo.bar</package>
<!-- You can use Spring XML syntax to define the routes here using the <route> element -->
<route>
<from uri="activemq:example.A"/>
<to uri="activemq:example.B"/>
</route>
</camelContext>
<!-- Uncomment to create a command agent to respond to message based admin commands on the ActiveMQ.Agent topic -->
<!--
<commandAgent xmlns="http://activemq.apache.org/schema/core" brokerUrl="vm://localhost"/>
-->
<!-- An embedded servlet engine for serving up the Admin console -->
<jetty xmlns="http://mortbay.com/schemas/jetty/1.0">
<connectors>
<nioConnector port="8161"/>
</connectors>
<handlers>
<webAppContext contextPath="/admin" resourceBase="${activemq.base}/webapps/admin" logUrlOnStart="true"/>
<webAppContext contextPath="/demo" resourceBase="${activemq.base}/webapps/demo" logUrlOnStart="true"/>
<webAppContext contextPath="/fileserver" resourceBase="${activemq.base}/webapps/fileserver" logUrlOnStart="true"/>
</handlers>
</jetty>
<!-- This xbean configuration file supports all the standard spring xml configuration options -->
<!-- Postgres DataSource Sample Setup -->
<!--
<bean id="postgres-ds" class="org.postgresql.ds.PGPoolingDataSource">
<property name="serverName" value="localhost"/>
<property name="databaseName" value="activemq"/>
<property name="portNumber" value="0"/>
<property name="user" value="activemq"/>
<property name="password" value="activemq"/>
<property name="dataSourceName" value="postgres"/>
<property name="initialConnections" value="1"/>
<property name="maxConnections" value="10"/>
</bean>
-->
<!-- MySql DataSource Sample Setup -->
<!--
<bean id="mysql-ds" class="org.apache.commons.dbcp.BasicDataSource" destroy-method="close">
<property name="driverClassName" value="com.mysql.jdbc.Driver"/>
<property name="url" value="jdbc:mysql://localhost/activemq?relaxAutoCommit=true"/>
<property name="username" value="activemq"/>
<property name="password" value="activemq"/>
<property name="maxActive" value="200"/>
<property name="poolPreparedStatements" value="true"/>
</bean>
-->
<!-- Oracle DataSource Sample Setup -->
<bean id="oracle-ds" class="org.apache.commons.dbcp.BasicDataSource" destroy-method="close">
<property name="driverClassName" value="oracle.jdbc.driver.OracleDriver"/>
<property name="url" value="jdbc:oracle:thin:@192.168.0.245:1521:askyaya"/>
<property name="username" value="activemq"/>
<property name="password" value="activemq"/>
<property name="maxActive" value="200"/>
<property name="poolPreparedStatements" value="true"/>
</bean>
<!-- Embedded Derby DataSource Sample Setup -->
<!--
<bean id="derby-ds" class="org.apache.derby.jdbc.EmbeddedDataSource">
<property name="databaseName" value="derbydb"/>
<property name="createDatabase" value="create"/>
</bean>
-->
</beans>
<!-- END SNIPPET: example -->
----------------------
以上我用jdbc 来写的,速度非常快,也可以hibernate实现如果有大虾知道的话贴出来 ,
最后吗,有些人问我,什么样的人适合做程序员,告诉大家
就是突破能力一定要强,想锻炼这能力,多看看书哟.以上实现我只用一个星期就基本就解决了jms 大部分难点.
评论
<amqPersistenceAdapter syncOnWrite="false" directory="${activemq.base}/data" maxFileLength="20 mb"/>
中
${activemq.base}需要在哪里配置吗?还是只要启动activemq就有这个环境变量了?
http://localhost:8161/admin/能看到。
如果看到这个是否就是证明我的ActiveMQ已经启动成功!
恩。如果启动成功。我想问下。为什么
connection.start();
这步始终没有执行到。。请指教!
发表评论
-
activemq 重新连接的机制
2008-09-18 14:39 23220最近一个项目要用到ActiveMq,并且需要最大程度的保证消息 ... -
ActiveMQ stop inactivity read check
2008-09-17 16:01 10648You can do the following to fix ... -
WSAD环境下JMS异步通信全攻略 (3)
2008-09-11 14:18 32233.5 消息驱动的Bean 在前文讨论JMS消息接收处理逻 ... -
WSAD环境下JMS异步通信全攻略 (2)
2008-09-11 13:58 3771三、JMS P2P编程 在JMS P2P通信方式中,发送程 ... -
WSAD环境下JMS异步通信全攻略 (1)
2008-09-11 13:57 4711一、JMS基本概念 1.1 P2P通信 1.2 Pub ... -
topicpublisher (jms)
2008-09-10 18:55 2918目的地类型JNDI名字连接工厂类型Topic/Queuejav ... -
ProducerTool /MessageBroker /getConnectionFactoryF
2008-09-10 18:12 2473lib: jms1.1.jar activemq-all-5. ... -
activemq例子代码 发送BytesMessage消息
2008-09-10 13:55 18380import javax.jms.Connection; im ... -
ActiveMQ in Action(7)
2008-09-10 13:44 3948ActiveMQ in Action(7) 关键字 ... -
ActiveMQ in Action(6)
2008-09-10 13:43 3731ActiveMQ in Action(6) 关键字: acti ... -
ActiveMQ in Action(5)
2008-09-10 13:42 3924ActiveMQ in Action(5) 关键字: acti ... -
ActiveMQ in Action(4)
2008-09-10 13:40 3475ActiveMQ in Action(4) 关键字: acti ... -
ActiveMQ in Action(3)
2008-09-10 13:39 3675ActiveMQ in Action(3) 关键字: acti ... -
ActiveMQ in Action(2)
2008-09-10 13:38 4207ActiveMQ in Action(2) 关键字: acti ... -
ActiveMQ in Action(1)
2008-09-10 13:37 5825ActiveMQ in Action(1) 关键字: acti ... -
为ActiveMQ服务器添加简单验证机制
2008-09-09 23:48 4192为ActiveMQ服务器添加简单验证机制 关键字: Java, ... -
Sender/receiver 消息
2008-09-09 20:28 2123Sender:import java.io.BufferedR ... -
activema.xml 配置
2008-09-09 17:44 3810/***作者:andyao,email:andyaoy@gma ... -
JMX 与系统管理
2008-09-08 10:52 1861Java SE 6 新特性: JMX 与系统管理 ... -
ActiveMQ中的消息持久性
2008-09-05 12:24 3389ActiveMQ中的消息持久性 ActiveMQ很 ...
相关推荐
标题中的"activemq持久化jdbc所需jar包.zip"指的是Apache ActiveMQ消息中间件在使用JDBC(Java Database Connectivity)进行消息持久化时所需的库文件集合。ActiveMQ是一款开源、高性能、跨语言的企业级消息代理,它...
Apache ActiveMQ 是一个流行的开源消息代理,实现了Java消息服务(JMS)规范,用于在分布式环境中传递消息。JMS是一种标准接口,允许应用程序创建、发送、接收和读取消息,从而促进异步通信和解耦。在本文中,我们将...
总结来说,`activemq-store-jdbc-1.4.jar` 是 ActiveMQ 实现基于 JDBC 的消息持久化的关键组件,它允许用户利用关系数据库的强大功能来存储和检索消息。通过理解这个库的工作原理和配置,开发者可以更灵活地管理和...
具体改进内容通常可以在发布的变更日志中找到,但在这里我们主要关注其核心功能:通过JDBC接口与数据库进行交互,实现消息的持久化。 三、JDBC存储的优势 1. **数据一致性**:JDBC存储利用了数据库的事务特性,...
Java消息服务(Java Message Service,简称JMS)是Java平台中用于企业级应用间异步通信的一种标准API。它允许应用程序创建、发送、接收和读取消息,为分布式计算环境提供可靠的中间件服务。在JMS接收端,我们需要...
ActiveMQ是一款非常流行的开源消息中间件,它基于Java语言开发,并且遵循了Java消息服务(JMS)规范。ActiveMQ提供了丰富的特性,包括持久化消息存储、事务支持、集群等功能。在企业级应用中,ActiveMQ常常被用来实现...
7. Apache ActiveMQ:ActiveMQ是实现了JMS规范的开源消息中间件项目,它支持多种消息协议和传输协议,可以用于分布式系统中的消息传递和集成。它具有高性能、高可靠性和可扩展性,允许客户端在不共享同一个物理或...
ActiveMQ是业界广泛使用的开源消息代理,它遵循Java Message Service (JMS) 规范,提供高效、可靠的异步通信能力。 **Apache ActiveMQ** Apache ActiveMQ是一个强大的开源消息中间件,它允许应用程序之间通过消息...
3. **消息提供者实现**:每个JMS消息提供者(如ActiveMQ、Apache Qpid、IBM WebSphere MQ、Apache Kafka等)都有自己的实现库,用于实际与消息队列交互。例如,如果你使用ActiveMQ,你需要引入`activemq-client.jar`...
### ActiveMQ In Action翻译笔记-更新版...总结而言,**ActiveMQ**是一款功能强大且广泛使用的消息中间件,通过遵循JMS规范,为企业级应用提供了异步、可靠的消息传递机制,是构建高效、健壮分布式系统的重要组成部分。
Apache ActiveMQ是开源的、基于Java消息服务(JMS)的高级消息中间件,它在Linux和Unix系统上运行得尤为出色。ActiveMQ是Apache软件基金会的一个项目,它提供了多种协议支持,包括开放标准的AMQP、STOMP、MQTT以及...
Apache ActiveMQ是开源的、基于Java消息服务(JMS)的应用服务器,它允许应用程序通过消息传递进行异步通信。在Linux环境下部署和运行ActiveMQ,是企业级分布式系统中常见的一种选择,因为Linux提供了稳定、安全的...
ActiveMQ是Apache软件基金会开发的一个开源消息代理,它实现了Java消息服务(JMS)规范,允许应用程序之间进行异步通信。而JDK 1.6是Java编程语言的开发和运行环境,对于运行像ActiveMQ这样的Java应用至关重要。 ...
2. **全面的JMS规范实现**:ActiveMQ不仅支持JMS持久化和XA消息,还支持事务处理,确保消息传递的可靠性和一致性。 3. **与Spring框架的深度整合**:ActiveMQ可以无缝嵌入Spring框架的应用中,同时也支持Spring 2.0...
Apache ActiveMQ是业界广泛使用的开源消息中间件,它基于Java Message Service (JMS) 规范,提供高效、可靠的异步消息传递服务。在Linux环境下安装ActiveMQ是部署分布式系统和微服务架构的重要步骤,本篇文章将详细...
JMS提供者是实现JMS规范的具体软件,例如IBM WebSphere MQ、Apache ActiveMQ、Oracle Advanced Queuing等。这些提供商提供了与JMS API的接口,使得开发者能够使用统一的方式来操作消息。 ### 3. JMS API JMS API...
7. **JMS的实现**: JMS规范由多种实现提供,如Apache ActiveMQ、IBM WebSphere MQ、Oracle AQ等。这些实现都提供了JMS API的实现,使得开发者可以在不同的消息中间件上开发和部署JMS应用。 8. **JMS消息类型**: JMS...
- **Oracle Advanced Queuing (AQ)**:Oracle数据库内置的消息队列服务。 ### 结论 Java消息服务(JMS)作为一种重要的分布式通信技术,在现代软件架构中扮演着不可或缺的角色。通过理解其核心概念和应用场景,...