Free Pascal is Sourceforge Community Choice Project of the Month

The Community Choice April Project of the Month is Free Pascal, an advanced open source compiler for Pascal and Object Pascal. Read our interview with the project’s founder. Congratulations to the Free Pascal project on being voted as the April 2014 Community Choice POTM.

AMQP, MQTT, and STOMP Messaging Protocols compared

Andy Piper / vFabric Team published an article in 2013 about three popular protocols for message broker client/server communication: Choosing Your Messaging Protocol: AMQP, MQTT, or STOMP. The STOMP specification (currently at 1.2) can be found here. For Delphi and Free Pascal developers, Habarisoft offers STOMP client libraries designed for and tested with popular open source message brokers.

Habari Client Libraries

 

 

ActiveMQ Apollo 1.7 open source message broker released

The Apache ActiveMQ Project announced the availability of Apollo 1.7, a new open source message broker.

ActiveMQ Apollo is a faster, more reliable, easier to maintain messaging broker built from the foundations of the original ActiveMQ. It accomplishes this using a radically different threading and message dispatching architecture. Like ActiveMQ, Apollo is a multi-protocol broker and supports STOMP, AMQP, MQTT, Openwire, SSL, and WebSockets.

 

Client libraries are available for many programming languages. Habarisoft offers client libraries for Delphi and Free Pascal.

Habari Client for Apollo

Habari Client libraries update 2014.03.u1

Habari Client libraries are Delphi and Free Pascal libraries for application integration with five popular open source message brokers. Updated versions of these libraries are now available for download by registered users.

Tested with current message broker versions

The new release has been tested with the latest message broker versions: Apache ActiveMQ 5.9.0, Apollo 1.6, HornetQ 2.4.0.Final, Open Message Queue 5.0.1 and RabbitMQ 3.2.4

Bug fixes and improvements

  • Negotiation of heart-beat negotiation according STOMP spec (bug id 988)
  • Log CONNECT frame heart-beat intervals (bug id 984)
  • TBinaryMessageTestCase is registered in wrong test suite (bug id 983)
  • Log4D crashes with Free Pascal (bug id 977)
  • Use Id_SOL_* constants in Indy communication adapter (bug id 973)
  • Producer flow control for throughput demo application (bug id 925)
  • Equal signs in message property keys and values fail (bug id 924)

Habari Client Libraries

Habari Client libraries release 2014.03

Habarisoft announces new release

Habari Client libraries are Delphi and Free Pascal libraries for application integration with five popular open source message brokers. Updated versions of these libraries are now available. New features and improvements in this release include improved support for transacted sessions, improved support of STOMP specification for message header properties, more unit tests and documentation, and bug fixes.

Tested with current message broker versions

The new release has been tested with the latest message broker versions: Apache ActiveMQ 5.9.0, Apollo 1.6, HornetQ 2.4.0.Final, Open Message Queue 5.0.1 and RabbitMQ 3.2.4

Transaction support for message receipt acknowledgement

Transactional sending of messages was already supported in all versions of Habari Client libraries. Some library versions1 now also support commit and roll back for received messages.

To enable transacted message receive, use the CreateSession method with the transactional flag set to true and client message acknowledgment enabled (amClientAcknowledge instead of amTransactional) as shown below:

  // receive in a transacted session
  Session := Connection.CreateSession(True, amClientAcknowledge);
  Queue := Session.CreateQueue(GetQueueName);
  Consumer := Session.CreateConsumer(Queue);
  Msg := Consumer.Receive(1000);

  // process the message
  ...

  // acknowledge the message
  Msg.Acknowledge;

  ...

  // in case of critical errors, roll back acknowledgements
  Session.Rollback;

After a transaction rollback or a connection close without commit, messages which have been acknowledged after the transaction start will return to unacknowledged state.

Now with 100+ DUnit and FPCUnit tests

Tests related to unsupported features are disabled / ignored automatically.

fpcunit

