@@ -48,56 +48,39 @@ public void handleUnexpectedConnectionDriverException(Connection conn, Throwable
4848 }
4949
5050 public void handleReturnListenerException (Channel channel , Throwable exception ) {
51- // TODO: Convert to logging framework
52- System .err .println ("ReturnListener.handleBasicReturn threw an exception for channel " +
53- channel + ":" );
54- exception .printStackTrace ();
55- try {
56- ((AMQConnection ) channel .getConnection ()).close (AMQP .INTERNAL_ERROR ,
57- "Internal error in ReturnListener" ,
58- false ,
59- exception );
60- } catch (IOException ioe ) {
61- // Man, this clearly isn't our day.
62- // Ignore the exception? TODO: Log the nested failure
63- }
51+ handleChannelKiller (channel , exception , "ReturnListener.handleBasicReturn" );
6452 }
6553
6654 public void handleFlowListenerException (Channel channel , Throwable exception ) {
67- // TODO: Convert to logging framework
68- System .err .println ("FlowListener.handleFlow threw an exception for channel " +
69- channel + ":" );
70- exception .printStackTrace ();
71- try {
72- ((AMQConnection ) channel .getConnection ()).close (AMQP .INTERNAL_ERROR ,
73- "Internal error in FlowListener" ,
74- false ,
75- exception );
76- } catch (IOException ioe ) {
77- // Man, this clearly isn't our day.
78- // Ignore the exception? TODO: Log the nested failure
79- }
55+ handleChannelKiller (channel , exception , "FlowListener.handleFlow" );
8056 }
8157
82- public void handleConsumerException (Channel channel ,
83- Throwable exception ,
84- Consumer consumer ,
85- String consumerTag ,
58+ public void handleConsumerException (Channel channel , Throwable exception ,
59+ Consumer _consumer , String consumerTag ,
8660 String methodName )
61+ {
62+ handleChannelKiller (channel , exception , "Consumer " + consumerTag
63+ + " method " + methodName
64+ + " for channel " + channel );
65+ }
66+
67+ protected void handleChannelKiller (Channel channel ,
68+ Throwable exception ,
69+ String what )
8770 {
8871 // TODO: Convert to logging framework
89- System .err .println ("Consumer " + consumer + " method " + methodName + " for channel " +
90- channel + " threw an exception :" );
72+ System .err .println (what + " threw an exception for channel " +
73+ channel + ":" );
9174 exception .printStackTrace ();
9275 try {
9376 ((AMQConnection ) channel .getConnection ()).close (AMQP .INTERNAL_ERROR ,
94- "Internal error in Consumer " +
95- consumerTag ,
77+ "Internal error in " + what ,
9678 false ,
9779 exception );
9880 } catch (IOException ioe ) {
9981 // Man, this clearly isn't our day.
10082 // Ignore the exception? TODO: Log the nested failure
10183 }
84+
10285 }
10386}
0 commit comments