users@glassfish.java.net

Re: Re: [issue] can not store transaction log into database

From: Wang.Qiang <wang.qiang_at_cn.fujitsu.com>
Date: Thu, 10 Jul 2008 16:09:20 +0900

sankara,

Thank you very much for your help.

but I still have some issues.

1.You writed 'It doesn't appear that you are using more than one
resource in the transaction.'
it seems something inconsistent with 'This log record is written only if
the transaction has two or more resources (2PC transaction).'
did you mean that it doesn't appear that you are using less than one
resource in the transaction?not more than?

2.As you written 'then try putting some load and then you will be able
to see some entries in the table. '
I used a transaction had two resources to test whether transaction log
will be written to txn_log_table or not,
before application finished,Ichecked the txn_log_table,but txn_log_table
was still empty.
how can I really affirm the function of storing Transaction Logging to
database is correct?

code like this
@Stateless(name="myejb",mappedName="ejb/myejb")
public class MyBeanImpl implements MyBean {

public void method(){
for(int i = 0; i < 100; i++ ){
insertSomeDataIntoOneDatabase();
insertSomeDataIntoAnotherDatabase();
}
}
}

regards
Wang



sankara rao bhogi
> Wang,
>
> Step1 is not required. Transaction log record in the txn_log_table is
> quite short lived, hence it is pretty difficult to realize if there is
> any data written to it at all. This log record is written only if the
> transaction has two or more resources (2PC transaction). It doesn't
> appear that you are using more than one resource in the transaction.
> If you are using 2PC transaction and want to validate if any data is
> written to the txn_log_table, then try putting some load and then you
> will be able to see some entries in the table.
>
> regards
> sankar
>
>
>
> Wang.Qiang wrote:
>
>> Hi,all
>>
>> I am writing a application to test Transaction Logging, and I want to
>> store Transaction Logs in a Database(Derby) by following steps
>>
>> 1. Create a JDBC connection Pool and set the
>> non-transactional-connections attribute to true.
>>
>> 2. Create a JDBC resource name of jdbc/myds that uses the connection
>> pool and note the JNDI name of the JDBC resource.
>>
>> 3. Create a table named txn_log_table with the schema:
>> create table txn_log_table(localtid bigint,servername varchar(40),gtrid
>> char(70) for bit data)
>>
>> 4. Add the db-logging-resource property to the transaction service.
>> asadmin set
>> server.transaction-service.property.db-logging-resource="jdbc/myds"
>>
>> 5. To disable file synchronization, use the following asadmin
>> create-jvm-options command:
>> asadmin create-jvm-options -Dcom.sun.appserv.transaction.nofdsync
>>
>> 6. Restart the server
>>
>> 7.deloy the application into default server
>> ** all above steps are configed in the glassfish default server
>>
>> my application use toplink to persist a entity to database
>> EJB code like this
>>
>> @Stateless(name="myejb",mappedName="ejb/myejb")
>> public class MyBeanImpl implements MyBean {
>> @PersistenceContext(unitName="myunit")
>> private EntityManager manager;
>>
>> public void testInsert(String name, String sex) {
>> MyEntity entity = new MyEntity();
>> entity.setName(name);
>> entity.setSex(sex);
>> manager.persist(entity);
>> }
>> }
>>
>> Client to invoke the ejb.
>> the result is the entity is correct insert into the database,
>> but,I go to check the txn_log_table in the database,
>> the 'txn_log_table' table does not have any data.
>> I think txn_log_table will record this transaction.
>> I don't know why?
>> Could you help me?
>>
>> Thanks in advance
>> Wang
>>
>>
>>
>>
>>
>>
>>
>>
>>
>>
>>
>>
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe_at_glassfish.dev.java.net
>> For additional commands, e-mail: users-help_at_glassfish.dev.java.net
>>
>>
>>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe_at_glassfish.dev.java.net
> For additional commands, e-mail: users-help_at_glassfish.dev.java.net
>
>
>
>


-- 
以上
--------------------------------------------------
王 強
Development Dept.II(Interstage)
Nanjing Fujitsu Nanda Software Tech. Co., Ltd.(FNST)
8/F., Civil Defense Building, No.189 Guangzhou Road,
Nanjing, 210029, China
TEL:+86+25-86630566-918
COINS:79955-918
FAX:+86+25-83317685
MAIL:wang.qiang_at_cn.fujitsu.com
--------------------------------------------------