How do you get a Java object from Apache ActiveMQ Classic into a Delphi application with nothing but HTTP? A new open-source starter project shows one way:

https://github.com/michaelJustin/delphi-activemq-rest-starter

The idea

  • A Java sender creates a plain JMS ObjectMessage holding an Order object.
  • A client-side MessageTransformer converts the object to JSON on the way out, in the same format as ActiveMQ’s jms-object-json transformation.
  • A Delphi console application uses Indy TIdHTTP to fetch the message from the ActiveMQ REST API.
  • JsonDataObjects‘ ToSimpleObject maps the JSON onto a TPersistent descendant.
Root := TJsonObject.Parse(Body);
try
  UnwrapClassName(TJsonObject(Root)).ToSimpleObject(Order, False);
finally
  Root.Free;
end;

Why the transformer?

The REST API doesn’t apply message transformations. For an ObjectMessage, it only returns getObject().toString(). Converting on the Java client means the broker stores plain JSON, needs no Java classes on its class path and never deserializes an object. In case you’re thinking of Artemis instead: its REST interface was removed in version 2.26.0.

Good to know

In ActiveMQ 6.x, the REST MessageServlet is disabled by default and deprecated, and it’s due to be removed in a future release. The project is a learning and prototyping setup, not a production architecture.

It requires Delphi 2009 or newer, Indy 10.6.3.15, JsonDataObjects, ActiveMQ Classic 6.3.2 and Java 17+. The README covers broker setup, a real JSON sample and troubleshooting. The project is MIT-licensed, and feedback is welcome.

Ready for more than a demo?

Habari STOMP Client for ActiveMQ connects Delphi and Free Pascal applications to ActiveMQ over STOMP, a maintained protocol, with transactions, durable subscriptions, message listeners, and ObjectMessage exchange through broker-side transformation. More at https://www.habarisoft.com/habari_activemq.html

Visited 4 times, 4 visit(s) today