Spring Stomp websockets with activemq client - spring

I am trying to build a stomp websocket and use amazon activemq service.
it provides 2 url (one in case of failure) and I was wondering if I could use the ActiveMQConnectionFactory to setup the message broker.
so, basically inside DelegatingWebSocketMessageBrokerConfiguration use ActiveMQConnectionFactory to set the client on the stompBroker, instead of or along the ReactorNettyTcpClient.
Basicaly I want to take advantage of the failure recovery url in aws mq.

Related

Bridge between two WebSocket STOMP servers

We have an ActiveMQ server and our own API with WebSocket/STOMP service endpoint.
Is there a way to configure ActiveMQ to connect and subscribe to a topic in our API and then publish the messages in ActiveMQ?
If not, are there any other WebSocket/STOMP bridge components which could be used to achieve the same thing (subscribe to a topic in our API and post messages to a topic in ActiveMQ)?
The motivation of all this is... complicated.
ActiveMQ natively supports Camel routes. You could potentially use Camel's STOMP component to subscribe to your own STOMP endpoint and then send those messages to a local destination.

Performance issues with ActiveMQ Artemis and Spring JmsTemplate

While doing some load tests with the ActiveMQ Artemis broker and my Spring Boot application I am getting into performance issues.
What I am doing is, sending e.g. 12,000 messages per second to the broker with JMSeter and the application receives them and saves them to a DB. That works fine. But when I extend my application by a filter mechanism, which forwards events after saving to DB, back to the broker using jmsTemplate.send(destination, messageCreator) it goes very slow.
I first used ActiveMQ 5.x and there this mechanism works fine. There you could configure the ActiveMQConnectionFactory with setAsyncSend(true) to tune performance. For the ActiveMQ Artemis ConnectionFactory implementation there is no such a possibility. Is there another way to tune performance like in ActiveMQ 5.x?
I am using Apache ActiveMQ Artemis 2.16.0 (but also tried 2.15.0), artemis-jms-client 2.6.4, and Spring Boot 1.5.16.RELEASE.
The first thing to note is that you need to be very careful when using Spring's JmsTemplate to send messages as it employs a well-known anti-pattern that can really kill performance. It will actually create a new JMS connection, session, and producer for every message it sends. I recommend you use a connection pool like this one which is based on the ActiveMQ 5.x connection pool implementation but now supports JMS 2. For additional details about the danger of using JmsTemplate see the ActiveMQ documentation. This is also discussed in an article from Pivotal (i.e. the "owners" of Spring).
The second point here is that you can tune if persistent JMS messages are sent synchronously or not using the blockOnDurableSend URL property, e.g.:
tcp://localhost:61616?blockOnDurableSend=false
This will ensure that persistent JMS messages are sent asynchronously. This is discussed further in the ActiveMQ Artemis documentation.

Amazon MQ transforming AMQP message to JMS

I have a Python and Java Spring application communicating 2 ways. The stack is mostly built on Java/Spring so ActiveMQ and JMS were the logical choices. However, we added a Python application that needed to interact with the rest of the services so I used qpid proton (AMQP library) and added the following configuration inside the ActiveMQ configuration to get it working:
<transportConnectors>
<transportConnector name="openwire" uri="ssl://0.0.0.0:61617?maximumConnections=1000&wireFormat.maxFrameSize=104857600"/>
<transportConnector name="amqps" uri="amqp+ssl://0.0.0.0:5671?maximumConnections=1000&wireFormat.maxFrameSize=104857600&transport.transformer=jms"/>
</transportConnectors>
which worked flawlessly on ActiveMQ and allowed to send/receive JMS TextMessage with an AMQP client.
Unfortunately, Amazon MQ refused this configuration and returned the following error:
The value 'amqp+ssl' of attribute 'name' on element 'transportConnector' is not valid with respect to its type, 'protocol'. and cvc-enumeration-valid: Value 'amqps' is not facet-valid with respect to enumeration '[openwire]'
AWS markets Amazon MQ as a managed ActiveMQ service but they seem to be lacking in functionalities since the mapping from AMQP to JMS has been available since version 5.8: https://activemq.apache.org/amqp and the Amazon MQ broker that I'm using is at version 5.15.12
I have tried adding the amp;transport.transformer=jms and transport.transformer=jms headers to the query string of the broker's URL, as well as using STOMP as the protocol (since it is a plain-text protocol) in the Python app instead of AMQP but none of these worked.
So, do you know any potential missing configurations or other ways I could send an AMQP message in my Python app and receive a JMS TextMessage in the Java app?
By default in the open source ActiveMQ 5.x code the AMQP transport already defaults to the JMS transformation so unless the Amazon version has altered that you shouldn't need to even set that explicitly if you want JMS transforms of the inbound AMQP messages. If they've altered that then you'd need to contact them to determine how to change that configuration.

Spring Integration - ActiveMQ to Kafka

I am currently trying to write an adapter which will consume messages from ActiveMQ and publish it to Kafka.
I am thinking of using spring integration to integrate these two messaging systems.
My problem is that my application will not maintain registry of the Models using which many applications will publish the records to activeMQ. I want to receive these javax jms message and want to perform some transformation like adding jmscorrelationId into kafka message.
ALso, another requirement is to send acknowledgement to active mq only when kafka send/publish is successfull.
Can ack be send back to activemq using spring integration?
Will spring integration be a good option?
Kindly note my tech architect is not in favor of using Camel/Mule. Also, he does not want to use Kafka Connect as i was planning to use Kafka connect source.
Please suggest.
The Spring Integration Kafka extension project has a sync mode for publishing, which will block the thread until Kafka confirms delivery (or throw an exception on a failure).
The JMS inbound gateway can be used to return a reply to a JMS queue.
You can add transformers (or whatever) in the flow to modify the message.

How to get properly all queue messages from RabbitMQ in Spring?

I am using Spring, Spring-Websocket, STOMP for my application, and RabbitMQ as broker. I need to log all messages going through RabbitMQ to Postgresql tables.
I know that I can write #MessageMapping in Spring and log there, but my problem is that some clients talk to RabbitMQ directly through MQTT protocol, and Spring does not support it yet (https://jira.spring.io/browse/SPR-12581). Moreover browser clients talk through Spring to RabbitMQ using STOMP protocol.
RabbitMQ allows to track all messages using Firehose tracer. How to properly listen to amq.rabbitmq.trace topic from Spring? Or do I need to write separate Java app as consumer?
The Spring AMQP is for you!
You bind some custom queue to to that amq.rabbitmq.trace with appropriate pattern (e.g. publish.#) and configure SimpleMessageListenerContainer to receive messages from that queue.
It can be done even with pretty simple config: #EnableRabbit and #RabbitListener on some POJO method. Anyway the Binding #Bean must be there to attache your queue to that exchange.

Resources