网创优客建站品牌官网
为成都网站建设公司企业提供高品质网站建设
热线:028-86922220
成都专业网站建设公司

定制建站费用3500元

符合中小企业对网站设计、功能常规化式的企业展示型网站建设

成都品牌网站建设

品牌网站建设费用6000元

本套餐主要针对企业品牌型网站、中高端设计、前端互动体验...

成都商城网站建设

商城网站建设费用8000元

商城网站建设因基本功能的需求不同费用上面也有很大的差别...

成都微信网站建设

手机微信网站建站3000元

手机微信网站开发、微信官网、微信商城网站...

建站知识

当前位置:首页 > 建站知识

mq补偿机制java代码 mq补偿实现最终一致性

MQ java源代码谁有?

IBM拿去卖钱的,不可能有源代码啊。我这有一些乱七八糟的相关文档,给你发过去,你看一下吧,不知道对你有没有用。

成都创新互联是一家集网站建设,六安企业网站建设,六安品牌网站建设,网站定制,六安网站建设报价,网络营销,网络优化,六安网站推广为一体的创新建站企业,帮助传统企业提升企业形象加强企业竞争力。可充分满足这一群体相比中小企业更为丰富、高端、多元的互联网需求。同时我们时刻保持专业、时尚、前沿,时刻以成就客户成长自我,坚持不断学习、思考、沉淀、净化自己,让我们为更多的企业打造出实用型网站。

PS:都是英文的,我也没看过。

我还有一些MB的文档,要就HI我。

求助java连接mq及mq配置

没借用框架的话,之前自己写了一个工具类,可以参考一下

需要一个连mysql的jar包,下一个就行

package com.cn.taxi.util;

import java.sql.Connection;

import java.sql.DriverManager;

import java.sql.PreparedStatement;

import java.sql.ResultSet;

import java.sql.SQLException;

import com.mysql.jdbc.Statement;

public class DBHelper {

public static final String url = "jdbc:mysql://127.0.0.1:3306/taxi";

public static final String name = "com.mysql.jdbc.Driver";

public static final String user = "root";

public static final String password = "123";

public static Connection getConn() {

Connection conn = null;

PreparedStatement pst = null;

try {

Class.forName(name);//指定连接类型

conn = DriverManager.getConnection(url, user, password);//获取连接

} catch (Exception e) {

e.printStackTrace();

}

return conn;

}

public static void close(Connection con,Statement st,ResultSet rs) {

if(con!=null)

{

try {

con.close();

} catch (SQLException e) {

// TODO Auto-generated catch block

e.printStackTrace();

}

}

if(st!=null)

{

try {

st.close();

} catch (SQLException e) {

// TODO Auto-generated catch block

e.printStackTrace();

}

}

if(rs!=null)

{

try {

rs.close();

} catch (SQLException e) {

// TODO Auto-generated catch block

e.printStackTrace();

}

}

}

}

用java代码如何设置activemq消息持久化到数据库中?

ActiveMQ持久化消息的二种方式;

1、持久化为文件

这个装ActiveMQ时默认就是这种,只要设置消息为持久化就可以了。涉及到的配置和代码有:

persistenceAdapter

kahaDB directory="${activemq.base}/data/kahadb"/

/persistenceAdapter

producer.Send(request, MsgDeliveryMode.Persistent, level, TimeSpan.MinValue);

2、持久化为MySql

首先需要把MySql的驱动放到ActiveMQ的Lib目录下,我用的文件名字是:mysql-connector-java-5.0.4-bin.jar

接下来修改配置文件

persistenceAdapter

jdbcPersistenceAdapter dataDirectory="${activemq.base}/data" dataSource="#derby-ds"/

/persistenceAdapter

在配置文件中的broker节点外增加

bean id="derby-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

从配置中可以看出数据库的名称是activemq,需要手动在MySql中增加这个库。

然后重新启动消息队列,会发现多了3张表

1:activemq_acks

2:activemq_lock

3:activemq_msgs

java 怎么样调用IBM MQ 或者通信问题

websphere mq : 用于传输信息 具有跨平台的功能。

1 安装websphere mq 并启动

2 websphere mq 建立 queue Manager (如:MQSI_SAMPLE_QM)

3 建立queue 类型选择 Local类型 的 (如lq )

3 建立channels 类型选择Server Connection (如BridgeChannel)

java 代码如下:

package test.mq;

import com.ibm.mq.*;

/*

* 成功的访问mq 的java 类

*/

public class FirstMqTest {

// public static void main(String[] args[]){

// FirstMqTest first = new FirstMqTest();

// first.test();

// }

public static void main(String args[]){

FirstMqTest first = new FirstMqTest();

first.test();

}

public void test(){

String qManager = "MQSI_SAMPLE_QM"; //QueueManager name

String qName = "lq";//Queue Name

try {

//configure connection parameters

MQEnvironment.hostname="172.16.17.123";//MQ Server name or IP

//MQEnvironment.port=1414;//listenr port

MQEnvironment.channel="BridgeChannel";//Server-Connection Channel

MQEnvironment.CCSID =1381;

// Create a connection to the QueueManager

System.out.println("Connecting to queue manager: "+qManager);

MQQueueManager qMgr = new MQQueueManager(qManager);

// Set up the options on the queue we wish to open

int openOptions = MQC.MQOO_INPUT_AS_Q_DEF | MQC.MQOO_OUTPUT;

// Now specify the queue that we wish to open and the open options

System.out.println("Accessing queue: "+qName);

MQQueue queue = qMgr.accessQueue(qName, openOptions);

// Define a simple WebSphere MQ Message ...

MQMessage msg = new MQMessage();

// ... and write some text in UTF8 format

msg.writeUTF("Hello, World!");

// Specify the default put message options

MQPutMessageOptions pmo = new MQPutMessageOptions();

// Put the message to the queue

System.out.println("Sending a message...");

/*

* 在此测试一下 mq 的传输次列

*

*/

for(int j=0;j 5;j++){

String str ="test11111111111";

str = str+j;

msg.writeUTF(str);

queue.put(msg, pmo);

}

queue.put(msg, pmo);

// Now get the message back again. First define a WebSphere MQ message

// to receive the data

MQMessage rcvMessage = new MQMessage();

// Specify default get message options

MQGetMessageOptions gmo = new MQGetMessageOptions();

// Get the message off the queue.

System.out.println("...and getting the message back again");

queue.get(rcvMessage, gmo);

// And display the message text...

String msgText = rcvMessage.readUTF();

System.out.println("The message is: " + msgText);

// Close the queue

System.out.println("Closing the queue");

queue.close();

// Disconnect from the QueueManager

System.out.println("Disconnecting from the Queue Manager");

qMgr.disconnect();

System.out.println("Done!");

}

catch (MQException ex) {

System.out.println("A WebSphere MQ Error occured : Completion Code "

+ ex.completionCode + " Reason Code " + ex.reasonCode);

}

catch (java.io.IOException ex) {

System.out.println("An IOException occured whilst writing to the message buffer: "

+ ex);

}

}

}


网页标题:mq补偿机制java代码 mq补偿实现最终一致性
网站链接:http://bjjierui.cn/article/dojjjie.html

其他资讯