seba.wagner
seba.wagner

Reputation: 3860

javax.jms.JMSException: No ManagedConnections available within configured blocking timeout

when I run an ActiveMQ in Tomcat I receive the following exceptions after hitting the server with adding a new message:

javax.jms.JMSException: No ManagedConnections available within configured blocking timeout ( 5000 [ms] ) for pool org.apache.geronimo.connector.outbound.SinglePoolConnectionInterceptor@6581542c
at org.apache.activemq.ra.ActiveMQConnectionFactory.createConnection(ActiveMQConnectionFactory.java:101)
at org.apache.activemq.ra.ActiveMQConnectionFactory.createConnection(ActiveMQConnectionFactory.java:67)

I am using Apache Tomee for managing the ActiveMQ queue.

My ActiveMQ configuration is very simple:

<?xml version="1.0" encoding="UTF-8"?>
<tomee>
    <!-- see http://tomee.apache.org/containers-and-resources.html -->

    <!-- activate next line to be able to deploy applications in apps -->
    <!-- <Deployments dir="apps" /> -->

    <Resource id="MyJmsResourceAdapter" type="ActiveMQResourceAdapter">
        BrokerXmlConfig =  broker:(tcp://localhost:61616)
        ServerUrl       =  tcp://localhost:61616
    </Resource>

    <Resource id="MyJmsConnectionFactory" type="javax.jms.ConnectionFactory">
        ResourceAdapter = MyJmsResourceAdapter
    </Resource>

</tomee>

And to define the Queue I have a simple code:

@Resource(name = "myQueue")
private Queue barQueue;

@Resource
private ConnectionFactory connectionFactory;

/**
 * Push Message to Queue
 *
 * @param payload
 * @throws JMSException
 */
private void pushToQueue(Serializable payload) throws JMSException {
    Connection connection = connectionFactory.createConnection();
    connection.start();

    // Create a Session
    Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);

    // Create a MessageProducer from the Session to the Topic or Queu
    MessageProducer producer = session.createProducer(barQueue);
    producer.setDeliveryMode(DeliveryMode.PERSISTENT);

    // Create a message
    ObjectMessage message = session.createObjectMessage(payload);

    // Tell the producer to send the message
    producer.send(message);
}

I can send messages fine if I leave a bit of a gap between the messages. But if I hit the server a bit harder I run in the above exception.

Where can I configure the Connection Pool size et cetera? Do I have an issue in closing the connection after using it?

Thanks, Sebastian

Upvotes: 2

Views: 1595

Answers (1)

seba.wagner
seba.wagner

Reputation: 3860

I think I found it: http://tomee.apache.org/jmsconnectionfactory-config.html

But I think the actual problem was that I did not close the connection.

In the example at: http://tomee.apache.org/tomcat-activemq.html

There is like a "..." at the end. What is actually missing at the end of the code block is a: connection.close();

That fixes my connection problems.

Upvotes: 2

Related Questions