Bug fixes and improvements

  • Authentication with empty credentials (login / passcode) values fails
  • Support for encoded carriage return (“\r”) in STOMP 1.2 headers
  • Support for equal signs and colons in STOMP headers
  • Support for empty STOMP header values
  • Compiler errors with Free Pascal 2.7.1
  • Unit tests for wild-card destinations
  • Unit tests for queue browser

1Tested with Apache ActiveMQ 5.9.0, Apollo 1.6 and RabbitMQ 3.2.3

A RESTful CRUD demo application with Delphi

Habari Web Components is a web application framework for small to medium size HTTP services, based on the Internet Direct (Indy) library.

A new demo application – included with full source code in demo/restful-crud – exposes a RESTful API which supports HTTP GET / POST / DELETE commands to read, create and delete data.

The source code below shows the configuration code for the RESTful API. Every request handler is bound to a resource address, document type (MIME type), and HTTP method.

Note that PUT is not yet implemented in the API because web browsers do not support HTTP PUT in HTML forms. For HTTP DELETE, the web interface uses a Javascript-based workaround to delete a resource.


procedure TMyRestfulComponent.Init(const Config:
            IWebComponentConfig);
begin
  inherited; // always call inherited.Init

  // GET http://localhost/rest/persons
  // list all persons
  &Path('persons');
  Produces('text/html');
  GET(procedure(Request: TRequest; Response: TResponse)
  begin
    Response.ContentText := CRUDModule.GetPersons;
    Response.CharSet := 'UTF-8';
  end);

  // POST http://localhost/rest/persons
  // add new person
  &Path('persons');
  Produces('text/html');
  POST(procedure(Request: TRequest; Response: TResponse)
  var
    Name: string;
    Person: TPerson;
  begin
    Name := UTF8Decode(Request.Params.Values['name']);
    Person := TPerson.Create(CRUDModule.NextID, Name);
    CRUDModule.SavePerson(Person);
    Response.Redirect(Request.Document);
  end);

  // PUT http://localhost/rest/persons/{id}
  // update person
  &Path('persons/{id}');
  Produces('text/html');
  PUT(procedure(Request: TRequest; Response: TResponse)
  var
    ID: string;
  begin
    ID := Request.Params.Values['id'];
    // TODO
  end);

  // DELETE http://localhost/rest/persons/{id}
  // delete person
  &Path('persons/{id}');
  Produces('text/html');
  DELETE(procedure(Request: TRequest; Response: TResponse)
  var
    ID: string;
  begin
    ID := Request.Params.Values['id'];
    CRUDModule.DeletePerson(StrToInt(ID));
  end);

  // GET http://localhost/rest/persons/{id}
  // get person information
  &Path('persons/{id}');
  Produces('text/html');
  GET(procedure(Request: TRequest; Response: TResponse)
  var
    ID: string;
  begin
    ID := Request.Params.Values['id'];
    Response.ContentText := CRUDModule.GetPerson(StrToInt(ID));
    Response.CharSet := 'UTF-8';
  end);
end;

Habari Web Components

Habari Web Components 2.7b1 – RFC 5789 and RESTful web applications

Habari Web Components is a web application framework for small to medium size HTTP services, based on the popular open source TCP/IP library for Delphi and Free Pascal, Internet Direct (Indy).

Changes in 2.7(beta1):

TdjRestfulComponent
The demo folder /restful contains the TdjRestfulComponent, a small example implementation of a RESTful framework which integrates with Habari Web Components (requires Indy 10.6 rev 50880 or newer)
HTTP PATCH (RFC 5789) support
PATCH is a new HTTP method to support partial resource updates in RESTful applications, it is defined in RFC 5789. Custom web components can now implement OnPATCH methods in addition to the existing request handlers OnGET, OnPOST etc. (TdjRestfulComponent also allows to register a PATCH resource handler)

Changes in version 2.6

Online demo:  the “Kitchen Sink” online demo on http://www.habariwebcomponents.de/demo/index.html runs on a Ubuntu Linux system and shows examples, which are also included in the demo download (note that Linux is not officially supported yet).

Habari Web Components

Habari Client libraries: on-line chat demo for Delphi launched

