Fiorano Logo  
     Fiorano Login 

Native CSharp-Runtime Examples View as PDF
LMS

With the introduction of Large Message Support (LMS) in FioranoMQ, clients can now transfer large messages in the form of large files with theoretically no limit on the message size. Large messages can be attached with any JMS message and the client can be sure of a reliable and secure transfer of the message through FioranoMQ server.

Following are the highlights of the FioranoMQ LMS implementation

  • Reliable transfer of large messages.
  • No increase in cache/JVM heap size required.
  • The Large message transfer is not restricted to any queue or topic
  • Ability to resume message transfer at both sender and receiver end.
  • Minimal changes in the application code.

This folder contains samples that demonstrates the use of sending large messages (files) using Fiorano JMS server using the FioranoMQ Native CSharp Runtime Library.

  • LMSender.cs - This program illustrates how an application can send a large message in the point- to- point messaging model. This program performs the following steps.
    1. It creates a JMS connection with the FioranoMQ server and send a large message (JMS message with a property which specifies the path of the large file) on primaryQueue.
    2. The published large message notifies the consumers listening on primary- Queue about the availability of a file called send.zip that can be received.
    3. When a consumer responds to the notification, then both the parties (sender and consumer) performs the initial handshaking operation.
    4. When the hand-shake is complete, the sender creates a status listener and registers it on the large message so that it can be notified about the transfer status asynchronously.
    5. Now sender starts sending the various fragments of the file, send.zip, to the consumer and starts receiving notification when a complete window of fragments is transferred.
    6. When the message (file) transfer is complete, the application is notified about the completion of the message transfer. In case of a failure in transferring the message, the program receives the notification through the same status listener.
  • LMReceiver.cs - This program illustrates how an application can receive and store the large message in the point-to-point messaging model. This program performs the following steps.
    1. It creates a JMS connection with the FioranoMQ server and starts listening for availability of messages on primaryQueue.
    2. On receiving the availability notification, it creates a status listener so that it can receive notifications about the message transfer status asynchronously.
    3. Now the program specifies the complete path of the location (.\received.zip) on which the received fragments (of the sent file) should be saved.
    4. The consumer receives a transfer status notification when it receives a complete window successfully.
    5. Also when the message (file) transfer is complete, then the consumer is notified about the completion and in case of a failure in receiving the message, the program receives the exception through the same status listener.

To run these samples using FioranoMQ, do the following:

  1. Compile each of the source files. The %FMQ_DIR%\nativecsharp\scripts directory contains a script called csclientbuild.bat which compiles the Native CSharp program.
  2. Run the LMSender by executing LMSender.exe executable file.
  3. Run the LMReceiver by executing LMReceiver.exe file.

Note: You would notice that when the file, send.zip is successfully transferred and received by the consumer, then a new file called received.zip will get created in the same directory.

MessageSelectors

A message selector allows a client to specify, by message header, the messages its interested in. Only messages whose headers and properties match the selector are delivered. The semantics of not delivered differ a bit depending on the MessageConsumer being used. Message selectors cannot reference message body values.

Consumer's message selectors cannot be modified dynamically. However it is not necessary to close the connection or reconnect for this purpose. It is sufficient if the consumer is closed (subscriber.close() API) and a new consumer is created with the new selector.

This directory contains two sample programs which illustrate the use of Message Selector using the FioranoMQ Native CSharp Runtime Library.

  • SelectorReceive.cs - This example illustrates the use of Message Selectors. The receiver receives Messages that match the criteria specified in the getSelectedMessages() method.
  • SelectorSend.cs - SelectorSend publishes messages, which contain details such as make and model about a particular car as JMS Message properties.

To run these samples using FioranoMQ, do the following:

  1. Compile each of the source files. The %FMQ_DIR%\nativecsharp\scripts directory contains a script called csclientbuild.bat which compiles the Native CSharp program.
  2. Run the SelectorRecv by executing the SelectorRecv.exe executable file.
  3. Run the SelectorSend by executing the SelectorSend.exe file.
    SelectorSend.exe filename [Fully qualified name of the file]

Note: Run the "SelectorRecv" program first, and then run the "SelectorSend" program. When the SelectorSend program is run, the data file ch05.dat must be supplied as input.

MultiPartMessage

This directory contains two sample programs which illustrate the use of Multi Part Message using the FioranoMQ Native CSharp Runtime Library.

  • MultiPartMessage.cs - This sample provides a definition of the multipart message and provides APIs to add a new part and to retrieve the already added parts from the message.
  • SampleClass.cs - This sample provides a stepped down version of a object part that can be added to the multipart message.
  • MultiPartMessageSender.cs - This sample demonstrates how an application can create a multipart message, adds different parts to it and finally sends it on a JMS destination using the JMS semantics completely.
  • MultiPartMessageReceiver.cs - This sample demonstrates how an application can receive a multipart message and then retrieve different parts that were added by the sender sample.

