C ++ and JMS - how to connect them?

I am new to C ++, but have a lot of experience in Java EE.

I need to write a small application that is very asynchronous. It receives data from HTTP and stores it in a queue (it must have guaranteed delivery and very high bandwidth), something like ActiveMQ or OpenMQ, possibly through JMS.

Then another C ++ application / listener extracts data from the queue (through some Listener, which is activated directly in the queue, not by the pool), connects to the MySQL database and performs some business logic calculations and sends a message to another Queue.

In Java EE, this will be a web application that will send messages to the JMS queue. Message-Driven Beans will be the consumer of these messages in the EJB module, and Session EJB will send messages to the outgoing JMS queue.

Can anyone with C ++ experience explain some basics to me:

  • Is JMS the only option for C ++ for guaranteed delivery queues? Do you offer ActiveMQ or something else, bearing in mind that the message "Consumer" will be in C ++.

  • Do I need to create some kind of multithreaded daemon in C ++ that listens for Queue messages or is it part of creating a stream (message consumption) for the ActiveMQ implementation of C + consumers?

Any other suggestions on how to implement the above scenario would be greatly appreciated.

EDITED: I would prefer the message broker and client to be in C ++. ActiveMQ is a Java product that we don’t really need.

+6
source share
1 answer

1 - JMS - Java Message Service is just a reference to the API for Java and Java only. There is no standard in messaging that applies to C ++, with the exception of AMQP (which, in my opinion, is not very effective for cross-implementation). For C ++, you need to rely on specific provider libraries for each message broker implementation.

Implementation Suggestions:

  • ActiveMQ - it has a good C ++ API (Called CMS), which is modeled and called after JMS, so you will be familiar with the API. The main broker will work in Java no less - maybe the easiest choice.

  • IBM WebSphere MQ is not an open source enterprise-class broker that runs its own (written in C) and has C ++ libraries. It's pretty nice when you overcome the learning curve, and the price does not matter.

  • RabbitMQ is a very popular and reliable open source, high-performance messaging engine. It has C ++ client libraries, but is written in Erlang and runs in the erlang / otp runtime.

  • Apache QPID - Less well-known AMQP / JMS agent. It comes in two versions on the server side, Java and C ++, where the C ++ broker has the best performance. Comes with C ++ client libraries.

2 - For multithreading, JMS specifications do not really have a solution. This is more like a Java EE (or Spring Framework) container that simply wraps flow control and frees the developer from it. In this case, ActiveMQ does not ship as much as several support classes, and as far as I know, none of the other vendor libraries does. So, find some library that wraps flows (I have no idea) or deal with consumer flows themselves. It doesn’t have to be all this dirty, done right.

+18
source

Source: https://habr.com/ru/post/924385/


All Articles