Yesterday, I was reading a book about André Kertész, one of my favourite photographers. I tried to reproduce one of his most famous photographs, La Fourchette, that he made in 1928.
1/180ƒ/5.6ISO 20037 mm
The shape of my fork and plates are different from the original ones but the lighting is pretty similar. I used a single strobe to get a unidirectional hard light and tried several positions to get the shadows of the plate, the fork and the teeth close to the original:
The printing I have is more subtle and nuanced that this picture from Wikimedia that has too much contrast.
There is nothing better for a rainy sunday than cooking some cookies with my girlfriend and make pictures of them to play with my flash and reflectors.
stomp.js is a simple JavaScript library to send and receive STOMP messages from a Web browser using Web Sockets.
Today, I have released its version 2.3.0 that adds support for node.js. This makes it possible to send and receive STOMP message from any node.js app by connecting to a STOMP broker on its TCP port (usually 61613) or on its Web Socket.
I have registered a npm package stompjs that can be installed by typing:
npm install stompjs
and in the code, requiring the module:
var Stomp = require('stompjs');
To connect to a STOMP broker over a TCP socket, use the Stomp.overTCP(host, port) method:
var client = Stomp.overTCP('localhost', 61613);
To connect to a STOMP broker over a Web Socket, use instead the Stomp.overWS(url) method:
var client = Stomp.overWS('ws://localhost:61614/stomp');
Apart from this initialization, the STOMP API remains the same whether it is running in a Web browser or in node.js application.
A simple node.js app that sends and receives a STOMP message can be coded in a few lines:
var Stomp = require('stompjs');
// Use raw TCP sockets
var client = Stomp.overTCP('localhost', 61613);
// uncomment to print out the STOMP frames
// client.debug = console.log;
client.connect('user', 'password', function(frame) {
console.log('connected to Stomp');
client.subscribe('/queue/myqueue', function(message) {
console.log("received message " + message.body);
// once we get a message, the client disconnects
client.disconnect();
});
console.log ('sending a message');
client.send('/queue/myqueue', {}, 'Hello, node.js!');
});
In this example, the client connect to the STOMP broker on its TCP socket by calling Stomp.overTCP(host, port):
var client = Stomp.overTCP('localhost', 61613);
To connect on its Web Socket, you only need to change the creation of the client by calling instead Stomp.overWS(url):
var client = Stomp.overWS('ws://localhost:61614');
This means that if your code uses stomp.js, you can run the same code in the Web browser or in node.js That may prove handy for testing...
Why another STOMP client for node.js when there are already a dozen?
I believe the code of stomp.js is already the best of them.
The STOMP protocol implementation is the same whether the client is running in a Web browser or in node.js. The only differences are the timers and the socket implementations (native Web Socket for Web browser, net.Socket for node.js). The socket implementation can still be customized and many users run it over SockJS
There are likely some corner cases to iron out but the main features (including heart-beating) should work as expected.
Note that the node.js support is done outside the stomp.js file. If you only need to use STOMP from the Web browser, this changes nothing: you only need that file (or its minified version).
The title says it all: I've agreed with O'Reilly Media to write a book about Mobile and Web Messaging.
Almost all my career has been spent developing messaging platforms or clients using messaging. The last few years, I have focused on messaging for Mobile and Web platforms.
I added STOMP support to HornetQ to be able to send and receive messages from iOS and Android apps.
I wrote stomp.js to send and receive messages from HTML5 Web Browsers1. This small library is now used by the main Open Source messaging brokers (ActiveMQ, Apollo, RabbitMQ in addition to HornetQ).
This book is the result of all this work and will help mobile and Web developers leverage messaging protocols in their applications.
I plan to introduce messaging protocols and write about STOMP (and most likely MQTT too) in details. The book will come with examples for mobile platforms and Web browsers.
For a long time, I wanted to write a technical book and it is a chance to do it about an interesting subject and be published by the best editor for programming books. O'Reilly agreed to publish the book under an Open Source license and the source and examples will be hosted on GitHub (when I have some material to show).
This opportunity is only possible because my employer, Red Hat, allows me to spend some of my work time on this book. Red Hat is an awesome company to work for and we are hiring!
I am incredibly excited about this book and look forward to sharing some sample chapters. I just need to start writing them now! :)
That's why I just released a new version of stomp.js. I plan to write a chapter about it and found some shortcomings that I wanted to fix. ↩
During my summer holidays, I have simplified its API to make it more object-oriented instead of a simple translation of the protocol frames. The new API is backwards compatible except for the susbcription change.
The documentation has been updated to reflect the new API.
The message objects passed to the subscribe callback now have ack() and nack() methods to directly acknowledge (or not) the message.
var sub = client.subscribe("/queue/test",
function(message) {
// do something with the message
...
// and acknowledge it
message.ack();
},
{ack: 'client'}
);
Unsubscription
Instead of returning an id from client.subscribe(), subscribe() returns an object with an id property corresponding to the subscription ID and an unsubscribe() method.
var subscription = client.subscribe(...);
...
subscription.unsubscribe();
Transaction
The begin() method returns a JavaScript object with commit() and abort() methods to complete the transaction.
var tx = client.begin();
message.ack({ transaction: tx.id, receipt: 'my-receipt' });
...
tx.commit(); // or tx.abort();
A transaction ID is automatically generated when calling 'begin() and is available in the returned object's id property.
Miscellaneous changes and fixes
default onreceive method
When a subscription is automatically created on the broker-side, the received messages are discarded by the Stomp.client that find no matching callback for the subscription headers. To workaround that, the client can set a default onreceive callback that will be called if no matching subscription is found.
By default, debug messages are now written in window.console.
STOMP can now be used from a WebWorker (an example shows how to use it).
STOMP frame fragmentation
If the STOMP frames are big to send on a single WebSocket frame, some web server may have trouble process them. It is now possible to split a STOMP frame on multiple Web Socket frames by configuring the client.maxWebSocketFrameSize (in bytes). If the STOMP frame is bigger than this size, it will be send over multiple Web Socket frames (default is 16KiB).
use the 1st value for repeated headers
Stomp.js was keeping the last value of repeated headers. This has been fixed according to the specification to take the 1st value of repeated headers.
We bought a siphon for cooking some time ago and are having fun with it to prepare desserts and starters (we made a mousse de foie gras that was awesome). Yesterday, we prepared a velours de mangue (velvet of mango).