<?xml version="1.0" encoding="utf-8"?>
<feed xml:lang="en-us" xmlns="http://www.w3.org/2005/Atom"><title>Simon Willison's Weblog: sqs</title><link href="http://simonwillison.net/" rel="alternate"/><link href="http://simonwillison.net/tags/sqs.atom" rel="self"/><id>http://simonwillison.net/</id><updated>2024-07-31T17:34:54+00:00</updated><author><name>Simon Willison</name></author><entry><title>Build your own SQS or Kafka with Postgres</title><link href="https://simonwillison.net/2024/Jul/31/sqs-or-kafka-with-postgres/#atom-tag" rel="alternate"/><published>2024-07-31T17:34:54+00:00</published><updated>2024-07-31T17:34:54+00:00</updated><id>https://simonwillison.net/2024/Jul/31/sqs-or-kafka-with-postgres/#atom-tag</id><summary type="html">
    
&lt;p&gt;&lt;strong&gt;&lt;a href="https://blog.sequinstream.com/build-your-own-sqs-or-kafka-with-postgres/"&gt;Build your own SQS or Kafka with Postgres&lt;/a&gt;&lt;/strong&gt;&lt;/p&gt;
Anthony Accomazzo works on &lt;a href="https://github.com/sequinstream/sequin"&gt;Sequin&lt;/a&gt;, an open source "message stream" (similar to Kafka) written in Elixir and Go on top of PostgreSQL.&lt;/p&gt;
&lt;p&gt;This detailed article describes how you can implement message queue patterns on PostgreSQL from scratch, including this neat example using a CTE, &lt;code&gt;returning&lt;/code&gt; and &lt;code&gt;for update skip locked&lt;/code&gt; to retrieve &lt;code&gt;$1&lt;/code&gt; messages from the &lt;code&gt;messages&lt;/code&gt; table and simultaneously mark them with &lt;code&gt;not_visible_until&lt;/code&gt; set to &lt;code&gt;$2&lt;/code&gt; in order to "lock" them for processing by a client:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;with available_messages as (
  select seq
  from messages
  where not_visible_until is null
    or (not_visible_until &amp;lt;= now())
  order by inserted_at
  limit $1
  for update skip locked
)
update messages m
set
  not_visible_until = $2,
  deliver_count = deliver_count + 1,
  last_delivered_at = now(),
  updated_at = now()
from available_messages am
where m.seq = am.seq
returning m.seq, m.data;
&lt;/code&gt;&lt;/pre&gt;

    &lt;p&gt;&lt;small&gt;&lt;/small&gt;Via &lt;a href="https://lobste.rs/s/ap6qvh/build_your_own_sqs_kafka_with_postgres"&gt;lobste.rs&lt;/a&gt;&lt;/small&gt;&lt;/p&gt;


    &lt;p&gt;Tags: &lt;a href="https://simonwillison.net/tags/message-queues"&gt;message-queues&lt;/a&gt;, &lt;a href="https://simonwillison.net/tags/postgresql"&gt;postgresql&lt;/a&gt;, &lt;a href="https://simonwillison.net/tags/sql"&gt;sql&lt;/a&gt;, &lt;a href="https://simonwillison.net/tags/sqs"&gt;sqs&lt;/a&gt;, &lt;a href="https://simonwillison.net/tags/kafka"&gt;kafka&lt;/a&gt;&lt;/p&gt;



</summary><category term="message-queues"/><category term="postgresql"/><category term="sql"/><category term="sqs"/><category term="kafka"/></entry><entry><title>Mass Video Conversion Using AWS</title><link href="https://simonwillison.net/2007/Apr/3/amazon/#atom-tag" rel="alternate"/><published>2007-04-03T23:44:37+00:00</published><updated>2007-04-03T23:44:37+00:00</updated><id>https://simonwillison.net/2007/Apr/3/amazon/#atom-tag</id><summary type="html">
    
&lt;p&gt;&lt;strong&gt;&lt;a href="http://developer.amazonwebservices.com/connect/entry.jspa?externalID=691"&gt;Mass Video Conversion Using AWS&lt;/a&gt;&lt;/strong&gt;&lt;/p&gt;
How to use S3, SQS, EC2, ffmpeg and some Python to  bulk convert videos with Amazon Web Services.


    &lt;p&gt;Tags: &lt;a href="https://simonwillison.net/tags/amazon"&gt;amazon&lt;/a&gt;, &lt;a href="https://simonwillison.net/tags/aws"&gt;aws&lt;/a&gt;, &lt;a href="https://simonwillison.net/tags/ec2"&gt;ec2&lt;/a&gt;, &lt;a href="https://simonwillison.net/tags/ffmpeg"&gt;ffmpeg&lt;/a&gt;, &lt;a href="https://simonwillison.net/tags/python"&gt;python&lt;/a&gt;, &lt;a href="https://simonwillison.net/tags/s3"&gt;s3&lt;/a&gt;, &lt;a href="https://simonwillison.net/tags/sqs"&gt;sqs&lt;/a&gt;&lt;/p&gt;



</summary><category term="amazon"/><category term="aws"/><category term="ec2"/><category term="ffmpeg"/><category term="python"/><category term="s3"/><category term="sqs"/></entry><entry><title>boto</title><link href="https://simonwillison.net/2007/Feb/11/boto/#atom-tag" rel="alternate"/><published>2007-02-11T00:17:52+00:00</published><updated>2007-02-11T00:17:52+00:00</updated><id>https://simonwillison.net/2007/Feb/11/boto/#atom-tag</id><summary type="html">
    
&lt;p&gt;&lt;strong&gt;&lt;a href="http://code.google.com/p/boto/"&gt;boto&lt;/a&gt;&lt;/strong&gt;&lt;/p&gt;
Python library for accessing Amazon’s S3, SQS and EC2 Web Services, with excellent documentation.


    &lt;p&gt;Tags: &lt;a href="https://simonwillison.net/tags/amazon"&gt;amazon&lt;/a&gt;, &lt;a href="https://simonwillison.net/tags/aws"&gt;aws&lt;/a&gt;, &lt;a href="https://simonwillison.net/tags/boto"&gt;boto&lt;/a&gt;, &lt;a href="https://simonwillison.net/tags/ec2"&gt;ec2&lt;/a&gt;, &lt;a href="https://simonwillison.net/tags/python"&gt;python&lt;/a&gt;, &lt;a href="https://simonwillison.net/tags/s3"&gt;s3&lt;/a&gt;, &lt;a href="https://simonwillison.net/tags/sqs"&gt;sqs&lt;/a&gt;&lt;/p&gt;



</summary><category term="amazon"/><category term="aws"/><category term="boto"/><category term="ec2"/><category term="python"/><category term="s3"/><category term="sqs"/></entry></feed>