Spring Boot JMS listener won't deploy on EAP 7.3 (JBoss/Wildfly) - spring-boot

I'm trying to deploy on EAP 7.3 (ex JBoss, commercial release of Wildfly) an JMS listener like below:
...
#JmsListener(destination = "${jms.destination.name}")
public void onMessage(final Message msg) throws JMSException {
logger.info("*** MessageReceiver.onMessage(): got message {}", ((TextMessage) msg).getText());
}
...
Deploying it on the app server I get the following warning:
2021-06-03 15:57:45,836 WARN [org.springframework.jms.listener.DefaultMessageListenerContainer] (DefaultMessageListenerContainer-7) Setup of JMS message listener invoker failed for destination 'jms.queue.BanQ' - trying to recover. Cause: There is no queue with name jms.queue.BanQ
The deployment gets stuck and the warning above is displayed continuously, every couple of seconds.
So what seems to happen is that the mention queue doesn't exist. However, looking in the console I can see that:
So, as shown in the figure above, the queue named jms.queue.Bank exists. What might be the problem here ?
Many thanks in advance for any help.
Kind regards,
Seymour

Related

Spring data rabbitmq #RabbitListener suddenly stopped consuming en-queued messages

I am using spring boot 2.1.1 release and spring-boot-starter-amqp , the ##RabbitListener stopped consuming messages although it was working fine. When i restarted the consumer API , it starts to work fine.
Also from the management UI, it shows no consumers on this queue
Java 1.8 version
RabbitMQ 3.7.11 cluster (3 nodes)
Kubernetes
No Exception at the java client side or rabbitmq server side.
Heartbeates and keepalive with default values
I tried to re-synchronize the queue via rabbitmqctl, but it still not working.
#Component
public class Receiver {
Logger logger = Logger.getLogger(Receiver.class);
#RabbitListener(queues="test")
public void recievedMessage(String msg) {
logger.info("Recieved Message: " + msg);
}
}
The most common cause, by far, for problems like this is the container thread is "stuck" somewhere in user code - either in the listener, or code called by the listener; e.g. a deadlock.
First step is to take a thread dump the next time it happens to see what the listener container thread(s) are doing.

Starting Spring Boot application without check for Kafka Server

