Win a copy of Reactive Streams in Java: Concurrency with RxJava, Reactor, and Akka Streams this week in the Reactive Progamming forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
  • Campbell Ritchie
  • Liutauras Vilda
  • Junilu Lacar
  • Jeanne Boyarsky
  • Bear Bibeault
  • Knute Snortum
  • Tim Cooke
  • Devaka Cooray
Saloon Keepers:
  • Ron McLeod
  • Stephan van Hulst
  • Tim Moores
  • Tim Holloway
  • Carey Brown
  • Piet Souris
  • Frits Walraven
  • Ganesh Patekar

Rabbit MQ In Depth question: Filtering on null values

Posts: 16
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

We are currently working on converting from HornetQ to RabbitMQ. One of the snags we ran into is regarding message filters for subscriptions.

In HornetQ, we were able to filter on headers with a null value. We were also able to filter on headers with a "not equal to" value. In RabbitMQ we are finding we are unable to do either of these things.

For example, on a single queue we might have a million messages come in on a single day. Half the messages have a header populated like "myVariable=X", the other half do not have the "myVariable" header at all.

In HornetQ land, we were able to set up a subscription to the tune of "give me messages where myVariable is NULL, or myVariable doesn't exist". This way, we only read the half million messages we care about.

In RabbitMQ we can do no such thing. Our best alternative is to read all 1 million messages and discard those which do not have "myVariable".

We looked into other options like having the other messages populated with a variable that we could do a positive check on, but this is not feasible.

Any other ideas or ways we can get around this limitation in Rabbit MQ?

Posts: 16
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Have you looked at the Headers exchange? I think it'd do the type of thing you're looking for if I'm understanding you correctly. When you're discussing a header that is populated, are you specifically talking about the header table in the AMQP message properties, or is it something in your message body?

I do not know of a filtering exchange, but it'd be fairly trivial to write a plugin that does such a thing.
Switching from electric heat to a rocket mass heater reduces your carbon footprint as much as parking 7 cars. Tiny ad:
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!