To run these samples using FioranoMQ, do the following:

  1. Compile each of the source files. The %FMQ_DIR%\nativecsharp\scripts directory contains a script called csclientbuild.bat which compiles the Native CSharp program.
  2. Run the MultiPartMessageSender by executing the MultiPartMessageSender.exe executable file.
  3. Run the MultiPartMessageReceiver by executing the MultiPartMessageReceiver.exe file.
ObjectMessage

Any serializable Java object can be packaged into an Object message and published on a Topic or Queue. If a collection of Java objects needs to be published, one of the collection classes provided in Java 2 can be used.

This directory contains a program which demonstrates how to send Object messages using JMS in a PTP messaging model using the FioranoMQ Native CSharp Runtime Library.

  • ObjectSender.cs - Creates an Object Message and send it on a queue. By default the queue on which message is published is primaryQueue, which can be modified using the command line argument.
  • ObjectReceiver.cs - Implements a synchronous listener which listens for object messages published on a queue. The default queue on which listener is made is primaryQueue, which can be modified using the command line arguments.

To run these samples using FioranoMQ, do the following:

  1. Compile each of the source files. The %FMQ_DIR%\nativecsharp\scripts directory contains a script called csclientbuild.bat which compiles the Native CSharp program.
  2. Run the Receiver by executing the Receiver.exe executable file.
  3. Start up one or more named clients using the command(s) by executing the ObjectSender.exe file.
PriorityQueues

Priority queues refer to sending messages with priorities on Queues.

  • PriorityQueue.cs - This program demonstrates the process to send messages with priorities on Queues.

The administrator uses the password "passwd" to login as the administrator. If you have previously set the administrator password to something other than "passwd", then this test case will fail.

To run these samples using FioranoMQ, do the following:

  1. Compile the source file. The %FMQ_DIR%\nativecsharp\scripts directory contains a script called csclientbuild.bat which compiles the CSharp program.
Browser

This directory contains two sample programs which illustrate basic JMS Browser functionality using the FioranoMQ Native CSharp Runtime Library.

  • Q_Sender.cs - Reads strings from standard input and sends them on the queue "primaryQueue".
  • QBrowser.cs - Implements a browser, which is used to browse the messages on the queue "primaryQueue", and prints out the received messages.

To run these samples using FioranoMQ, do the following:

  1. Compile each of the source files. The %FMQ_DIR%\nativecsharp\scripts directory contains a script called csclientbuild.bat which compiles the Native CSharp program
  2. Start the Sender program. When the program comes up, type in a few strings, pressing the Enter key after each string.
  3. Start the QueueBrowser program. The Queue Browser will enumerate all the messages sent.
  4. Repeat steps (2) and (3) over. Each time, you will find that all messages published during are immediately browsed by the QueueBrowser.
RequestReply

JMS provides the JMSReplyTo message header field for specifying the Destination where a reply to a message should be sent. The JMSCorrelationID header field of the reply can be used to reference the original request. In addition, JMS provides a facility for creating temporary queues and topics that can be used as a unique destination for replies.

Enterprise messaging products support many styles of request/reply, from the simple "one message request yields a one message reply" to "one message request yields streams of messages from multiple respondents." Rather than architect a specific JMS request/reply abstraction, JMS provides the basic facilities on which many can be built.

For convenience, JMS defines request/reply helper classes (classes written using JMS) for both the PTP and Pub/Sub domains that implement a basic form of request/reply. JMS providers and clients may provide more specialized implementations

Basic

This directory contains the examples illustrating use of the built-in JMS request/reply API (the request() and replyTo() APIs) using the FioranoMQ Native CSharp Runtime Library.

  • Requestor.cs - Implements a client application making requests.
  • Replier.cs Implements a server application that listens for requests on a given Queue and replies to each request.

FioranoMQ provides a wrapper over the JMS specific Topic and QueueRequestors, namely, FioranoTopicRequestor and FioranoQueueRequestors. These wrappers provide additional APIs to set timeout for requests.

FioranoTopic and FioranoQueue Requestor, now make it mandatory for the replier to set the "correlation-ID" received from the requested message. FioranoRequestor sends data with a "correlation-ID" set, the replier has to send back a reply with the "correlation-ID" set by the requestor.

To run these samples using FioranoMQ, perform the following steps:

  1. Compile each of the source files. The %FMQ_DIR%\nativecsharp\scripts directory contains a script called csclientbuild.bat which compiles the Native CSharp program.
  2. Run the Requestor by executing the Requestor.exe executable file.
  3. Run the Replier by executing the Replier.exe file.
  4. Timeout

This directory contains two sample programs which illustrate the timed request/ reply abstraction provided by FioranoMQ.

  • TimedQueueRequestor.cs - Reads strings from standard input and use it to send a request on the queue "primaryqueue". It waits for the reply, for a specific time interval.
  • TimedQueueReplier.cs - Implements an asynchronous listener, which listens on the queue "primaryqueue", and replies to each request.

To run these samples using FioranoMQ, perform the following steps:

  1. Compile each of the source files. The %FMQ_DIR%\nativecsharp\scripts directory contains a script called csclientbuild.bat which compiles the Native CSharp program.
  2. Run the replier by executing the TimedQueueReplier.exe executable file.
  3. Run the timed requestor by executing the TimedQueueRequestor.exe file.
RevalidateConnections

FioranoMQ server on detecting a loss of connection, notifies the application by invoking the onException ( ) of ExceptionListener object, which is associated with the Connection instance. The loss of connection might be due to number of possible reasons, such as termination of server process and network failure. When working over an unreliable network, the FioranoMQ administrator must enable pinger in the server.

On detecting a failure, an application automatically reconnects through a proprietary API - revalidate ( ), provided by FioranoMQ. In addition, when the application automatically reconnects, its does not lose its state, active Senders and Receivers. This API can be found in FioranoQueueConnection for PTP.

This directory contains two sample programs which illustrate revalidate connection property using the FioranoMQ Native CSharp Runtime Library. These samples revalidate connections when the connection is lost with the FioranoMQ Server. In addition, it restores the validity of created sessions, senders and receivers on this connection.

  • Sender.cs - Reads strings from standard input and sends them on the queue "primaryQueue".
  • Receiver.cs - Implements an asynchronous listener, which listens on the queue "primaryQueue", and prints out the received messages.

To run these samples using FioranoMQ, perform the following steps:

  1. Compile each of the source files. The %FMQ_DIR%\nativecsharp\scripts directory contains a script called csclientbuild.bat which compiles the Native CSharp program.
  2. Run the receiver by executing the receiver.exe executable file.
  3. Run the sender by executing the Sender.exe file.
  4. Shut down FioranoMQ server
  5. Restart FioranoMQ server.
  6. The Sender and Receiver will re-establish the connection with the server after sometime and messages will start getting exchanged again.
SendReceive

This directory contains four sample programs which illustrate basic JMS Send/ Receive functionality using the FioranoMQ Native CSharp Runtime Library.

  • QSender.cs - Reads strings from standard input and sends them on the queue "primaryqueue".
  • QReceiver.cs - Implements an asynchronous listener, which listens on the queue "primaryqueue", and prints out the received messages.
  • NPQSender.cs - Reads strings from standard input and sends them on the Queue "primaryQueue" in non-persistent mode.
  • ListenerReceiver.cs - Implements an listener, which listens on the queue "primaryqueue", and prints out the received messages

To run these samples using FioranoMQ, perform the following steps:

  1. Compile each of the source files. The %FMQ_DIR%\nativecsharp\scripts directory contains a script called csclientbuild.bat which compiles the Native CSharp program.
  2. Run the Receiver by executing the Receiver.exe executable file in case you want to run asynchronous receiver otherwise run ListenerReceiver.exe to receive message synchronously.
  3. Run the Sender by executing the Sender.exe file in case you want to send Persistent Messages otherwise run NPQSender.exe which will send Non-Persistent Messages.

Note: To run any of the Native CSharp samples, ensure that environment variable FMQ_DIR points to Fiorano installation directory (this defaults to \Fiorano\FioranoMQ\fmq).

Transactions

A Session may optionally be specified as transacted. Each transacted session supports a single series of transactions. Each transaction groups a set of produced messages and a set of consumed messages into an atomic unit of work. In effect, transactions organize a sessions input message stream and output message stream into series of atomic units. When a transaction commits, its atomic unit of input is acknowledged and its associated atomic unit of output is sent. If a transaction rollback is done, its produced messages are destroyed and its consumed messages are automatically recovered.

This directory contains a sample programs which illustrate JMS Transaction functionality using the FioranoMQ Native CSharp Runtime Library.

  • Transactions.cs - Implements the sender and receiver, and uses the commit/rollback functionality to demonstrate JMS Transactions

To run this sample using FioranoMQ, do the following:

  1. Compile the source files. The %FMQ_DIR%\nativecsharp\scripts directory contains a script called csclientbuild.bat which compiles the Native CSharp program.
  2. Run the sample by executing the Transactions.exe executable file. For proper results from the sample, ensure that there are no messages in the primary-Queue.


ESB | JMS | SOA | MQ | Enterprise Service Bus | Java Message Service | Service Oriented Architecture |
Messaging Queue | Enterprise Messaging | SAP integration | SAP solutions | JMS performance | JMS server |
SOA platform
© Fiorano Software Technologies P Ltd. All Rights Reserved. Privacy Statement |Terms of Use
  Site Developed & Maintained by Fiorano Webteam.

 World Wide Support
 USA
:
+1-408-354-3210
 INDIA
:
+91 80 4017-0000
 UK
:
+44(0) 19328 95005