0

smooks を使用して .csv ファイルからレコードを取得していました。ファイルのサイズは、単一のファイルで約 30MB のデータです。このファイルでは、約 3 ラックのレコードがリストにフェッチされます。

i was done next リストは subList を使用してサブパートに分割されます パーティションサイズは最大 2000 です。

1 回のトランザクションで 2000 レコードをフラッシュしたいのですが、私のコードではそのようにはできません。

私はSeam 2.1.2、jap with hibernate、EntityManager、JTA Transactionsを使用しています。

components.xml

  <core:init debug="false" jndi-pattern="@jndiPattern@" />
    <core:manager concurrent-request-timeout="2000"
        conversation-id-parameter="cid" conversation-timeout="120000"
        parent-conversation-id-parameter="pid" />
    <web:hot-deploy-filter url-pattern="/*.mobee" />
    <persistence:entity-manager-factory
        installed="@seamBootstrapsPu@" name="entityManagerFactory"
        persistence-unit-name="mobeeadmin" />
    <persistence:managed-persistence-context 
        auto-create="true" entity-manager-factory="@seamEmfRef@" name="entityManager"
        persistence-unit-jndi-name="@puJndiName@" />
 <async:quartz-dispatcher />
    <security:identity authenticate-method="#{authenticator.authenticate}" />
  <web:rewrite-filter view-mapping="*.mobee" />
    <web:multipart-filter create-temp-files="true" max-request-size="28672000"     url-pattern="*.seam"/>
    <event type="org.jboss.seam.security.notLoggedIn">
        <action execute="#{redirect.captureCurrentView}" />
    </event>
<event type="org.jboss.seam.security.loginSuccessful">
        <action execute="#{redirect.returnToCapturedView}" />
    </event>
    <mail:mail-session host="localhost" port="25" />

Java コード:

  private  List<DoTempCustomers> doTempCustomers;

   int partitionSize = 2000;

   for (int i = 0; i < doTempCustomers.size(); i += partitionSize) {
      String message= tempCustomerMigration(doTempCustomers.subList(i,
               i + Math.min(partitionSize, doTempCustomers.size() - i)));
   }



 @Begin(join=true)
    public String tempCustomerMigration(List<DoTempCustomers>  list){
         PersistenceProvider.instance().setFlushModeManual(getEntityManager());
         TempCustomers temp = null;
      for(DoTempCustomers tempCustomers:list){
        try {
        temp=new TempCustomers();
            BeanUtils.copyProperties(temp, tempCustomers);
            getEntityManager.persist();
            getEntityManager.flush();
         }

サーバーの応答を GUI に送信する前に、各トランザクションでレコードを DB にフラッシュする方法について、この問題は解決されませんでした。

それ以外の場合、例外が発生した処理時間は

2012-12-06 17:09:56,380 WARN  [com.arjuna.ats.arjuna.logging.arjLoggerI18N] [com.arjuna.ats.arjuna.coordinator.BasicAction_58] - Abort of action id -53eff40e:f2db:50c0a356:7d invoked while multiple threads active within it.
2012-12-06 17:09:56,380 WARN  [com.arjuna.ats.arjuna.logging.arjLoggerI18N] [com.arjuna.ats.arjuna.coordinator.CheckedAction_2] - CheckedAction::check - atomic action -53eff40e:f2db:50c0a356:7d aborting with 1 threads active!
2012-12-06 17:09:56,522 DEBUG [org.jboss.util.NestedThrowable] org.jboss.util.NestedThrowable.parentTraceEnabled=true
2012-12-06 17:09:56,522 DEBUG [org.jboss.util.NestedThrowable] org.jboss.util.NestedThrowable.nestedTraceEnabled=false
2012-12-06 17:09:56,522 DEBUG [org.jboss.util.NestedThrowable] org.jboss.util.NestedThrowable.detectDuplicateNesting=true
2012-12-06 17:09:56,524 INFO  [STDOUT] [Mobee]- WARN 2012-12-06 17:09:56,524 [] JDBCExceptionReporter - SQL Error: 0, SQLState: null
2012-12-06 17:09:56,525 INFO  [STDOUT] [Mobee]-ERROR 2012-12-06 17:09:56,524 [] JDBCExceptionReporter - Transaction is not active: tx=TransactionImple < ac, BasicAction: -53eff40e:f2db:50c0a356:7d status: ActionStatus.ABORTING >; - nested throwable: (javax.resource.ResourceException: Transaction is not active: tx=TransactionImple < ac, BasicAction: -53eff40e:f2db:50c0a356:7d status: ActionStatus.ABORTING >)
2012-12-06 17:09:56,545 INFO  [STDOUT] [Mobee]-ERROR 2012-12-06 17:09:56,527 [] AbstractFlushingEventListener - Could not synchronize database state with session
org.hibernate.exception.GenericJDBCException: Cannot open connection
    at org.hibernate.exception.SQLStateConverter.handledNonSpecificException(SQLStateConverter.java:103)

この例外のために、jboss--service.xml で TransactionTimeout を増やすために Google で sol を見つけました。私にとっては、タイムアウト パラメータを増やしても意味がありません。

4

1 に答える 1

0

EJB セッション Bean である新しい Seam コンポーネントを作成し、UserTransactionを使用してバッチで更新/挿入を実行できます。UserTransaction では、トランザクションのタイムアウトも指定できます。この新しいコンポーネントを、上で使用しているコンポーネントに挿入します。 ここに例があります - 5 番目の投稿を参照してください。. それ以外の場合、EJB を使用したくない場合は、単一の会話にスコープされたSeam 管理の永続コンテキストを使用しているように見えるため、ネストされた Seam 会話を使用する必要があると思います。

于 2012-12-10T01:10:52.347 に答える