0

Is there a way to resend expired messages in a JBoss 4.2.2 message queue? The issue is they exceeded their retry amounts, but now the problem is fixed, so is there a way to resend them?

In JBoss 3 they were just text files that you could move around. Now that it is stored in a database, how can you do it?

Yishai
  • 90,445
  • 31
  • 189
  • 263

3 Answers3

1

Have a look at Hermes JMS. It's an open source tool for browsing JMS queues and topics. It can replay messages that end up on the broker's undeliverable queue.

Nat
  • 9,820
  • 3
  • 31
  • 33
0

Note: I work for CodeStreet

Our 'ReplayService for JMS' product is built exactly for this use case: search and retrieve previously published messages (n-times delivery) - JMS is really designed for a 1-time delivery.

With ReplayService for JMS, you would configure a WebLogic recording to record all messages published to your topic or queue. Through a Web-based GUI, you can then search for individual messages (by substring, XPath or JMS Selector) and then replay them again to the original JMS destination.

See http://www.codestreet.com/marketdata/jms/jms_details.php for further details.

Axel Podehl
  • 4,034
  • 29
  • 41
0

This is what I ended up doing:

    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();
Yishai
  • 90,445
  • 31
  • 189
  • 263