Spring AMQP, catch listener container stopped event - spring

Using springframework 4.3.6, I have configured AMQP (RabbitMQ) to retry connection to the message broker every 5 seconds for 5 times. When all attempts fail to make a connection to the broker, spring fails with a warning:
WARN [x.x.x.x.SimpleMessageListenerContainer] stopping container - restart recovery attempts exhausted
I would like to listen to the listener container stop event and notify systems team about unavailability of the message bus.
I tried creating ApplicationListener with type ListenerContainerConsumerFailedEvent and also DeclarationExceptionEvent. But none of it worked. So i was wondering if there is any other way to catch container stopped event in case of failure to start the container successfully.
If it helps, the error message i get after each attempt to connect is
ERROR [x.x.x.x.SimpleMessageListenerContainer] Failed to check/redeclare auto-delete queue(s).

Related

How to retry consuming message, then stop consuming, when error occurs in listener

I have Kafka listener writing data to a database, in case of database timeout (JdbcException), I'd like to retry, and if timeouts persist, stop consuming Kafka message.
As far as I understand, Spring Kafka 2.9 has 2 CommonErrorHandler implementations:
DefaultErrorHandler tries to redeliver messages several times and then send failed messages to logs or DLQ
CommonContainerStoppingErrorHandler stops listener container and message consumption
I would like to chain both of them: first try to redeliver messages several times, then stop container when delivery doesn't succeed.
How can I do that?
Use a DefaultErrorHandler with a custom recoverer that calls a CommonContainerStoppingErrorHandler after the retries are exhausted.
See this answer for an example
How do you exit spring boot application programmatically when retries are exhausted, to prevent kafka offset commit
(It uses the older SeekToCurrentErrorHandler, but the same concept applies.)

Spring JMS - Issue with Default Message Listener Container issues on setting both durable and shared subscription

I have developed a Spring Integration Application which is running in multiple instance of PCF.
The application listens to the topic and process the message.
I use MqConnectionFactory for Topic connection and Spring JMS - DefaultMessageListenerContainer for listener message.
On Durable Subscription - With Same Client ID.
The first instance of the application runs without any issue and process the message.
Other instance, I am getting the following Error.
2429 - MQRC_SUBSCRIPTION_IN_USE
When I have different Client ID , Every instance of the application get the same copy of message resulting in duplicate processing - The idea of running multiple instance is to share the load and process parallel.
On Enabling Shared Subscription along with Durable Subscription - With Same Client ID.
Every instance is getting the following error.
JMSWMQ2025 Failed to subscribe to the topic due to the exception occurred
reason '2432' MQRC_SUB_ALREADY_EXIST.

Spring JMS 4.3.2 + Jboss EAP 6.4.8 + Webmethods Jms Broker 8.2 + Durable shared topic subscription

I'm trying to subscribe to a topic using durable and shared enabled, so that multiple instance can be connected to a topic to increase the scalability.
However, only the first instance getting connected without any errors, the second instance message listener keeps throwing the below error messages. I checked with my Webmethods counterpart and he found that the client state was disabled and that's why second listener was not able to connect using the same subscription name.
Can someone throw light on this issue please.
18:14:15,050 WARN
[org.springframework.jms.listener.DefaultMessageListenerContainer]
(DefaultMessageListenerContainer-145) Setup of JMS message listener
invoker failed for destination 'topicName' - trying to recover. Cause:
[BRM.10.2209] JMS: Durable subscription
"connectionFactory##subscriptionName" is in use.
The message
JMS: Durable subscription "connectionFactory##subscriptionName" is in use.
typically hints at a misconfiguration of your Topic on Broker. Please check (with MWS) that the Topic really has "Shared State=true“:
Then make sure your Connection Factory has a „Connection Factory Client ID“ set:
And finally you should set the following JVM setting:
-Dcom.webmethods.jms.clientIDSharing=true

Oracle OSB Proxy service Error

I have created a jms consuming proxy service with queue created using Oracle AQ. And the proxy service is routed to Business service which enqueues same message into different queue created using orace AQ.
Proxy service is running fine and the message is put in to destination queue, but its throwing error message as below
unexpected failure while processing an incoming message for endpoint proxy service
and I think because of the erorr, the service is retrying again and the message is posted to destination queue 16 times.
Please help me in resolving this.
Thanks.
Try to play with the transaction in the Proxy service or the JMS retries. It could be the Global transaction setup that is giving the error.

ActiveMQ failed to start (IOException)

I've been using ActiveMQ for a few weeks now and every time I boot up my laptop, I always just use activemq start to start it but today it throws an error:
Failed to start Apache ActiveMQ, java.io.IOException: Transport Connector could not be registered in
JMX: Failed to bind to server socket: tcp://0.0.0.0:61616?maximumConnections=1000&wireFormat.maxFrameSize=104857600 due to: java.net.BindException: Address already in use: JVM_Bind)
What can I do to resolve this?
There is already another ActiveMQ instance running so the new one cannot bind to that server socket just as the exception tells you. Kill the previous instance and then you can start a new one.

Resources