I have got an application that uses SpringBoot 2.10.0.Release and kafka in the version 2.10.0. The application has got a simple producer and consumer: The sender works with KafkaTemplate and the consumer with KafkaListener.
What I try to achieve is to be able to start the SpringBoot application even if the KafkaServer is not running.
Currently without a running KafkaBroker the application cannot be started with this error message:
org.springframework.context.ApplicationContextException:
Failed to start bean 'org.springframework.kafka.config.internalKafkaListenerEndpointRegistry';
nested exception is org.apache.kafka.common.errors.TimeoutException
Is there a way to achieve this and if yes could anybody give me hint or a keyword how to manage this?
When running the Spring-Boot application with a KafkaListener, the listener will per default try to listen to Kafka. If the KafkaBroker is invalid or missing, then you will get a org.apache.kafka.common.KafkaException.
You can change the default behaviour of the container factory by setting the autoStartup property to false. One way to do this is by adding autoStartup = "false" element to your KafkaListener annotation:
#KafkaListener(topics = "some_topic", autoStartup = "false")
public void fooEventListener(){
Now your spring boot application will start. You will still get an error when trying to use the KafkaListener if the broker is still down or invalid, but you will now be able to handle the error within your Java code instead of a Spring Boot server crash.
Documentation about KafkaListner autoStartup element.
It have to be mentioned that the error you are receiving (TimeoutException) is not because the broker is down, it is what Kafka will throw if the buffer is full.
The batch records will then be removed from the queue and will not be delivered to the broker. This error will not be the reason for you application using Kafka not to start.

Spring JMS CachingConnectionFactory doesn't seem to reconnect on exception

The JMS connection didn't get reconnected when this exception happened:
2014-08-16 10:51:36,724 WARN [TIBCO EMS TCPLink Reader (Server-12486338)] connection.CachingConnectionFactory - Encountered a JMSException - resetting the underlying JMS Connection
javax.jms.JMSException: Connection has been terminated
at com.tibco.tibjms.Tibjmsx.buildException(Tibjmsx.java:502)
at com.tibco.tibjms.TibjmsConnection._onDisconnected(TibjmsConnection.java:2286)
at com.tibco.tibjms.TibjmsConnection$ServerLinkEventHandler.onEventDisconnected(TibjmsConnection.java:341)
at com.tibco.tibjms.TibjmsxLinkTcp$LinkReader.work(TibjmsxLinkTcp.java:320)
at com.tibco.tibjms.TibjmsxLinkTcp$LinkReader.run(TibjmsxLinkTcp.java:247)
2014-08-16 10:51:40,286 WARN [TIBCO EMS TCPLink Reader (Server-12494013)] connection.CachingConnectionFactory - Encountered a JMSException - resetting the underlying JMS Connection
javax.jms.JMSException: Connection has been terminated
at com.tibco.tibjms.Tibjmsx.buildException(Tibjmsx.java:502)
at com.tibco.tibjms.TibjmsConnection._onDisconnected(TibjmsConnection.java:2286)
at com.tibco.tibjms.TibjmsConnection$ServerLinkEventHandler.onEventDisconnected(TibjmsConnection.java:341)
at com.tibco.tibjms.TibjmsxLinkTcp$LinkReader.work(TibjmsxLinkTcp.java:320)
at com.tibco.tibjms.TibjmsxLinkTcp$LinkReader.run(TibjmsxLinkTcp.java:247)
The exact same error happened a few seconds apart and I wonder if Spring tried to reconnect and gave up after two tries.
I checked Spring source code and didn't find reconnection logic in onException() method in either CachingConnectionFactory or its parent class SingleConnectionFactory. We're using spring-jms 3.1.2 but I looked at the latest Spring source code as well.
Thanks for your help.
I had similar issue where DefaultMessageListenerContainer is unable to reconnect once an exception happens(when TIBCO primary server stops and switch over to secondary TIBCO server).
I was using SingleConnectionFactory and it was causing the issue.
Fetching the connectionFactory directly from Websphere using java:comp/env/jms/TIBCOConnectionFactory resolved this issue.

why message getting re-delivered to a MDB

We have a MDB running on weblogic 12c with the following definition
#TransactionManagement(TransactionManagementType.BEAN)
#MessageDriven(activationConfig = { #ActivationConfigProperty(propertyName = "destinationType", propertyValue = "javax.jms.Queue") })
public class NonPersistentSalesMessageBean implements MessageListener
{
}
The functionality of this bean is
Receives the message
uses session beans for all business logic (session bean in turn use entity beans(JPA2.0))
reply with the response message back to the destination queue
The bean is receiving duplicate messages frequently. As stated earlier there are some exceptions at the entity bean level while inserting into the database but that's not related to the reply message. The MDB is successfully posting the response back to the destination queue but after 6 or 7 seconds am seeing the same message being sent again.
Why is the message getting redelivered when the app is successfully sending the response back to the destination queue?
Can someone please tell me what are the scenarios for a message to be redelivered ?
I can check using message.getJMSRedelivered() but would like to understand why is this getting redelivered? any help or answer s will be highly appreciated. please
Please note this is a MDB which was running fine on weblogic 10 and we upgraded to 12c when we started to have this issue. So we reverted to weblogic 10 and now its back to working fine.
Thanks...Venkat

org.apache.activemq.ActiveMQConnectionFactory cannot be cast to javax.jms.QueueConnectionFactory

I have integrated JMS in my project and getting the Exception as ActiveMQConnectionFactory cannot be cast to javax.jms.QueueConnectionFactory while calling the JMS receiver from servletcontext listener but it works fine from public static void main method and able to receive message from queue asynchronously.I am able to send the message to queue using queueconnection and queuesession from my web app and using the same qconnection approach in JMS receiver function which implements MessageListener interface.
Can any one suggest me what is the best way to start the JMS receiver or consumer automatically when web app starts because i use servletcontextlistener to start listening the message queue automatically.
(both JMS queuesender and queuereceiver works fine from public static void main method and problem starts only after calling the queuereceiver from contextinitialize method)
Maybe this post can help you.
The cause there were two version of the ActiveMQ-jars in the classpath, said the poster.
In my case, the cause was 2 versions of javax.jms in the classpath: the one that came with ActiveMQ, and the one I was using to compile my sources (ActiveMQ is supposed to be just a test dependency for my application). I changed the scope of my maven dependency javax.jms:jms:1.1 from compile to provided, which removed the javax.jms-jar from my WAR file, and the exception disappeared.
Yes there's a version problem, I was able to fix this problem by using these version of activemq, jms and j2ee dependencies.
ActiveMQ 5.8.0 and above
activemq-broker-5.8.0
activemq-client-5.8.0
geronimo-jms_1.1_spec-1.1.1
geronimo-j2ee-management_1.1_spec-1.0.1
Earlier version of ActiveMQ
activemq-core-5.5.1
geronimo-j2ee-management_1.0_spec-1.0
geronimo-jms_1.1_spec-1.1.1
Check the versions it'll help

Resources