RabbitMQ and Spring: how to get all subscriptions - java

I'm using RabbitMQ, Spring and SockJS.
My app generatea many different messages and posts them to rabbitmq via stomp. This generation requires a lot of resources so I want to know is there any subscriptions to rabbitmq and what kind of subscription it is (I need to know routing keys of this subscriptions) to avoid generating unnecessary messages.
Is there any possibilities to get this information from Spring or any Java client library?

You can find all the information using one or more of the following
command line tool rabbitmqctl
rabbitmq http api
rabbitmq management (web ui)

There is a library to get information from rabbitmq http api https://github.com/rabbitmq/hop

Related

Ways to implement Google Pub Sub

I found these 3 ways for implementing messaging with Google Pub Sub:
with client libraries
https://cloud.google.com/pubsub/docs/publisher
with spring integration message channels and PubSubTemplate API
https://dzone.com/articles/spring-boot-and-gcp-cloud-pubsub
without message channels but with PubSubTemplate API
https://medium.com/bb-tutorials-and-thoughts/gcp-how-to-subscribe-and-send-pubsub-messages-in-spring-boot-app-b27e2e8863e3
I want to understand the differences between them / when each is best to use and which would be useful for my case.
I have to implement a single Topic and a single Subscription to get the queue functionality. I think I'd rather not use Spring message channels if not needed , they seem to intermediate the communication between Pub Sub topic and the subscription and I don't want that. I want things simple , so I think the option 3 would be best but I am also wondering about option 1.
Option 1, client libraries, is universal. You don't need Spring to run it, you can use this library in Groovy or in Kotlin also.
Option 2, it's deeply integrated to Spring. It's quite invisible but if you have special thing to do, it's tricky to override this implementation
Option 3, it's a light spring integration. PubSubTemplate (the client in fact) is loaded automatically for you at startup, as any bean and you can use it easily in your code. It's my preferred option when I use Spring.
Google Cloud Pub/Sub Using Client Libraries :
Using Google Cloud Pub/Sub with Client libraries is one of the standard and easiest way to implement Cloud Pub/Sub.
A producer of the data publishes messages to Pub/Sub topic, a subscriber client then creates a subscription to that topic and consumes messages.
You need to install the client libraries. You can follow this setup and tutorial for further information.
Here you won't require Spring integration, you can directly use the client library to publish messages and pull it from subscription.
Spring Integration using spring channels :
This use case involves intensive integration of Spring Boot Application with Google Cloud Pub/Sub using Spring Integration to send and receive Pub/Sub messages. ie. Pub/Sub acts as intermediate messaging system
Here The Spring Application sends messages to Cloud Pub/Sub topic utilizing spring channels and the Application further receives messages from Pub/Sub through these channels.
Pub/Sub message in Spring-Boot App :
This use case is a simple and valid example of integrating Cloud Pub/Sub with Spring boot application.
The use case demonstrates how to subscribe to a subscription and send message to topics using Spring Boot Application
Message is published to the topic, queued in the respective subscription and then received by the subscriber Spring Boot Application

Making a request response queue with Azure Java SDK

I'm trying to implement something similar to https://code.msdn.microsoft.com/Brokered-Messaging-Request-0ce8fcaf#content in Java, but can't find functionality from the Service Bus Java SDK to match the QueueClient.AcceptMessageSession used in the example.
So how can I make the client to poll the response queue only for messages that match the expected sessionId? Do I need to create a seperate response queue for each client? Or is it best practise to re-insert non matching messages back to the queue?
I'm using the com.microsoft.azure/azure-servicebus maven package version 0.9.3.
Seems that this feature is not supported in the Java SDK because it uses the service bus REST api instead of the WFC api. Topic/Subscription way might be the only way to implement this with the Java SDK.
More detail: https://github.com/Azure/azure-sdk-for-java/issues/246
#HannuHuhtanen, in my mind, I think the solution is that using two JMS connections to seperately connect two service bus queues for a continuous WebJob as server and clients, please try to refer to the tutorial to know how to use JMS with AMQP for ServiceBus.

How to manage messages in apache ActiveMQ

I have Apache ActiveMQ embedded into my java 8 server side project. Its working fine, and I am able to send and consume messages from pre-configured queues. I now need to be able programatically remove messages from the queue upon request. After reading some docs I found that Apache ActiveMQ has a sub-project called Artemis that seems to provide the required functionality. But I am a bit confused on how to do it. Is Artemis sort of plugin on top of ActiveMQ and I just need to add required dependencies and use the tools or is it a separate product and it doesn't work with Active MQ but as an independent product. If so how do I manage individual messages (in particular delete requested message) in Active MQ?
First off, 'ActiveMQ Artemis' is a sub-project within the ActiveMQ project that represents an entirely new broker with a radically different underlying architecture than the main ActiveMQ broker. You would run one or the other.
To manage messages in the ActiveMQ broker you would use the JMX Mamagement API and the Queue#remove methods it exposes to remove specific messages. This can be done using the Message ID or more broadly using a message selector to capture more than one message if need be. The JMX API is also exposed via Jolokia so that you can manage the broker via simple REST calls instead of the JMX way if you prefer.
In any case this sort of message level management on the broker is a bit of an anti-pattern in the messaging world. If you find yourself needing to treat the broker as a database then you should ask yourself why you aren't using a database since a broker is not a database. Often you will run into many more issues trying to manage your messages this way as opposed to just putting them into a database.

Spring STOMP Java client and server pub/sub topic

I am looking for an example or code snippets on using Spring's STOMP topic pub/sub messaging, with both the client and server in the same tomcat7 instance. NOT OVER THE WEBSOCKET.
We want to handle some operations asynchronously in our server side and so want to use STOMP as our messaging protocol in our tomcat7 instance. Everywhere I look I find samples for STOMP over websocket or integrating with other MOM's!!
Anyone know about a java sample for simple spring stomp pub/sub? Appreciate any pointers...Thanks.
Have a look at the Spring Websocket Portfolio application. Yes, I know you said not over websocket, but the application has some tests that use a STOMP client/server that might just be what you are looking for.

How do I get a java application to subscribe to an NServiceBus publisher?

I've asked Google and searched through the NServiceBus website and forums, but I can't seem to find any prescriptive guidance on how I would write a Java application to subscribe to a publisher. Does anyone have any such link or experience?
This scenario is not well supported out of the box - you'll need to do some infrastructure munging yourself. In general, look at how the proxy is built, and add some gateway-style HTTP communication in the mix, or expose that with a standard .NET webservice.
You could manually send the subscribe message to the publisher over MSMQ, the publisher would then send any relevant messages to your java subscribers input queue. But you would need to receive those manually also.
I guess you're then committed to using MSMQ as your transport layer for your entire bus also.

Categories

Resources