0

タイトルは紛らわしいかもしれませんが、これが私が達成したいことです。1つのejbから別のejbにjmsメッセージを送信したいのですが、2番目のejbにはメッセージリスナーがあり、これは正常に機能しています。ただし、1番目のejbで、2番目のejbが応答する一時的な宛先キューを作成する必要がありました。これも正しく機能しています。

私の問題は2番目のejbにあります。これは、サードパーティのWebサービスを呼び出しており、長い時間が経過すると応答することがあり、その時点で一時キューが期限切れになるはずです。しかし、問題はjava.netに準拠していないことです:http://java.net/projects/mq/lists/users/archive/2011-07/message/22

The message hasn't been delivered to a client and it expires -- in this case, the message is deleted when TTL is up.
The message is delivered to the JMS client (it's in-flight). Once this happens, since control is handed to the jms client, the broker cannot expire the message.
Finally, the jms client will check TTL just before it gives the message to the user application. If it's expired, we will not give it to the application and it will send a control message back to the broker indicating that the message was expired and not delivered.

それで、それは受け取られましたが、まだ返事がありません。次に、一時キューに書き込む時間に、すでに期限切れになっているはずですが、何らかの理由でキューに書き込むことができ、imqログにffがあります。

1 messages not expired from destination jmsXXXQueue [Queue] because they have been delivered to client at time of the last expiration reaping

一時キューがすでに期限切れになっているかどうかを検出できる別の実装はありますか?別の一連のアクションを実行できるようにするには?私の現在の問題はejb2の応答が遅いことであり、ejb1からのjmsリーダーはすでになくなっているため、これ以上ありません。

4

1 に答える 1

0

私の解決策は、最初のステートレス Bean (最初の jms メッセージの発信元) を Bean 管理のトランザクション内にラップすることでした。以下のコードを参照してください。

@Stateless
@TransactionManagement(TransactionManagementType.BEAN)
@LocalBean
public class MyBean {
    public void startProcess() {
        Destination replyQueue = send(jmsUtil, actionDTO);
        responseDTO = readReply(jmsUtil, replyQueue, actionDTO);
        jmsUtil.dispose();
    }

    public Destination send(JmsSessionUtil jmsUtil, SalesOrderActionDTO soDTO) {
        try {
            utx.begin();
            jmsUtil.send(soDTO, null, 0L, 1,
                    Long.parseLong(configBean.getProperty("jms.payrequest.timetolive")), true);
            utx.commit();
            return jmsUtil.getReplyQueue();
        } catch (Exception e) {
            try {
                utx.rollback();
            } catch (Exception e1) {

            }
        }
        return null;
    }

    public ResponseDTO readReply(JmsSessionUtil jmsUtil, Destination replyQueue,
                SalesOrderActionDTO actionDTO) {
            ResponseDTO responseDTO = null;
        try {
            utx.begin();

            responseDTO = (ResponseDTO) jmsUtil.read(replyQueue);

            if (responseDTO != null) {
                //do some action
            } else { // timeout
                ((TemporaryQueue) replyQueue).delete();
                jmsUtil.dispose();
            }
            utx.commit();
            return responseDTO;
        } catch (Exception e) {
            try {
                utx.rollback();
            } catch (Exception e1) {
            }
        }
        return responseDTO;
    }
}
于 2013-01-07T03:13:24.073 に答える