Websockets ExecutorSubscribableChannel class keeps on sending heartbeat every 15 sec - spring

I'm using spring boot 2.3.3.RELEASE with websocket support and RabbitMQ as external broker with stomp support.
The issue is that the client keeps on getting a heartbeat message "\n" every +-15 secs even though the client negotiated the heatbeat as "0, 30000" during the CONNECT request as suggested in this documentation on heart-beat header support with stomp in RabbitMQ. By turning on trace log I was able to find that ExecutorSubscribableChannel has a run() method that gets executed by a ThreadPoolExecutor every +-15 secs, which in turn sends that heartbeat message. I'm not sure if its a bug or I'm missing some configuration on my side. Any help would be appreciated.

I was able to solve this with help on feedback provided on the issue that I opened in spring-framework GitHub. Here is the link.

Related

Messages not coming to Java Camel route application in sequence

The problem I am facing is very strange. My application is a Spring Boot application where I am using a Camel route to listen to AMQ 7 and then processing the message till it gets stored in a database or sent to another AMQ 7 instance. The issue is messages are consumed from AMQ via Camel but it's not maintaining the order in application logs. This means that before the flow for first message is getting completed I could see the logs start getting printed for another message dropping into AMQ which is making it difficult to track that the logs belong to which message from AMQ. Is it a prob with AMQ or Camel routes? Any suggestions is highly appreciated.
This issue could be related to the camel route if the asyncConsumer option is enabled, see the documentation for further details https://camel.apache.org/components/latest/activemq-component.html

Spring-Kafka request/reply listener timeout

I am using Spring-Kafka and using request/reply templates. I am noticing that after awhile I encounter timeouts when one service calls the other. The only way this seems to resolve is when I change topic name from request1, reply1 to request2, reply2 and redeploy both sides.... What am I missing in the configuration of the listener and or requester side? It seems the after a period of time it goes stale

Apache Camel - IDLE AMQP1.0 Connection

I have Apache-Camel with Spring application. Application acts as a bridge between two AMQP destinations. It consumes messages from one broker and publishes it on to the other broker. Communication is done both ways over AMQP1.0 protocol.
Problem
I am facing a IDLE connection issue. After few days of operations, the consumers stops receiving messages, unless restarted. Moreover, I am not able to get any ERROR logs. This issue goes away after restart of application.
My expectation is that similar to Spring-JMS, Apache Camel shall retry connecting the consumers. Kindly guide me if I need to configure something in Camel to perform reconnection tries and do proper logging.
Camel Route COnfiguration
cmlCntxt.addRoutes(new RouteBuilder() {
public void configure() {
from("incomingOne:queue:" + inQueueOne)
.to("outGoingBroker:queue:"outQueueOne).transform(body().append("\n\n"));
from("inQueueTwo:queue:" + inQueueTwo).to("outGoingBroker:"+outQueueTwo).transform(body().append("\n\n"));
}
});
Moreover I am not having control of the brokers at both ends and am unable to check why my consumers are not receiving messages. That is why I am expecting camel ERROR logs to be informative for me to debug the issue, whether connectivity or else.
Try configuring jms.requestTimeout property at your remoteURI. by default, the requestTimeout is indefinite . So incase of any issues, it might stuck forever.
Also try using failover to connect the broker and enable debugging in application.
if you are still facing the issue, kindly edit with broker details

How should you handle the retry of sending a JMS message from your application to ActiveMQ if the ActiveMQ server is down?

So using JMS and ActiveMQ, I can be sure that my message sent from my Spring Boot application using JmsTemplate will reach it's destination application even if that destination application is down at the time I send the message to ActiveMQ. As when the destination application starts up, it grabs the message from the queue. Great!
However.
What happens if my Spring Boot application tries to send a JMS message to a queue on the ActiveMQ server, but the ActiveMQ server is down at that point or the network is down and I get a connection refused exception?
What is the recommended way to make sure my application keeps trying to re-sends the message to ActiveMQ until it is successful? Is this something I have to develop into my application myself? Are there any nifty Spring tools or annotations which do this for me? Any advice on best practice or how I should be handling this scenario?
You can try Spring-Retry. Has lots of fine grain controls for it:
http://www.baeldung.com/spring-retry
https://github.com/spring-projects/spring-retry
If it is critical that you don't lose this message, you will want to save it to some alternative persistent store (e.g. filesystem, local mq server) along with whatever retry code you come up with. But for those occasional network glitches or a very temporary mq shutdown/restart, Spring-Retry alone should do the trick.
Couple of approaches I can think of
1. You can set up another ActiveMq as fallback. In your code you don't have to do anything, just change your broker url from
activemq.broker.url=tcp://amq01.blah.blah.com:61616
to
activemq.broker.url=failover:(tcp://amq01.blah.blah.com:61616,tcp://amq02.blah.blah.com:61616)?randomize=false
The rest is automatically taken care of. i.e. when one of them is down, the messages are sent to other.
Another approach is to send to a internal queue (like seda, direct) when activemq is down and read from there.
Adding failover to the url is one appropriate way.
And another reasonable way is to making sure activemq always online , as activemq has the master-slave mode(http://activemq.apache.org/masterslave.html) to get high availability.

Setting message size for spring sockjs websocket server

I have used spring sockjs server implementation for websockets. It supports messages upto 2kb but above that the websocket connection breaks -gives an 1006 error. If I reduce the message size, then it runs ok.
I went through the docs as well as classes, but could get a place where I can increase this limit. Have asked in spring forum as well but no reply.
Any Idea?
Any stack traces in the server logs? What server? And what transport is being used (websocket, xhr-streaming, other?) For the WebSocket transport you may be hitting default limits on the message buffer. Have you seen the section on Configuring the WebSocket Engine in the documentation?
Got it resolved, the way spring document has mentioned, did not worked for me -tomcat would not pick the parameters from there. Finally getting hold of ServletServerContainerFactoryBean (which is always singleton) and setting the properties there worked for me. Details:
How to increase output buffer for spring sockjs websocket server implementation.

Resources