activemq-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From OG <ogjunk-...@yahoo.com>
Subject Re: 3.2.1, NPE at DefaultBroker:579
Date Mon, 16 Jan 2006 22:29:29 GMT
Hi,

I found James Strachan's pointer to:
  http://activemq.org/How+can+I+support+auto+reconnection

I've been trying to use the "reliable" configuration without any luck
so far.  I currently have this:

  <broker>
    <connector>
      <serverTransport uri="vm://localhost"/>
    </connector>
    ....
  </broker>


I am unclear where the "reliable" bit mentioned in docs needs to go.

1) Does it go into serverTransport element's uri attribute?
  e.g. <serverTransport uri="reliable:vm://localhost"/>

2) Or into tcpServerTransport's uri attribute?
  e.g. <tcpServerTransport uri="reliable:vm://localhost"/>

3) Or into networkChannel's uri attribute?
  e.g. <networkChannel uri="reliable:vm://localhost"/>



I did have a little bit of luck with this:

  <broker>
    <connector>
      <serverTransport uri="vm://localhost"/>
    </connector>
    <networkConnector>
        <networkChannel uri="reliable:tcp://localhost"
        reconnectSleepTime="10000" />
    </networkConnector>



With this I was able to:
- put a message in the JMS queue
- stop DB
- have ActiveMQ hit the wall (DB down, no connections)
- restart DB
- have ActiveMQ start acting normally, connecting to DB, etc.


Is this a good solution to my problem?

Thanks,
Otis


--- OG <ogjunk-amq@yahoo.com> wrote:

> Hello,
> 
> I'm getting a NPE from DefaultBroker
>
(./modules/core/src/java/org/activemq/broker/impl/DefaultBroker.java),
> line 579 (in release 3.2.1).
> 
> Line 579:
> transientTopicMCM.sendMessage(client, message);
> 
> So transientTopicMCM must be null.
> 
> 
> I get this errors when I try to put something in the JMS queue. 
> Also,
> I should say that I _am_ having some issues with database connections
> (running out of them), and this is very likely related to this
> problem.
> I was wondering if somebody could take a quick look at the code
> below,
> and tell me if I'm doing something stupid.
> 
> Code and description of DB/connection situation is followed by the
> exception stack trace.
> 
> // static block in my code, executed only once in the JVM
> // is doing this in a static block a bad idea?
>     static {
>         _connectionFactory = new
> ActiveMQConnectionFactory(BROKER_URL);
>        
> _connectionFactory.setBrokerXmlConfig(XML_CONFIGURATION_LOCATION);
>     }
> 
> // called whenever a new message is sent to JMS queue, once for each
> message
>     public Connection createConnection() throws JMSException {
>         Connection connection =
> _connectionFactory.createConnection();
>         connection.start();
>         return connection;
>     }
>     public Session createSession(Connection connection) throws
> JMSException {
>         Session session = connection.createSession(false, ACK_MODE);
>         return session;
>     }
>     public MessageProducer createProducer(Session session, String
> queue) throws JMSException {
>         Destination destination = session.createQueue(queue);
>         MessageProducer producer =
> session.createProducer(destination);
>         producer.setDeliveryMode(DeliveryMode.PERSISTENT);
>         return producer;
>     }
> 
> 
> The code that sends the message in the first place looks like this:
> 
> 
>     Connection connection = null;
>     Session session = null;
>     MessageProducer producer = null;
> 
>     try {
>         // create connection, session, producer
>         connection = jmsAdapter.createConnection();
>         session = jmsAdapter.createSession(connection);
>         producer = jmsAdapter.createProducer(session, queue);
> 
>         // send message
>         jmsAdapter.sendBinaryMessage(session, producer,
> messageContent);
>     } catch (JMSException e) {
>         // log and rethrow
>     } catch (Throwable t) {
>         // log and rethrow
>     }
>     finally {
>         try {
>             // release used JMS resources
>             jmsAdapter.close(connection, session, producer);
>         } catch (JMSException e1) {
>             // log and rethrow
>         }
>     }
> 
> 
> It looks to me like there is something in ActiveMQ that gets
> nulled/messed-up when the connection to the DB fails (e.g. I run out
> of
> DB connections).
> This makes 100% sense - if the DB is out of connections, and my JMS
> queues are stored in the DB, of course ActiveMQ won't be able to get
> a
> connection.
> 
> However, once my DB recovers and there ARE available connections,
> further attempts to get a Connection from ActiveMQConnectionFactory
> with the above code go _connectionFactory.getConnection(), STILL
> fail. 
> It looks as if ActiveMQConnectionFactory, once messed up a bit by the
> lack of DB connections, never tries to get new connections when its
> getConnection() method is called.
> 
> I imagine one way of working around this is to simply create a new
> ActiveMQConnectionFactory every time you need a Connection, but this
> looks like a misuse of the API.
> 
> Any help would be very appreciated, as I'm having problems with this
> on
> a production system right now. :(
> 
> 
> This is the exception stack trace:
> 
> Caused by: javax.jms.JMSException
>         at
>
org.activemq.util.JMSExceptionHelper.newJMSException(JMSExceptionHelper.java:49)
>         at
>
org.activemq.util.JMSExceptionHelper.newJMSException(JMSExceptionHelper.java:37)
>         at
>
org.activemq.util.JMSExceptionHelper.newJMSException(JMSExceptionHelper.java:60)
>         at
>
org.activemq.ActiveMQConnection.syncSendPacket(ActiveMQConnection.java:1382)
>         at
>
org.activemq.ActiveMQConnection.sendConnectionInfoToBroker(ActiveMQConnection.java:1617)
>         at
> org.activemq.ActiveMQConnection.start(ActiveMQConnection.java:643)
>         at
>
com.simpy.jms.ActiveMqAdapter.createConnection(ActiveMqAdapter.java:139)
>         at
>
com.simpy.jms.JmsQueueService.sendBinaryMessage(JmsQueueService.java:53)
>         ... 33 more
> Caused by: java.lang.NullPointerException
>         at
>
org.activemq.broker.impl.DefaultBroker.doMessageSend(DefaultBroker.java:579)
>         at
>
org.activemq.broker.impl.DefaultBroker.sendMessage(DefaultBroker.java:320)
>         at
>
org.activemq.broker.impl.AdvisorySupport.dispatchToBroker(AdvisorySupport.java:395)
>         at
>
org.activemq.broker.impl.AdvisorySupport.addConnection(AdvisorySupport.java:166)
>         at
>
org.activemq.broker.impl.DefaultBroker.addClient(DefaultBroker.java:235)
>         at
>
org.activemq.broker.impl.BrokerContainerImpl.registerConnection(BrokerContainerImpl.java:316)
>         at
>
org.activemq.broker.impl.BrokerConnectorImpl.registerClient(BrokerConnectorImpl.java:154)
>         at
>
org.activemq.broker.impl.BrokerClientImpl.consumeConnectionInfo(BrokerClientImpl.java:557)
>         at
>
org.activemq.broker.impl.BrokerClientImpl.consume(BrokerClientImpl.java:373)
>         at
>
org.activemq.transport.vm.VmTransportChannel.asyncSend(VmTransportChannel.java:143)
>         at
>
org.activemq.transport.TransportChannelSupport.doAsyncSend(TransportChannelSupport.java:433)
>         at
>
org.activemq.transport.TransportChannelSupport.asyncSendWithReceipt(TransportChannelSupport.java:160)
>         at
>
org.activemq.transport.TransportChannelSupport.send(TransportChannelSupport.java:145)
>         at
>
org.activemq.ActiveMQConnection.syncSendPacket(ActiveMQConnection.java:1377)
>         ... 37 more
> 
> 
> Thanks,
> Otis
> 
> 


Mime
View raw message