Habari Client libraries 6.0 preview: new API

New interface types

The new API in Habari Client libraries 6.0 is based on three new interfaces which reduce the amount of client code:

  • IMQContext
  • IMQProducer
  • IMQConsumer

IMQContext interface

A IMQContext object encapsulates both the IConnection and the ISession object of the classic API. The connection factory interface contains new methods to create IMQContext objects:

function CreateContext: IMQContext; overload;
function CreateContext(const AcknowledgeMode: 
           TAcknowledgementMode): IMQContext; overload;
function CreateContext(const Username, Password: string): 
           IMQContext; overload;
function CreateContext(const Username, Password: string; 
           const AcknowledgeMode: TAcknowledgementMode): 
           IMQContext; overload;

The IMQContext provides methods to create messages, producer and consumer objects, destinations (queues, topics, temporary queues, temporary topics, durable subscribers and so forth), and for transaction control (commit, rollback).

IMQProducer interface

A IMQProducer object provides methods to produce and send messages to the broker. As a shortcut, a method allows to send text or bytes messages without creating ITextMessage or IBytesMessage object by providing the text or bytes as a parameter.

function Send(const Destination: IDestination; 
           const Body: string): IMQProducer; overload;
function Send(const Destination: IDestination; 
           const AMessage: IMessage): IMQProducer; overload;
...

IMQConsumer interface

A IMQConsumer object provides methods to consume messages from the broker.

The following example is taken from the unit tests. It uses the new API to create and send a text message to a broker queue destination, and then receives the message from this queue.

Source code example

procedure TNewApiTests.TestSendMessage;
var
  Context: IMQContext;
  Destination: IQueue;
  Producer: IMQProducer;
  Consumer: IMQConsumer;
  TextMessage: ITextMessage;
begin
  Context := Factory.CreateContext;
  Destination := Context.CreateQueue(GetQueueName);

  Producer := Context.CreateProducer;
  Producer.Send(Destination, 'Hello World');

  Consumer := Context.CreateConsumer(Destination);
  TextMessage := Consumer.Receive(2500) as ITextMessage;

  CheckEquals('Hello World', TextMessage.Text);
  Context.Close;
end;

Download

A snapshot of the new 6.0 release is available in the Habari Client for ActiveMQ and the Habari Client for RabbitMQ download areas:

General availability

Release 6.0 is planned for Q4/2018. Users of the 5.x releases are encouraged to download and test the 6.0 snapshot. Feedback is always welcome.

About Habari Client libraries

habari_logo_2016Habari Client libraries enable Object Pascal applications to take advantage of message broker / message queue technology – which is distributed, loosely coupled, reliable and asynchronous – to build integrated systems, using peer-to-peer and publish-subscribe communication models.

Advertisements

Habari Client libraries 2018.04 released

Habarisoft released new versions of its Object Pascal STOMP client libraries for Delphi and FPC integration with popular free open source message brokers.

The 2018.04 release is a maintenance release and includes:

Download

Release 2018.04 is available now for download from the Habarisoft server for registered users:

Changes in release 2018.04

  • Connection.Close closes all sessions and consumers. Previous versions only stopped the session(s), but did not send an UNSUBSCRIBE to the server.
  • Fixed several Free Pascal compiler warnings
  • Indy version check: if the symbol INDY100 is not defined, the compilation will end with an error. If the symbol 10_6_2 is not defined, the compilation will emit a warning

Unit test changes

  • Stopwatch methods
  • Test case ReceiveNoWaitDoesNotBlock
  • LocalStompServer closes connection after sending ERROR frame (specification)

Known issues with Apache ActiveMQ Artemis 1.5.6

  • The unit test case TestNoLocal fails with Apache ActiveMQ Artemis 1.5.6

Known issues with Apache ActiveMQ Artemis 2.5.0

  • Many unit test cases fail with Apache ActiveMQ Artemis 2.5.0

Resources

Home page: https://www.habarisoft.com/index.html

Feature matrix: https://www.habarisoft.com/index.html#feature_matrix

