Extension ID
com.castsoftware.dotnet.nms
What's new?
See .NET NMS - 1.0 - Release Notes.
Description
This extension provides support for Apache NMS .NET APIs which are responsible for consumer and publisher operations in .NET applications. If your C# application utilizes Apache NMS for messaging-related operations and the producer and consumer are handled using the C# language, and you want to modelize the producer and consumer links with appropriate objects and links, then you should install this extension.
Supported libraries
Library | Version | Supported |
---|---|---|
Apache NMS | up to: 2.1.0 | |
Apache NMS ActiveMQ | up to 2.1.0 |
Compatibility
CAST Imaging Core release | Supported |
---|---|
8.3.x |
Dependencies with other extensions
Some CAST extensions require the presence of other CAST extensions in order to function correctly. The .NET NMS extension requires that the following other CAST extensions are also installed (this will be managed automatically by CAST Imaging Console):
- CAST AIP Internal extension (internal technical extension)
- Web Services Linker
Download and installation instructions
The extension will not be automatically downloaded and installed in CAST Imaging Console. If you need to use it, you should manually install the extension using the Application - Extensions interface.
What results can you expect?
Objects
The following objects are generated:
Icon | Description |
---|---|
Apache NMS ActiveMQ publisher | |
Apache NMS ActiveMQ Receiver | |
Apache NMS ActiveMQ unknown publisher | |
Apache NMS ActiveMQ unknown Receiver |
Links
Link Type | Source and Destination of link | Supported APIs |
---|---|---|
callLink | callLink between the caller C# method and the Publisher object | Apache.NMS.IMessageProducer.Send Apache.NMS.IMessageProducer.SendAsync Apache.NMS.ActiveMQ.IMessageProducer.Send Apache.NMS.ActiveMQ.IMessageProducer.SendAsync |
callLink | callLink between the Receiver object and the caller C# method | Apache.NMS.IMessageConsumer.Receive Apache.NMS.IMessageConsumer.ReceiveAsync Apache.NMS.ActiveMQ.IMessageReceiver.Send Apache.NMS.ActiveMQ.IMessageReceiver.SendAsync |
Example code scenarios
Publisher APIs
static void Main() { string brokerUri = "tcp://localhost:61616"; string queueName = "dest_queue"; using (IConnection connection = new ConnectionFactory(new Uri(brokerUri)).CreateConnection()) { connection.Start(); using (ISession session = connection.CreateSession()) { IDestination destination = session.GetQueue(queueName); // Produce message ProduceMessage(session, destination); // Consume message ConsumeMessage(session, destination); connection.Stop(); } } } static void ProduceMessage(ISession session, IDestination destination) { using (IMessageProducer producer = session.CreateProducer(destination)) using (ITextMessage message = session.CreateTextMessage("Hello, ActiveMQ!")) { producer.Send(message); Console.WriteLine("Message sent: " + message.Text); } }
Receiver APIs
static void ConsumeMessage(ISession session, IDestination destination) { using (IMessageConsumer consumer = session.CreateConsumer(destination)) { ITextMessage receivedMessage = consumer.Receive() as ITextMessage; if (receivedMessage != null) { Console.WriteLine("Received message: " + receivedMessage.Text); } else { Console.WriteLine("No messages in the queue."); } }
Dotnet Publisher and Receiver
using Apache.NMS; using Apache.NMS.ActiveMQ; using System; class Program { static void Main() { string brokerUri = "tcp://localhost:61616"; string queueName = "dest_queue"; using (IConnection connection = new ConnectionFactory(new Uri(brokerUri)).CreateConnection()) { connection.Start(); using (ISession session = connection.CreateSession()) { IDestination destination = session.GetQueue(queueName); // Produce message ProduceMessage(session, destination); // Consume message ConsumeMessage(session, destination); connection.Stop(); } } } static void ProduceMessage(ISession session, IDestination destination) { using (IMessageProducer producer = session.CreateProducer(destination)) using (ITextMessage message = session.CreateTextMessage("Hello, ActiveMQ!")) { producer.Send(message); Console.WriteLine("Message sent: " + message.Text); } } static void ConsumeMessage(ISession session, IDestination destination) { using (IMessageConsumer consumer = session.CreateConsumer(destination)) { ITextMessage receivedMessage = consumer.Receive() as ITextMessage; if (receivedMessage != null) { Console.WriteLine("Received message: " + receivedMessage.Text); } else { Console.WriteLine("No messages in the queue."); } } } }
Known limitations
- Unknown Publisher/Receiver Objects will be created if the evaluation fails to resolve the necessary parameter.