有沒有辦法在JBoss 4.2.2消息隊列中重發過期消息?問題是他們超過了他們的重試數量,但現在問題得到了解決,那麼有沒有辦法重新發送它們?如何在重試過期後從JBoss 4.2.2消息隊列重新發送消息
在JBoss 3中,它們只是可以移動的文本文件。現在它存儲在數據庫中,你怎麼做到的?
有沒有辦法在JBoss 4.2.2消息隊列中重發過期消息?問題是他們超過了他們的重試數量,但現在問題得到了解決,那麼有沒有辦法重新發送它們?如何在重試過期後從JBoss 4.2.2消息隊列重新發送消息
在JBoss 3中,它們只是可以移動的文本文件。現在它存儲在數據庫中,你怎麼做到的?
這是我落得這樣做:
Hashtable t = new Hashtable();
t.put(Context.PROVIDER_URL, "localhost:1099");
t.put(Context.INITIAL_CONTEXT_FACTORY, "org.jnp.interfaces.NamingContextFactory");
Context ctx = new InitialContext(t);
Queue q = (Queue) ctx.lookup("/queue/DLQ");
//----------------------------
ConnectionFactory cf = (ConnectionFactory) ctx.lookup("/ConnectionFactory");
Connection connection = cf.createConnection();
Session session = connection.createSession(true, 0);
//---------------------------------
MessageConsumer consumer = session.createConsumer(q);
connection.start();
SpyObjectMessage m;
Queue originialDestination = null;
//There can only be one in my case, but really you have to look it up every time.
MessageProducer producer = null;
while ((m = (SpyObjectMessage) consumer.receive(5000)) != null) {
Object o = m.getObject();
Date messageDate = new Date(m.getJMSTimestamp());
String originalQueue = m.getStringProperty("JBOSS_ORIG_DESTINATION");
if (originialDestination == null) {
originialDestination = (Queue) ctx.lookup("/queue/" +
originalQueue.substring(originalQueue.indexOf('.') + 1));
producer = session.createProducer(originialDestination);
}
producer.send(session.createObjectMessage((Serializable) o));
m.acknowledge();
}
//session.commit(); //Uncomment to make this real.
connection.close();
ctx.close();
看一看Hermes JMS。它是瀏覽JMS隊列和主題的開源工具。它可以重播消息,最終在代理的無法投遞的隊列中播放。
注:我爲CodeStreet
工作我們的產品「爲JMS ReplayService」正好建這個用例:搜索和檢索先前發佈的消息(n次交付) - JMS實際上是爲1次交付而設計的。
使用ReplayService for JMS,您可以配置WebLogic錄製以記錄發佈到您的主題或隊列的所有消息。通過基於Web的GUI,您可以搜索單個消息(通過子字符串,XPath或JMS選擇器),然後再次將它們重播到原始JMS目標。
有關詳細信息,請參見http://www.codestreet.com/marketdata/jms/jms_details.php。
愛馬仕JMS看起來不錯,謝謝! – Yishai 2009-05-21 16:58:53