About Habari Client libraries

habari_logo_2016Habari Client libraries enable Object Pascal applications to take advantage of message broker / message queue technology – which is distributed, loosely coupled, reliable and asynchronous – to build integrated systems, using peer-to-peer and publish-subscribe communication models.

Connect Delphi and Free Pascal applications with WildFly 12 Final

Earlier this year, Red Hat released WildFly 12 Final, a free and open source Java EE application server for the Java platform. If you need to exchange data between Delphi or Free Pascal code and WildFly, you can follow these steps for a quick demonstration of the Habari Client for Artemis library from Habarisoft

Download

Server configuration

  • run <inst>wildfly-12.0.0.Final\bin\add-user and add the application user chat with password chat and role guest
  • edit <inst>wildfly-12.0.0.Final\standalone\configuration\standalone-full.xml to enable STOMP and add the ExampleTopic destination (see below)
<subsystem xmlns="urn:jboss:domain:messaging-activemq:3.0">
<server name="default">
 ...
  <acceptor name="stomp-acceptor" factory-class="org.apache.activemq.artemis.core.remoting.impl.netty.NettyAcceptorFactory">
    <param name="protocols" value="STOMP"/>
    <param name="port" value="61613"/>
  </acceptor>
  ...
  <jms-topic name="ExampleTopic" entries="java:/jms/topic/ExampleTopic" />
  </server>
</subsystem>

Launch server and clients

  1. start WildFly with <inst>wildfly-12.0.0.Final\bin\standalone -c standalone-full.xml
  2. launch one or more instances of the HabariChat demo application and connect to the server on localhost with user chat and password chat

The Delphi application now can use the ExampleTopic as the ‘chat room’ for messages between all running instances (and, of course, allows also non-Delphi clients to receive and send messages within this chat room topic as well).

chat-wildfly-12

chatroom

nickname

chat

Related posts

 

Habari Client libraries 2018.04 – first beta available

Habarisoft released the first beta of its Object Pascal STOMP client libraries for Delphi and FPC integration with popular free open source message brokers. The upcoming 2018.04 release includes:

  • Habari Client for ActiveMQ 5.4 – tested with Apache ActiveMQ 5.15.3
  • Habari Client for Artemis 5.4 – tested with Apache ActiveMQ Artemis 2.4.0
  • Habari Client for OpenMQ 5.4 – tested with OpenMQ 5.1.1 (August 2017) and Payara 5.0
  • Habari Client for RabbitMQ 5.4 – tested with RabbitMQ 3.7.4

Continue reading

Apache ActiveMQ Artemis 2.5.0 released

The Apache Software Foundation released Apache ActiveMQ Artemis 2.5.0.
Release notes: https://activemq.apache.org/artemis/release-notes-2.5.0.html
Documentation: https://activemq.apache.org/artemis/docs.html

 

About Apache ActiveMQ Artemis

Features

  • AMQP protocol support
  • OpenWire support for ActiveMQ 5 clients
  • MQTT support
  • STOMP protocol support
  • HornetQ Core protocol support for HornetQ 2.4,2.5 clients
  • JMS 2.0 and 1.1 support
  • High availability with shared store and non shared store (replication)
  • Flexible Clustering
  • High performance journal for message persistence
  • Queue memory limitation
  • SSL support
  • Management over JMX, JMS and core protocol
  • Large message support
  • Topic hierarchies
  • Producer flow control
  • Consumer flow control
  • Diverts
  • Last value queue
  • Message Groups
  • OSGi support

Connect Delphi and Free Pascal applications with Payara Server 5.0 (release candidate)

Payara Server is an open-source application server derived from GlassFish Server Open Source Edition. If you need to exchange data between Delphi or Free Pascal code and Payara Server, you can follow these steps for a quick demonstration of the Habari Client for OpenMQ library from Habarisoft. This native library uses the platform-independent STOMP wire protocol for asynchronous, bidirectional message exchange with popular message brokers, including Open Message Queue (Open MQ), the default message broker in Payara Server 5.

Continue reading