zato-redis-paginator is a library that has been just released and except for the init method, it's 100% API compatible with Django's own pagination but works with Redis instead of SQL databases.

Supported data types:

  • lists
  • sorted sets
  • ranges of sorted sets between min/max scores Consider the code below which uses pagination with a list.

Visit the project's home page for more information, including usage examples with other data types and have fun using it!

This how-to shows what is needed to send AMQP messages to exchanges using Zato, which is a Python-based ESB for SOA, cloud integrations and backend services.

SHOW ME THE CODE

This is the code needed:

Read below for the whole story.

UNDERSTANDING CONNECTION DEFINITIONS VS. CONNECTIONS

Before sending a first message, you need to make it known to Zato where messages will be sent as by default Zato encourages separation between services producing messages and the concrete destinations where the messages arrive.

You only invoke a single .send method in your code, without actually specifying particular URLs or credentials, message expiration, content type and so on. You can, but you don't have to.

That all is achieved by means of connection definitions and actual connections. A connection definition is a template describing details of connecting to an AMQP broker - its network address, virtual host, username/password and similar. Each connection definition can be used to create one or more connections that deal with particulars of each message sent - its priority, delivery mode and other per-message information.

Both types of objects are created using Zato's GUI or other means, such as enmasse or API.

Diagram

GUI

First create a connection definition and then use it to create an outgoing connection, as in the screenshots below.

Screenshot Screenshot Screenshot Screenshot

And that concludes it - a new connection has been created and the code shown before can be now hot-deployed in order to send AMQP messages.

OTHER MEANS OF CONFIGURATION

Instead, or in addition to, enmasse tool and API can be also used to create, list, update or delete AMQP connections. You're not limited to the GUI only.

MORE USAGE EXAMPLES

Browse the full API and more AMQP usage examples here.

A feature recently added in git development branch that will be released in 2.0 is the ability to specify services to be invoked when a server is starting up.

There's a new stanza in server.conf that lets you assign services and their payload that will be used during a sever's boot, as below.

As shown, this can be either a static string or a path to a file containing the data to invoke a service with.

This is a feature that will be added in much a broader scope - along with GUI, API and more usage examples - in next releases, but for 1.1, a zato-labs project is provided to support an invoke/retry pattern.

This can be used to implement any of these scenarios

  • invoke a service synchronously and if it fails, repeat the invocation a configured number of times waiting blockingly for the response
  • invoke a service synchronously and if it fails, invoke the service asynchronously in background notifying a callback service when it's finished, successfully or not
  • invoke a service asynchronously in background, and if it fails, repeat the invocation a configured number of times notifying a callback service when it's finished, successfully or not Install the add-on by putting it on PYTHONPATH, for instance, using pip and linking it to zato_extra_paths as below. This is a change that needs a server restart.
$ sudo pip install zato-invoke-retry
Downloading/unpacking zato-invoke-retry

...
[snip]
...

Successfully installed zato-invoke-retry
Cleaning up...
$
$ ln -s /usr/local/lib/python2.7/dist-packages/zato /opt/zato1/zato_extra_paths
$

You can now make use of invoke/retry as in the code examples below.

As an ending note, this feature is a good example of Zato's extensibility. No changes were needed to support it and only publically available features and API were used to add new value on top of existing core platform.

InfoQ has just published an article on Zato - covers Zato's architecture, goes through all of its main features and presents a sample integration using Yahoo YQL/JSON and Google XML with a goal of exposing their financial APIs.

All that in a concise and straight-to-the-point manner, including code samples, screenshots and CLI usage examples.

To everyone coming here from InfoQ - hello and have a nice stay :-)