Message Attributes and Payload in RabbitMQ - rabbitmq

I am using AMQP Java client i want to use message attributes properties like ,Message priority,Delivery mode, Message publishing timestamp,Expiration period, etc.how to set it on channel.basicPublish();

Have you looked through the RabbitMQ tutorials (http://www.rabbitmq.com/getstarted.html) they have lots of good examples which are in both java and python which should give you a good basis to start using RabbitMQ

Related

Publisher confirmations not working when using MassTransit, rabbitmq-message-deduplication plugin, and RabbitMQ

Using RabbitMQ 3.8.14 and 0.5.0 of the plugin
https://github.com/noxdafox/rabbitmq-message-deduplication
Along with the MassTransit library in C#.
If I set up a queue to use deduplication it seems that I can only get it to work if I turn off the publisher confirms.
With publisher confirms set to true (the default and desired setting) then when a duplicate is sent I get an exception like the following
MassTransit.RabbitMqTransport.MessageNotAcknowledgedException
If I set it to false then duplicates are filtered out and things work as expected.
I would like to have the deduplication and the message confirmations working if possible.
MassTransit with publisher confirm is not supported by the plugin.
This is due to the fact the library is asking to confirm the message was published into the queue. As the message is a duplicate, it will not be published within the queue. The plugin informs the Broker of this fact and the Broker sends a negative acknowledgement back to the library.
As the Broker does not support complex notifications semantics, there is no simple way to sort this out. In other words, the Broker can only state whether the messages was published in the queue. It cannot provide any extra information in regards.
You can find a lengthy explanation of the above in this comment.

Is there any way to read messages from Kafka topic without consumer?

Just for testing purpose, I want to automate scenario where I need to check Kafka messages content, so just wanted to know if it is possible to read messages without consumers directly from TOPIC using Kafka java libraries?
I'm new to Kafka so any suggestion will be good for me.
Thanks in advance!
You could SSH to the broker in question, then dump the log segments into a deserialized fashion, but it would take less time to simply use a consumer in any language, not necessarily Java
"For testing purposes" Kafka Java API provides MockProducer and MockConsumer, which are backed by Lists, not a full broker

When to use REST API, when to use Messaging Service (e.g RabbitMQ) in exchanging data between Microservices?

I am building a system using microservices architecture, using RabbitMQ as the messaging service.
I have a use cases of communication between 2 services and face the difficulties of using RabbitMQ to implement it.
Cart-Service needs to get data from Product-Service. In this case Cart-Service can send a message, Product-Service subscribes to that message. But I find no way for Product-Service to send back the data to Cart-Service.
May you let me know whether my approach of using RabbitMQ in this case is correct?
Any other approach I should apply in this use case?
Thank you in advance.
Use an event-driven naming convention for your rabbitMQ message routes. The format can be <service>.<entity>.<action>, e.g. "cart.item.added".
Cart service subscribes to product.*.* messages, Product service - to the cart.*.* ones.
The workflow might be the following:
cart: publishes "cart.item.added" message.
product: receives "cart.item.added" message, publishes "product.product.read" one
cart: receives "product.product.read" message with the product info.
If you're using Node.js for the microservices, you could read more on how to prototype RabbitMQ message exchange here:
https://medium.com/#krawa76/bootstrap-node-js-microservice-stack-4a348db38e51

What is difference between a Message Queue and ESB?

I was just reading about Enterprise Service Bus and trying to figure out how to implement it. However, the more I read about it, my conclusion was that it is just a glorified message queue.
I read about it here: What is an ESB and what is it good for?
We use RabbitMQ in our architecture quite a lot and what I was having hard time understanding was that there any many similarities between both concepts:
Both are basically post and forget
You can post a message of any format in both queues
My question is that what is it that an ESB does and RabbitMQ is not able to do?
I have not used RabbitMQ so I wont be able to comment on it. I have used ESB and currently using it.
ESB: It provides you multiple ways of subscribing to your message.Its mostly useful in Publisher-Subscriber model in which topics and subscription is used. You can publish your message payload in topics(similar to queues). Unlike a queue,topic provides us with capability to have more than one subscription for a single topic. This subscription can be divided based on your business need and you can define some kind of filter expression on those topic (also called channel)and with the specified filter a proper subscriber will pull the message from bus. Also one single message can be subscribed by multiple subscriber at a time. If no filtering is used on topics then it means all subscriber for that topic will pull the message from the channel.
This is asynchronous mechanism as you mentioned, post and forget. There is a retry mechanism in ESB where you can try subscribing the message for some number of times I think its 10 times(max) after which its sent in dead queue.
So if your requirement is to connect multiple enterprise system with loosely couple architecture then ESB is a good option.
I hope this was helpful to know about ESB

ActiveMQ + NMS can't receive messages

I'm trying to consume messages on an ActiveMQ topic from a C# application. I'm using the 1.3 .net release, and I don't receive any messages.
I have existing code that uses older libraries (and libraries built on top of libraries that I don't want to use or upgrade) that work fine, so I know messages are travelling along the topic, but my simple program with newer libraries just doesn't see them.
I'm using code copied and pasted from http://remark.wordpress.com/articles/publish-subscribe-with-activemq-and-nms/ as my test. The SimpleTopicSubscriber (with a simple change to make it a non-durable consumer) just doesn't receive anything. The SimpleTopicPublisher works just fine - I can send a simple message and it gets through, no problem.
Looking at the JMX console, I can see my subscriber connect, see that it's on the right topic, but it just doesn't get any messages.
Any ideas? I've even tried using the 1.2 libraries, but that didn't make any difference.
Thanks
Matt
Turns out there were 2 problems. I edited the example code incorrectly and passed in a durable consumer id instead of a selector. Not terribly clever.
Once I'd fixed this, I could receive messages, but only with the 1.1 release of the NMS/ActiveMq dlls. I couldn't receive messages with version 1.2 or 1.3.
But if I pass wireformat.version=2 as a parameter when connecting, everything works ok. The broker is 5.0.0 and I strongly suspect this would work ok with a later version of the broker.
Thanks
Matt
There are a couple reasons why your client might not be receiving messages, one could be that you didn't call Connection.Start(), without that the message pump won't start dispatching messages to your client. The other reason might be that your now non-durable Topic subscriber was started after the publisher in which case there'd be no messages delivered since you are using a Topic and Topics are like queue's in that once a message is sent its forgotten about so a subscriber that joins up later doesn't receive any messages that were sent before it subscribed.
Regards
Tim.
Open Source Integration: http://fusesource.com