1

So I have this code which publishes to JMS topic:

    public void notifyCreateListeners(MyCreatedObject payload) {
    logger.trace("ServiceImpl.notifyCreateListeners");
    TopicConnection conn = null;
    TopicSession session = null;
    Topic topic = null;

    try {
        Properties props = new Properties();
        props.setProperty("java.naming.factory.initial", "org.jnp.interfaces.NamingContextFactory");
        props.setProperty("java.naming.factory.url.pkgs","org.jboss.naming");
        props.setProperty("java.naming.provider.url", "jnp://localhost:49227");
        Context context = new InitialContext(props);
        TopicConnectionFactory tcf = (TopicConnectionFactory) context.lookup("/ConnectionFactory");
        conn = tcf.createTopicConnection(JbossJaasAuthenticator.principal, JbossJaasAuthenticator.credentials);
        topic = (Topic)context.lookup("topic/create_notify_topic");
        session = conn.createTopicSession(false, TopicSession.AUTO_ACKNOWLEDGE);
        conn.start();
        TopicPublisher send = session.createPublisher(topic);
        ObjectMessage message = session.createObjectMessage();
        message.setObject(payload);
        send.publish(message);
        conn.close();
    } catch (Exception e) {
        logger.error("an exception occurred notifying create listeners", e);
    }
}

I'm calling this code constantly through SOAP, and it executes rather fast, taking not more than 1-2 seconds. However, the problem that I have is, sometimes this code hangs on "send.publish(message)", and it can take very long time, from 5 to 15 minutes, and eventually will complete or will get killed by the transaction reaper:

[2015-04-01 11:38:00,198] WARN  com.arjuna.ats.arjuna.logging.arjLoggerI18N [com.arjuna.ats.arjuna.coordinator.BasicAction_40] - Abort called on already aborted atomic action -6ec596b6:e039:551a4e56:ff03b 
[2015-04-01 11:38:00,206] ERROR org.jboss.ws.core.jaxws.SOAPFaultHelperJAXWS SOAP request exception 
javax.ejb.EJBTransactionRolledbackException: Transaction rolled back

.....

Caused by: javax.transaction.RollbackException: [com.arjuna.ats.internal.jta.transaction.arjunacore.inactive] [com.arjuna.ats.internal.jta.transaction.arjunacore.inactive] The transaction is not active!

The strange part is that I do not use transaction for this method, which I confirmed with the method preceeding this one, where the "MyCreatedObject" is created in the DB, so I don't know which transaction is the reaper killing.

Question 1: How can I determine which transaction the reaper is killing? I enabled trace on the "com.arjuna", but nothing useful is printed out.

Question 2: How can I cause timeout for the send method? I tried setting timeToLive on the TopicPublisher to 120000 (2 minutes), but it seems that it has no effect.

Eventually, what would be ideal is for me to determine why there are delays on publishing to topic, and how can I interfere by setting some kind of timeout to this publishing, because this part is not that important, meaning that I do not want the overall SOAP call to end in error if the publishing fails, I would just want to log an error and let it finish successfully. I'm thinking of calling this "notifyCreateListeners" method in another thread, which I'll be killing after certain period of time (if it is still active). Is this a viable solution, or can you recommend something else?

  • Are you sure it's hanging on send.publish? I'm seeing a similar issue, but it's hanging on message.setObject. (Not strictly hanging, just taking an abnormally long time.) – Daniel Stolz Mar 02 '17 at 16:28
  • I'm pretty sure it was on send.publish(). I lost couple of days debugging it. It hadn't appeared recently though. I can't quite explain it. – Zoran Trifunovski Mar 21 '17 at 14:01

0 Answers0