私はApache Camel SQLバッチ挿入プロセスを使用しています。Apache Camel SQLバッチ挿入に長時間を要する
私のアプリケーションは、約2,000のチケットを含むアクティブMQからチケットを読み取ります。
私は次のように私は発射していたクエリがある100
としてバッチを更新しました:
sql.subs.insertCdr= insert into subscription_logs(master_id,request_type,req_desc,msisdn,amount,status,resp_code,resp_desc,channel,transaction_id,se_mode,be_mode,sub_type,sub_timeleft,srv_name,srv_id,start_date,end_date,operator,circle,country,time_offset,retry_count,user_status,previous_state,se_reqrecvtime,se_respsenttime,be_reqsenttime,be_resprecvtime,cp_id,cp_name,sub_srvname,sub_srvid,msg_senderid,msg_text,call_back_url,call_back_resp,client_ip,se_sysIp,language,cp_callbackurlhittime,action,alert,notification_url,notification_resp) values(:#masterId, :#requestType,:#reqDesc,:#msisdnCdr,:#price,:#status,:#responseCode,:#reason,:#channel,:#transactionId,:#seMode,:#beMode,:#subType,:#subTimeLeft,:#serviceName,:#serviceId,:#subStartDate,:#cdrEndDate,:#operator,:#circle,:#country,:#timeOffset,:#retryCount,:#userStatus,:#previousState,:#seReqRecvTime,:#seRespSentTime,:#beReqSentTime,:#beRespRecvTime,:#cpId,:#cpName,:#subServiceName,:#subServiceId,:#shortCode,:#message,:#callBackUrl,:#callBackResp,:#clientIp,:#seSysIp,:#language,:#cpCallbackUrlHitTime,:#action,:#alert,:#notificationUrl,:#notificationResponse)
次のようにSQLバッチのルートが定義されています
<pipeline> <log message="Going to insert in database"></log> <transform> <method ref="insertionBean" method="subsBatchInsertion"></method> </transform> <choice> <when> <simple>${in.header.subsCount} == ${properties:batch.size}</simple> <to uri="sql:{{sql.subs.insertCdr}}?batch=true"></to> <log message="Inserted rows ${body}"></log> </when> </choice> </pipeline>
以下は私のJavaコードです:
public List<Map<String, Object>> subsBatchInsertion(Exchange exchange) { if (subsBatchCounter > batchSize) { subsPayLoad.clear(); subsBatchCounter = 1; } subsPayLoad.add(generateInsert(exchange.getIn().getBody(SubscriptionCdr.class))); exchange.getIn().setHeader("subsCount", subsBatchCounter); subsBatchCounter++; return subsPayLoad; } public Map<String, Object> generateInsert(Cdr cdr) { Map<String, Object> insert = new HashMap<String, Object>(); try { insert = BeanUtils.describe(cdr); } catch (Exception e) { Logger.sysLog(LogValues.error, this.getClass().getName()+" | "+Thread.currentThread().getStackTrace()[1].getMethodName(), coreException.GetStack(e)); } for (String name : insert.keySet()) { Logger.sysLog(LogValues.APP_DEBUG, this.getClass().getName(), name + ":"+ insert.get(name) + "\t"); } return insert; }
今の問題は、ActiveMQので120チケットの周りに存在する場合には、SQLバッチがデータベースに値を挿入し始めているはずです。しかし、それはより多くの時間がかかります。 ActiveMQに約500のチケットがある場合、挿入プロセスを開始します。 挿入プロセスの最適化にanyboodyヘルプを使用できますか? または他のアプローチですか?