Habari MDC Container - Message Driven Components for Java and Delphi Integration
Join the DZone community and get the full member experience.Join For Free
betasoft is pleased to announce Habari MDC Container, a new application server framework for Delphi™ based on the JEE concept of Message Driven Beans. Designed for event-driven application, message driven components are business objects whose execution is triggered by messages instead of by method calls. With Habari MDC Container, Delphi developers can write lightweight application servers, which connect to open source JMS message brokers (Apache ActiveMQ, JBoss HornetQ or Sun OpenMQ are already supported) and process messages from topics and queues. Cross-language client applications can use services in the container for simple tasks like centralized logging, monitoring, and configuration but also implement advanced solutions like load balancing and legacy application integration.
This example creates an embedded Habari MDC Container, adds a JMS connection factory and a queue, and deploys a message driven component:
// create the container
Container := THabariContainer.Create;
// bind a connection factory
// bind a queue
// deploy the HelloWorld MDC
The interface declaration of the message driven component contains the two methods which need to be implemented, Configure and OnMessage:
THelloWorldMDC = class(TInterfacedObject, IMDCConfigProvider, IMessageListener)
procedure OnMessage(const AMessage: IMessage);
procedure Configure(var AMappedName: string; const AProperties: IActivationConfigProperties);
The implementation part shows that like in an message driven bean, a message driven component uses a mapped name for the JMS destination:
procedure THelloWorldMDC.Configure(var AMappedName: string;
const AProperties: IActivationConfigProperties);
AMappedName := 'jms/HelloWorldQueue';
procedure THelloWorldMDC.OnMessage(const AMessage: IMessage);
WriteLn('Hello World - ' + (AMessage as ITextMessage).Text);
Running the container with a Log4D console appender will show the deployment process, which includes a component verification, on the console. (If the JMS message broker is not running, the container will retry).
The container is now connected with the JMS broker and listens for messages on the queue TOOL.DEFAULT. Messages sent to this queue will be received and displayed by the HelloWorld MDC:
Deployed hello world component receiving JMS message
Opinions expressed by DZone contributors are their own.