consumer/producer can't reconnect to queue after hornet restart
hughbragg Sep 29, 2010 12:34 AMWhen I restart hornet, the consumer and the producer both try to reconnect automatically but both fail.
I have the producer and consumer in a loop trying to reconnect to hornet if the connection fails for any reason. They both do a full startup each loop.
When hornet comes back up they think they have reconnected but sending fails and receiving detects no messages.
Hornet thinks it has no consumers but the consumer actually does a full reconnect after a minute of idle time and no errors are detected.
The only way to get things rolling again is to restart both producer and consumer.
This code is run each time an error is caught or after 1 minute idle time on the consumer, but it still won't connect even when hornet is back up and hornet doesn't see a new consumer connecting. No exception is thrown.
{code}
private void SetupPTP() throws JMSException {
// Step 1. Directly instantiate the JMS Queue object.
queue = HornetQJMSClient.createQueue(cfg.CONFIG_QUEUE);
// Step 2. Instantiate the TransportConfiguration object which contains
// the knowledge of what transport to use,
Map<String, Object> connectionParams = new HashMap<String, Object>();
connectionParams.put(TransportConstants.PORT_PROP_NAME, cfg.CONFIG_PORT);
connectionParams.put(TransportConstants.HOST_PROP_NAME, cfg.CONFIG_HOST);
TransportConfiguration transportConfiguration =
new TransportConfiguration(
NettyConnectorFactory.class.getName(),
connectionParams);
// Step 3 Directly instantiate the JMS ConnectionFactory
// object using that TransportConfiguration
ConnectionFactory cf = HornetQJMSClient
.createConnectionFactory(transportConfiguration);
// Step 4.Create a JMS Connection
queueConnection = (QueueConnection)cf.createConnection();
// Step 5. Create a JMS Session
queueSession = (QueueSession)queueConnection
.createSession(true, Session.AUTO_ACKNOWLEDGE);
// Step 6. Create the consumer
consumer = this.jmsSession.createConsumer(queue);
}{code}
Can anyone offer an explanation as to why?
Is there a way to recommence processing after hornet goes down without restarting the consumer/producer?
Cheers