I have a few questions regarding the activemq-c implementation. I am
working with version activemq-cpp-3.4.0, and activemq-c-3.3.0.

I am migrating a workqueue out of a PostgreSQL database to ActiveMQ.
The database schema tables are simple, they contain a uuid column and
an 'attempt' column, which is an integer. Each time that the job
fails, the 'attempt' is incremented, and when a maximum is reached (or
the job is successful), it is taken out of the table.

My questions are specific to the C implementation. I am not a C++
programmer, but I could find my way around the C++ code, and help with
writing some C wrappers, if I'm pointed in the right direction.

I am placing messages onto an ActiveMQ queue from within a PostgreSQL trigger.

1. When I consume a message from a queue, is there a way to mark it as
'being-processed', without it being removed from the queue? So that
other consumers can't fetch the same message, and so that it will stay
on the queue if the consumer process crashes. I am concerned about the
gap between it being taken off the queue and processed, that if there
is a catastrophic crash, it will disappear. I want to explicitly
delete the message only if the processing is successful, otherwise it
should remain on the queue (with a property changed, see my next
question).

2. Is there a way to fetch messages from the queue based on a property
(eg in SQL, SELECT id FROM queue WHERE attempt=1)? I have set a
property on the message (setMessageIntProperty(message, "attempt", 0))
when it is first placed on the queue. I want to put the message back
on the queue, with attempt++ each time that it fails. But I also want
to just get a message if it has a certain 'attempt' value. Do I have
to take each message out of the queue, examine it for the property I
want, and then put it back on the queue if it doesn't match? Or can I
'pre-filter' the message and only get it if it matches criteria? Is
this the best way of doing it (setting a Property on the message), or
is there another way of doing what I need? For example, if there are
1000 messages, and only one of them has the property attempt=1, do I
have to go through each message until I find the matching property?

3. I have added some code to the C wrapper (specifically, a function
returning the message as an allocated buffer). Is there
somewhere/someone where I can send this code to be integrated into the
project? I imagine that some of the functionality I'm asking for above
might exist in the C++ implementation and not in the C one. I can help
to write some of that code, if there is someone who could show me
where to start.

Regards,

-- 
Jason Armstrong

Reply via email to