Re: PG-MQ?

From: "Marko Kreen" <markokr(at)gmail(dot)com>
To: "Jeroen T(dot) Vermeulen" <jtv(at)xs4all(dot)nl>
Cc: "Chris Browne" <cbbrowne(at)acm(dot)org>, pgsql-hackers(at)postgresql(dot)org
Subject: Re: PG-MQ?
Date: 2007-06-20 10:58:20
Message-ID: e51f66da0706200358q4172958ch724a783a691045e8@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On 6/20/07, Jeroen T. Vermeulen <jtv(at)xs4all(dot)nl> wrote:
> On Wed, June 20, 2007 04:45, Chris Browne wrote:
> > - Sometimes you have the semantics where:
> > - messages need to be delivered at least once
> > - messages need to be delivered no more than once
> > - messages need to be delivered exactly once
>
> IMHO, if you're not doing "exactly once," or something very close to it,
> you might as well stay with ad-hoc code. You can ensure single delivery
> by having the sender re-send when in doubt, and keeping track of
> duplications in the recipient.

In case of PGQ, the "at least once" semantics is related to batch-based
processing it does - in case of failure, full batch is delivered again,
so if consumer had managed to process some of the items already, it gets
them double.

As it is responsponsible only for delivering events from database,
it has no way of guaranteeing "exactly once" behaviour, that needs
to be built on top of PGQ.

Simplest case would be if the events are processed in same database
that the queue resides. Then you can just fetch, process, close batch
in one transaction and immidiately you get "exactly once" behaviour.

To achieve "exactly once" behaviour with different databases, look
at the "pgq_ext" module for sample. Basically it just requires
storing batch_id/event_id on remote db and committing there first.
Later it can be checked if the batch/event is already processed.

It's tricky only if you want to achieve full transactionality for
event processing. As I understand, JMS does not have a concept
of transactions, probably also other solutions mentioned before,
so to use PgQ as backend for them should be much simpler...

To Chris: you should like PgQ, its just stored procs in database,
plus it's basically just generalized Slony-I, with some optimizations,
so should be familiar territory ;)

--
marko

In response to

  • Re: PG-MQ? at 2007-06-20 07:45:57 from Jeroen T. Vermeulen

Responses

  • Re: PG-MQ? at 2007-06-20 11:18:31 from Heikki Linnakangas
  • Re: PG-MQ? at 2007-06-20 15:32:57 from Chris Browne

Browse pgsql-hackers by date

  From Date Subject
Next Message Heikki Linnakangas 2007-06-20 11:18:31 Re: PG-MQ?
Previous Message Markus Schiltknecht 2007-06-20 10:37:42 Re: PG-MQ?