Thank you everyone and you guys are absolutely correct. I thought I had to declare the connection and channel inside the try block because exception need to be thrown or caught.
Sent from mobile device with autocorrect. Phil > On Sep 27, 2013, at 9:40 AM, Tim Watson <[email protected]> wrote: > > Phil, > >> On 27 Sep 2013, at 14:31, Phil wrote: >> I'm a newbie on RabbitMQ. I'm writing a java service to consume a message >> from the queue. Everything is working as designed but I cannot seem to code >> "channel.close() or conn.close()" in the catch or finally block. Java is >> complaining about that the "cannot find symbol". >> >> symbol : variable channel >> location: class RouteToMercury.javaServices >> channel.close(); > > It's impossible to help with a compiler error if you don't post that code > that you're trying to compile. > >> Can I close the connection and channel if an exception occur? > > Yes, absolutely. The above looks like a scoping issue. I suspect you've done > something like... > > try { > final Channel channel = connection.createChannel(); > doSomeWork(channel); > } finally { > channel.close(); > } > > Am I right? If so, you need to move the channel variable to the outer scope. > > Cheers, > Tim > _______________________________________________ > rabbitmq-discuss mailing list > [email protected] > https://lists.rabbitmq.com/cgi-bin/mailman/listinfo/rabbitmq-discuss -- You received this message because you are subscribed to the Google Groups "rabbitmq-discuss" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To post to this group, send email to [email protected]. Visit this group at http://groups.google.com/group/rabbitmq-discuss. For more options, visit https://groups.google.com/groups/opt_out.
