|
RSS Feed - WebSphere MQ Support
|
RSS Feed - Message Broker Support
|
 |
|
Two phase commit |
« View previous topic :: View next topic » |
Author |
Message
|
Seshagiri |
Posted: Sun Oct 09, 2011 10:15 am Post subject: Two phase commit |
|
|
Apprentice
Joined: 04 Oct 2011 Posts: 42
|
Hi,
I am using 2 phase commit in java application(stand alone application that connects to queuemanager and gets the message from a queue and inserts the info into database) . when I commit the the MQ the data is not shown in the database tables. But if i close the oracle connection I am able to see the data in tables. Is this correct. The problem here is every time I need to get new connection for the next unit of work. |
|
Back to top |
|
 |
zpat |
Posted: Sun Oct 09, 2011 11:41 am Post subject: |
|
|
 Jedi Council
Joined: 19 May 2001 Posts: 5866 Location: UK
|
Do you understand what 2 phase commit is? It is not two commits. It is one commit over two resources. Look up XA cooordination. |
|
Back to top |
|
 |
bruce2359 |
Posted: Sun Oct 09, 2011 1:00 pm Post subject: |
|
|
 Poobah
Joined: 05 Jan 2008 Posts: 9469 Location: US: west coast, almost. Otherwise, enroute.
|
There are some things you need to do in your WMQ configuration to enable the database calls to part of the commit/backout process.
You might want to search google for oracle+wmq+commit+java. _________________ I like deadlines. I like to wave as they pass by.
ב''ה
Lex Orandi, Lex Credendi, Lex Vivendi. As we Worship, So we Believe, So we Live. |
|
Back to top |
|
 |
Seshagiri |
Posted: Sun Oct 09, 2011 7:17 pm Post subject: |
|
|
Apprentice
Joined: 04 Oct 2011 Posts: 42
|
zpat wrote: |
Do you understand what 2 phase commit is? It is not two commits. It is one commit over two resources. Look up XA cooordination. |
Yes you are right. Here I am commiting just MQ.
Please see the code:
1)
Hashtable properties = new Hashtable();
properties.put(MQC.THREAD_AFFINITY, new Boolean(true));
mqp.connectToQmanager(qManager, properties);
public void connectToQmanager(String qManager, Hashtable properties) throws MQException {
qMgr = new MQQueueManager(qManager,properties);
} // End of connectToQmanager
//The above statements connect to Qmanager
2)
con = mqp.getDBConnection(getDataSource());
con.setAutoCommit(false);
private final oracle.jdbc.xa.client.OracleXADataSource getDataSource() {
try {
if (ds == null) {
ds = new oracle.jdbc.xa.client.OracleXADataSource();
ds.setUser(userId);
ds.setPassword(pwd);
ds.setURL(dbURL);
}
}
catch (SQLException se) {
message = "SQLException occurred while creating datasource." + se.getMessage();
utilsObj.errDisplay(title, message, true);
}
return ds;
} // End of getDataSource
this will get the connection for oracle
Note: mqp is a object of MQAPI which is wrapper class fro MQ API's |
|
Back to top |
|
 |
|
|
 |
|
Page 1 of 1 |
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
|
|
|