I've got a simple example working where a message is posted as xml to a fanout exchange, and I have a test client that receives the message. But when I try to retrieve the same message in my deployed system, there is an error that occurs while AMQP's SimpleMessageListenerContainer handles it. By tracing into the code, I can see that the xml string is not being transformed into a java object as I thought it would, and there is a classcastexception (I'm not asking about this) that results in the same message being added to the the source fanout queue repeatedly forever. I haven't let it run for too long, but I quickly get up to 40k messages.
I've tried putting in my own error handler, but I can't get an error handler in the listener object, which is an instance of org.springframework.amqp.rabbit.AbstractMessageLis tenerContainer. The value is always null.
I read the following here:
So my questions are, how do I set this error handler so that I can at least see what error is causing the problem, and how can I stop this propagation?If you are using a SimpleMessageListenerContainer you will also be able to inject a Spring ErrorHandler instance that can be used to react to an exception in the listener. The ErrorHandler cannot prevent the exception from eventually propagating, but it can be used to log or alert another component that there is a problem.
Here is my current configuration:
I thought putting the error handler in the service activator might do the trick, but I'm thinking it has to be done in the initial rabbit settings--I'm not sure. I know this can be done if I programmatically set everything up following some of the examples in the spring-amqp project, and I could probably obtain the listener somehow in my java code through spring, but I'm sure there must be a way here.Code:<rabbit:queue id="statusEventQueue" name="status.event.queue" durable="true"/> <rabbit:connection-factory id="connectionFactory" host="#{config.host}" username="#{config.user}" password="#{config.password}" port="#{config.port}"/> <rabbit:template id="amqpTemplate" connection-factory="connectionFactory" /> <rabbit:admin connection-factory="connectionFactory" /> <!-- Fanout queue for status events. A perl script sends a message to this exchange to update status of the initialization process --> <rabbit:fanout-exchange name="vtl.status.fanout.exchange" durable="true"> <rabbit:bindings> <rabbit:binding queue="statusEventQueue"/> </rabbit:bindings> </rabbit:fanout-exchange> <bean id="eventMarshaller" class="org.springframework.oxm.jaxb.Jaxb2Marshaller"> <property name="classesToBeBound"> <list> <value>beans.NodeStatus</value> </list> </property> </bean> <bean id="unmarshallingTransformer" class="org.springframework.integration.xml.transformer.UnmarshallingTransformer"> <constructor-arg ref="eventMarshaller"/> </bean> <bean id="errorHandler" class="handlers.ErrorHandler"/> <int-amqp:inbound-channel-adapter channel="statusControllerEventChannel" queue-names="status.event.queue" connection-factory="connectionFactory" error-handler="errorHandler"/> <int:channel id="eventNodeStatusOutputChannel"/> <int:transformer ref="unmarshallingTransformer" input-channel="statusControllerEventChannel" output-channel="eventNodeStatusOutputChannel"/> <bean id="headStatusMap" class="beans.NodeStatusMap" factory-method="getInstance"/> <int:service-activator input-channel="eventNodeStatusOutputChannel" ref="headStatusMap" method="handleStatusMessage"/>
Thanks for any help you can provide,
Scott


Reply With Quote