Habarisoft now provides an Open Message Queue (OpenMQ) server instance, which allows to run the Delphi Habari Chat example application (included in the demo download for Habari Client for OpenMQ) on-line, without the need for a local OpenMQ or GlassFish application server installation.

To use this OpenMQ message broker for your chat client message exchange, follow these steps:

  1. download, extract and launch the HabariChat executable
  2. in the Connection configuration screen, enter the server broker URL stomp://demo.habarisoft.com

Note: you can also use the URL stomp://habariwebcomponents.de which resolves to the same server. The client library will use the default port when omitted.

Illustrated step-by-step instructions

Step 1: Connection configuration

chat

Step 2: Enter a chat room name

ExampleTopic

Step 3: Enter your nickname

nick

Step 4: Send and receive messages

chatscreenNotes

  • To communicate with other chat users, make sure that all use the same chat room name
  • The chat application opens a STOMP connection on port 7672/TCP to the server, it will not work if your computer is behind a firewall
  • Please note that this demo service might be temporarily off-line, and its network connection speed is slower than with a broker service running in the local network

About Habari Client libraries for Delphi and Free Pascal

With Habari Client libraries, Delphi and Free Pascal developers can take advantage of message broker / message queue technology, which is distributed, loosely coupled, reliable and asynchronous, to build integrated systems, connecting clients using the peer-to-peer or the publish-subscribe communication model.

ScroogeXHTML RTF to (X)HTML converter: server deployment licenses included

28. December 2013 – Starting today, every single developer license of ScroogeXHTML now also includes two (2) server licenses for the deployment of server-side applications.
ScroogeXHTML is a converter library / component for Delphi and Free Pascal, which converts documents in Rich Text Format (RTF) to HTML and XHTML at high speed. Supported document types are: XHTML 1.0 Strict and Transitional, XHTML Basic 1.0, XHTML Mobile Profile 1.0 (a.k.a WAP 2.0), HTML 4.01 Strict and Transitional, and HTML5 (draft). The library is also available for the Java™ platform.

Single Developer License

The ScroogeXHTML Single Developer License allows one developer to create and distribute an unlimited number of single-user applications which use the library in compiled (binary) form.
The Single Developer License includes two (2) Server Licenses to run applications on the server side of client/server systems. For additional server-side installations, ScroogeXHTML Server Licenses are necessary (see below).

Server License

For applications which run on the server side of a client/server system, one ScroogeXHTML Server License is necessary per server.

Home page and demo download:

http://www.habarisoft.com/scroogexhtml_delphi.html

API documentation:
http://www.habarisoft.com/scroogexhtml/6.5/docs/api

“Getting started” documentation:
http://www.habarisoft.com/download/ScroogeXHTMLGettingStarted.pdf

Habari Client libraries – new features in first 2014 release (planned for Q1)

Transaction support for message receipt acknowledgement

Transactional sending of messages was already supported in all versions of Habari Client libraries. Some library versions1 now also support commit and roll back for the acknowledgement of received messages. When a transaction is rolled back or the connection is closed without a commit, messages which have been acknowledged after the transaction start will return to unacknowledged state.

  // receive in a transacted session
  Session := Connection.CreateSession(True, amClientAcknowledge);
  Queue := Session.CreateQueue(GetQueueName);
  Consumer := Session.CreateConsumer(Queue);
  Msg := Consumer.Receive(1000);

  // process the message
  ...

  // acknowledge the message
  Msg.Acknowledge;

  ...

  // in case of critical errors, roll back acknowledgements
  Session.Rollback;

Bug fixes and improvements

Bug fixes and improvements included in the next release (planned for Q1/2014):

  • Authentication with empty credentials (user / passcode) values fails
  • Support for encoded carriage return (“\r”) in STOMP 1.2 headers
  • Support for equal signs and colons in STOMP headers
  • Support for empty STOMP header values
  • Compiler errors with Free Pascal 2.7.1
  • Unit tests for wild-card destinations
  • Unit tests for queue browser

1Tested with Apache ActiveMQ 5.9.0, Apollo 1.6 and RabbitMQ 3.2.3