2

ここには、スレッド プールと、ポーリングを実装してデータベースからメッセージを読み取るための Another Polling クラスがあります。ここでの問題は、膨大なメッセージが待機しているため、更新のために冗長なメッセージを読み取らないようにし、同時に待機している他のメッセージを処理する必要があることです。

// the code for poll method
public void poll() throws Exception {
    // Method which defines polling of the data entry for counting its size.
    st = conn.createStatement();
    int count = 1;
    long waitInMillisec = 1 * 60 * 125; // Wait for 7.5 seconds.
    for (int i = 0; i < count; i++) {
        System.out.println("Wait for " + waitInMillisec + " millisec");
        Thread.sleep(waitInMillisec);

        java.util.Date date = new java.util.Date();
        Timestamp start = new Timestamp(date.getTime());
        rs = st.executeQuery("select * from msg_new_to_bde where ACTION=804");
        java.util.Date date1 = new java.util.Date();
        Timestamp end = new Timestamp(date1.getTime());
        System.out.print("Query count: ");
        System.out.println(end.getTime() - start.getTime());

        Collection<KpiMessage> pojoCol = new ArrayList<KpiMessage>();
        while (rs.next()) {
            KpiMessage filedClass = convertRecordsetToPojo(rs);
            pojoCol.add(filedClass);

        }
4

1 に答える 1