ASG
IBM
Zystems
Cressida
Icon
Netflexity
 
  MQSeries.net
Search  Search       Tech Exchange      Education      Certifications      Library      Info Center      SupportPacs      LinkedIn  Search  Search                                                                   FAQ  FAQ   Usergroups  Usergroups
 
Register  ::  Log in Log in to check your private messages
 
RSS Feed - WebSphere MQ Support RSS Feed - Message Broker Support

MQSeries.net Forum Index » Multiphase Commit » Two phase commit

Post new topic  Reply to topic
 Two phase commit « View previous topic :: View next topic » 
Author Message
Seshagiri
PostPosted: Sun Oct 09, 2011 10:15 am    Post subject: Two phase commit Reply with quote

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
View user's profile Send private message
zpat
PostPosted: Sun Oct 09, 2011 11:41 am    Post subject: Reply with quote

Jedi Council

Joined: 19 May 2001
Posts: 5849
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
View user's profile Send private message
bruce2359
PostPosted: Sun Oct 09, 2011 1:00 pm    Post subject: Reply with quote

Poobah

Joined: 05 Jan 2008
Posts: 9394
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
View user's profile Send private message
Seshagiri
PostPosted: Sun Oct 09, 2011 7:17 pm    Post subject: Reply with quote

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
View user's profile Send private message
Display posts from previous:   
Post new topic  Reply to topic Page 1 of 1

MQSeries.net Forum Index » Multiphase Commit » Two phase commit
Jump to:  



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
Protected by Anti-Spam ACP
 
 


Theme by Dustin Baccetti
Powered by phpBB © 2001, 2002 phpBB Group

Copyright © MQSeries.net. All rights reserved.