Atomikos Forum |
|
Hi all,
I am new in this Community. I explain my problem. I have two distributed entity, that I will call "A" and "B", written in Java. "A" wants to send a message via socket to "B" and the message must be sent with a transaction. I tried to use Atomikos class, but it doesn't work. After the commit instruction, the status is 5(UNKNOWN). It should be COMMITTED or COMMITTING? Someone can help me with some example? Thanks a lot.
if this is the link, it is on the TODO list:
http://www.atomikos.com/Documentation/JtaXaCodeFragments I post some code here: public void run(){ try { tm = new UserTransactionManager(); tm.setTransactionTimeout ( 60 ); //First, I create a transaction tm.begin(); .......... .......... .......... /*here is the code that open a socket and send the message to the receiver*/ tm.commit(); //do commit } catch (Exception ex) {} } Please help me. Best Regards
Sorry...this is the code:
@Override public void run(){ try { tm = new UserTransactionManager(); tm.setTransactionTimeout ( 60 ); //First, create a transaction tm.begin(); //ProcessBuilder pb = new ProcessBuilder("./config/exec_mysqldump.sh","root","root","utenti"); //Process p = pb.start(); Socket s=new Socket(this.address,this.port); //qui invio il dump del database alla replica //File f=new File("./dump/"+this.nameDB); File f=new File("./ciccio"); if (!f.exists()) f.createNewFile(); ObjectOutputStream out=new ObjectOutputStream(s.getOutputStream()); boolean error=false; out.writeObject(f); out.flush(); out.close(); s.close(); System.out.println("inviato"); Transaction tx = tm.getTransaction(); tx.commit(); System.out.println("stato: "+tx.getStatus()); } catch (Exception ex) { Logger.getLogger(SendDumpDBtoReply.class.getName()).log(Level.SEVERE, null, ex); } } The log file is(tm.out): 11-07-14 09:35:28,984 [Thread-2] Starting read of logfile /home/marco/NetBeansProjects/ProvaTransazione/src/provatransazione/./logTrans/tmlog4.log 11-07-14 09:35:29,030 [Thread-2] Coordinator 127.0.1.1.tm0000100005 entering state: HEUR_HAZARD 11-07-14 09:35:29,031 [Thread-2] Local heuristic termination of coordinator 127.0.1.1.tm0000100005 with state COMMITTING 11-07-14 09:35:29,032 [Thread-2] Coordinator 127.0.1.1.tm0000100005 entering state: HEUR_HAZARD 11-07-14 09:35:29,032 [Thread-2] Local heuristic termination of coordinator 127.0.1.1.tm0000100005 with state COMMITTING 11-07-14 09:35:29,032 [Thread-2] Done read of logfile 11-07-14 09:35:29,032 [Thread-2] Logfile closed: /home/marco/NetBeansProjects/ProvaTransazione/src/provatransazione/./logTrans/tmlog4.log 11-07-14 09:35:29,074 [Thread-2] USING core version: 3.7.0 11-07-14 09:35:29,074 [Thread-2] USING com.atomikos.icatch.console_file_name = tm.out 11-07-14 09:35:29,074 [Thread-2] USING com.atomikos.icatch.console_file_count = 1 11-07-14 09:35:29,074 [Thread-2] USING com.atomikos.icatch.automatic_resource_registration = true 11-07-14 09:35:29,074 [Thread-2] USING com.atomikos.icatch.client_demarcation = false 11-07-14 09:35:29,078 [Thread-2] USING com.atomikos.icatch.threaded_2pc = true 11-07-14 09:35:29,078 [Thread-2] USING com.atomikos.icatch.serial_jta_transactions = true 11-07-14 09:35:29,078 [Thread-2] USING com.atomikos.icatch.log_base_dir = ./logTrans 11-07-14 09:35:29,078 [Thread-2] USING com.atomikos.icatch.console_log_level = DEBUG 11-07-14 09:35:29,078 [Thread-2] USING com.atomikos.icatch.max_actives = 50 11-07-14 09:35:29,079 [Thread-2] USING com.atomikos.icatch.checkpoint_interval = 500 11-07-14 09:35:29,079 [Thread-2] USING com.atomikos.icatch.enable_logging = true 11-07-14 09:35:29,079 [Thread-2] USING com.atomikos.icatch.output_dir = ./ 11-07-14 09:35:29,079 [Thread-2] USING com.atomikos.icatch.log_base_name = tmlog 11-07-14 09:35:29,079 [Thread-2] USING com.atomikos.icatch.console_file_limit = -1 11-07-14 09:35:29,079 [Thread-2] USING com.atomikos.icatch.max_timeout = 300000 11-07-14 09:35:29,079 [Thread-2] USING com.atomikos.icatch.tm_unique_name = 127.0.1.1.tm 11-07-14 09:35:29,079 [Thread-2] USING java.naming.factory.initial = com.sun.jndi.rmi.registry.RegistryContextFactory 11-07-14 09:35:29,080 [Thread-2] USING java.naming.provider.url = rmi://localhost:1099 11-07-14 09:35:29,080 [Thread-2] USING com.atomikos.icatch.service = com.atomikos.icatch.standalone.UserTransactionServiceFactory 11-07-14 09:35:29,080 [Thread-2] USING com.atomikos.icatch.force_shutdown_on_vm_exit = false 11-07-14 09:35:29,080 [Thread-2] USING com.atomikos.icatch.default_jta_timeout = 10000 11-07-14 09:35:29,080 [Thread-2] getCompositeTransaction() returning NULL! 11-07-14 09:35:29,080 [Thread-2] Coordinator 127.0.1.1.tm0000100006 entering state: ACTIVE 11-07-14 09:35:29,084 [Thread-2] TaskManager: initializing... 11-07-14 09:35:29,085 [Thread-2] THREADS: using JDK thread pooling... 11-07-14 09:35:29,096 [Thread-2] THREADS: using executor class com.atomikos.icatch.imp.thread.Java15ExecutorFactory$Executor 11-07-14 09:35:29,097 [Thread-2] (1.5) executing task: com.atomikos.timing.PooledAlarmTimer@110c424 11-07-14 09:35:29,097 [Thread-2] ThreadFactory: creating new thread: Atomikos:0 11-07-14 09:35:29,098 [Thread-2] Creating composite transaction: 127.0.1.1.tm0000100006 11-07-14 09:35:29,103 [Thread-2] createCompositeTransaction ( 60000 ): created new ROOT transaction with id 127.0.1.1.tm0000100006 11-07-14 09:35:29,119 [Thread-2] getCompositeTransaction() returning instance with id 127.0.1.1.tm0000100006 11-07-14 09:35:29,121 [Thread-2] commit() done (by application) of transaction 127.0.1.1.tm0000100006 11-07-14 09:35:29,122 [Thread-2] Coordinator 127.0.1.1.tm0000100006 entering state: COMMITTING 11-07-14 09:35:29,161 [Thread-2] Coordinator 127.0.1.1.tm0000100006 entering state: TERMINATED 11-07-14 09:35:29,162 [Thread-2] Coordinator 127.0.1.1.tm0000100006 : stopping timer... 11-07-14 09:35:29,163 [Thread-2] Coordinator 127.0.1.1.tm0000100006 : disposing statehandler TERMINATED... 11-07-14 09:35:29,163 [Thread-2] Coordinator 127.0.1.1.tm0000100006 : disposed. I don't understand if it works, that is the transaction is done. Please help me if you can!!!!!!! |