(Migrated) Working on usage examples

(This message has been automatically imported from the retired mailing list)

Hello list,

I’ve just started the work on a new ‘Programming examples’ chapter which
I’d like to complete this week.

The idea is to provide concrete and ready to use examples for users to
download and customize.

Such things are already available throughout the whole documentation but
the idea here is to provide everything in a reference-style format.

Note that it’s about programming more than integrations as such. There
will be another chapter added for that too (“Integration scenarios” or
some such).

Here’s a list of things I’ll be adding - if you have any suggestions
what else to cover, please let me know.

Like I said, integration scenarios won’t be covered in this chapter but
if you’d like to mention any you’d like to see added in the other
chapter, please speak up :slight_smile:

HTTP
Exposing a service over HTTP
Accessing request headers
Setting response headers

SimpleIO (SIO)
Making a service accept JSON/XML/SOAP
Returning JSON/XML/SOAP

JSON
Accessing JSON request
Converting JSON to Bunch
Returning JSON

XML
Accessing XML request
Creating responses
Working with namespaces

CSV
Reading CSV on input
Producing CSV
Turning JSON/XML/SOAP into CSV and vice-versa

Other data formats
Reading arbitrary data formats
Accessing BASE64-encoded data

AMQP
Receiving messages from queues
Sending messages to exchanges

FTP
Putting files on server
Periodically checking for new files
Listing directories
Reading files

JMS WebSphere MQ
Receiving messages from queues
Sending messages to queues

Redis
Simple keys
Sets
Dictionaries
Transactions

Scheduler
Invoking services at predefined intervals

SQL
Issuing raw SQL
SQLAlchemy
Turning SQL into JSON/XML/SOAP

ZeroMQ
Receiving messages from sockets
Sending messages to sockets

Many thanks!

Hi,

I’d be willing to see “Parsing XML response of Simple HTTP outgoing
channel” in XML section. I don’t see that covered. Let me know if I’m wrong.

Also I’d be willing to see “Asynchronous Service invocation and results
collection” example.

For HTTP I’d need to see an example of custom requests Authenticatior to be
added. In my usecases Authentication is complex story and built-in Basic
Auth doesn’t solve the issue.

I’d need to see, how to run Service in Deferred mode. I.e. postpone some
action. In my usecases Service can fail, most often by external service
being unavailable. It would be good to see how Service can inject itself
into Scheduler and be executed after some retry interval by Scheduler.

Hope these usecases will enrich your collection,

m.

On Wed, Jun 26, 2013 at 2:59 PM, Dariusz Suchojad dsuch@zato.io wrote:

Hello list,

I’ve just started the work on a new ‘Programming examples’ chapter which
I’d like to complete this week.

The idea is to provide concrete and ready to use examples for users to
download and customize.

Such things are already available throughout the whole documentation but
the idea here is to provide everything in a reference-style format.

Note that it’s about programming more than integrations as such. There
will be another chapter added for that too (“Integration scenarios” or some
such).

Here’s a list of things I’ll be adding - if you have any suggestions what
else to cover, please let me know.

Like I said, integration scenarios won’t be covered in this chapter but if
you’d like to mention any you’d like to see added in the other chapter,
please speak up :slight_smile:

HTTP
Exposing a service over HTTP
Accessing request headers
Setting response headers

SimpleIO (SIO)
Making a service accept JSON/XML/SOAP
Returning JSON/XML/SOAP

JSON
Accessing JSON request
Converting JSON to Bunch
Returning JSON

XML
Accessing XML request
Creating responses
Working with namespaces

CSV
Reading CSV on input
Producing CSV
Turning JSON/XML/SOAP into CSV and vice-versa

Other data formats
Reading arbitrary data formats
Accessing BASE64-encoded data

AMQP
Receiving messages from queues
Sending messages to exchanges

FTP
Putting files on server
Periodically checking for new files
Listing directories
Reading files

JMS WebSphere MQ
Receiving messages from queues
Sending messages to queues

Redis
Simple keys
Sets
Dictionaries
Transactions

Scheduler
Invoking services at predefined intervals

SQL
Issuing raw SQL
SQLAlchemy
Turning SQL into JSON/XML/SOAP

ZeroMQ
Receiving messages from sockets
Sending messages to sockets

Many thanks!


Dariusz Suchojad

https://zato.io
The next generation ESB and application server. Open-source. In Python.
_____________**
Zato-discuss mailing list
Zato-discuss@lists.zato.io
https://mailman-mail5.**webfaction.com/listinfo/zato-**discusshttps://mailman-mail5.webfaction.com/listinfo/zato-discuss

On 06/26/2013 05:20 PM, Myroslav Opyr wrote:

I’d be willing to see “Parsing XML response of Simple HTTP outgoing
channel” in XML section. I don’t see that covered. Let me know if I’m wrong.

Hm, you’re right and I’ve modified a usage example here

https://zato.io/docs/progguide/outconn/http.html#soap

to include a couple of lines needed to parse SOAP (hence any XML).

It’s also here in this blog post where a response from Google is an XML too.

https://zato.io/blog/posts/django-web-services-integration.html

Also I’d be willing to see “Asynchronous Service invocation and results
collection” example.

Right, this is a more complex scenario than what will be in this chapter
and this can be only an example because this in fact can be done in more
than way.

An approach I can document and it’s also something 1.2 or 1.3 will have
is something along these lines

context = 'my data’
callback = 'my-service’
self.invoke_async(‘some-service’, callback, context)

callback and context will be stored in Redis and whatever response
’some-service’ produces, the callback service will be invoked with that
response along with the context from Redis.

This is the approach that can be trivially implemented in 1.1 manually
but I’ll add such a feature soon too.

For HTTP I’d need to see an example of custom requests Authenticatior to
be added. In my usecases Authentication is complex story and built-in
Basic Auth doesn’t solve the issue.

OK, for channels or outconns? Or both?

I’d need to see, how to run Service in Deferred mode. I.e. postpone some
action. In my usecases Service can fail, most often by external service
being unavailable. It would be good to see how Service can inject itself
into Scheduler and be executed after some retry interval by Scheduler.

This is a good idea for a blog post as it would need some explanations
of underlying mechanisms. Also sounds like a decent feature to add. And
again, it’s easy to implement it now.

Below is the handle method in a fairly concrete pseudo code, assuming
everything is in JSON:

“”"
if self.channel == SCHEDULER:
payload = bunchify(self.request.raw_request)
else:
payload = bunchify(self.request.payload)

try:
self.outgoing.plain_http.get(‘FOO’).conn.send(‘some data’)
except Exception, e:
job_data = {
‘cluster_id’: self.server.cluster_id,
‘name’: ‘Retrying {}’.format(self.name),
'is_active": True,
'job_type": ‘interval_based’,
'service": self.name,
‘start_date’: now(),
‘minutes’: 5,
‘extra’:self.request.raw_request}
service = 'zato.scheduler.job.create’
else:
job_data = {‘id’: get_job_id_from_redis()}

self.invoke(service, job_data)
"""

The trick is that a job can accept extra data and this the place that
the original request (or anything) can be put in.

When invoked from the scheduler the service needs to check where its
input data is and then continues its job in the same fashion no matter
the input channel.

Additional checks would have to be also added to prevent creating of
multiple jobs for the same service of course :slight_smile:

OK, I’ve added more usage examples to

https://zato.io/docs/progguide/examples/index.html

Have fun! :slight_smile:

OK, I’ve added more usage examples to

https://zato.io/docs/progguide/examples/index.html

Have fun! :slight_smile: