Xafari Server. Main Types 

  • Message
  • Xafari.MQ.MQError
  • Message Handler


Persistent object to represent Message is implemented as a MQMessage Domain Component.

  • c#
  • VB

public interface MQMessage
  MessageStatus CurrentStatus { get; set; }
  DateTime CreatedDate { get; set; }
  string Tag { get; set; }
  string Description { get; set; }
  string User { get; set; }
  XPWeakReferenceStruct MessageData { get; set; }

<DomainComponent> _
Public Interface MQMessage
  Property CurrentStatus As MessageStatus
  Property CreatedDate As DateTime
  Property Tag As String
  <FieldSize(410)> _
Property Description As String
  Property User As String
  <PersistentDc> _
Property MessageData As XPWeakReferenceStruct
End Interface

To add a new Message to the Message Queue use InsertMessage method:

  • c#
  • VB

MQManager.Instance.InsertMessage<T>(T messageData, string tag, string description)

Private Function (ByVal messageData As T, ByVal tag As String, ByVal description As String) As MQManager.Instance.InsertMessage(Of T)
End Function

Each Message can contain additional data that are required for subsequent processing of the Message. These data can be arbitrary persistent object. MessageData property provides access to this object, MQMessage.MessageData is a property of the Xafari.Base.XPWeakReferenceStruct type.

When working with Messages, you need to use a special Object Space, to obtain it call the MQManager.Instance.CreateObjectSpace() method. In the same Object Space you need to process additional Message data (see above).

A unique tag is assigned to each Message type. Using this tag, the server sends Messages to the appropriate handlers.. Using this tag, the server sends Messages to the appropriate handlers.

CurrentStatus field shows the current status of Messages in the Queue. The field accepts values of the MessageStatus enumeration.


In the process of Message processing errors may occur. Detailed information about the error (exception) is stored in the Xafari.MQ.MQError table. If the user is viewing a Message Queue (MQMessage_ListView) and select the Message with error, then Error details Action will be available. This Action invokes Detail View with error information.

Message Handler

All Message Handlers implement the Xafari.Server.IMessageHandler interface. Xafari.Server.MessageHandler base abstract class aims to simplify the problem of implementing a new Message Handlers. This class implements the logic for the Message blocking, run handler in a separate thread, generates events declared in the IMessageHandler interface. It is required to override ProcessMessageCore abstract method in the MessageHandler descendant.

  • c#
  • VB

protected abstract void ProcessMessageCore(IObjectSpace messageObjectSpace, MQMessage message, CancellationToken token);

Protected MustOverride Sub ProcessMessageCore(ByVal messageObjectSpace As IObjectSpace, ByVal message As MQMessage, ByVal token As CancellationToken)

During operation of the server this method is invoked in a separate thread (this logic is implemented in the Xafari.Server.MessageHandler class). Before calling the method, the processed Message changes status from the "WaitingForExecution" to "Processing". If the processing of the Message does not have any exceptions, then, when the ProcessMessageCore method is completed the Message changes the status to "Finished". In the case when the exception occurs, the Message changes the status to "Error". Detailed error information is stored in the Xafari.MQ.MQError table.

At the moment Xafari framework supplies Xafari.Reports.Server.ReportMessageHandler included inXafari.Reports.Server.dll assembly. ReportMessageHandler provides report generation on the server side.