MQ Adaptor
There are two ways to customize the Messaging Queue Adaptor.
IMessageAdaptor Interface
DefaultMQAdaptor provided with build, implements the IMessageAdapter interface. Create a new messaging queue adaptor by implementing the IMessageAdaptor interface. IMessageAdapter interface has the following details:
public interface IMessageAdapter :IDisposable { /// <summary> /// Indicates if the adapter is connnected or not /// </summary> bool IsConnected { get; set; } bool IsSQConnectionExists { get; set; } /// <summary> /// Raised when the adapter receives a message /// </summary> event EventHandler<RequestEventArgs> MessageReceivedEvent; /// <summary> /// Connect to the message server /// </summary> /// <returns></returns> Dictionary<string,string> Connect(); /// <summary> /// Publish message using adaptor /// </summary> /// <param name=”message”>messag</param> /// <returns></returns> bool PublishToChannel(PublishQueueType queueType, string message,Dictionary<string,string> messageProperties, Dictio- nary<string, object> messageHeaders); /// <summary> /// start listening to the channel /// </summary> /// <returns>true if subscribtion was successful</returns> bool SubscribeToChannels(Dictionary<string,string> channelDetails);
/// <summary> /// This method unsubscribes the connection made in subscribed channels /// </summary> /// <returns>True in case of successful unsubscription</returns> bool UnsubscribeFromChannels(); /// <summary> /// Send ack to server /// </summary> /// <param name=”ackTag”></param> /// <returns></returns> bool SendAcknowledge(object ackTag); } |
Create a messaging adaptor by implementing the above interface. Inject the new custom Adaptor through RobotViewModel
Constructor in Rview.xaml.cs.
Overridding DefaultMQAdaptor
Following methods are present as virtual in the DefaultMQAdaptor.
- public virtual Dictionary<string, string> Connect()
- public virtual bool PublishToChannel(PublishQueueType queueType, string message,
Dictionary<string, string> messageProperties, Dictionary<string, object> messageHeaders) - public virtual bool SubscribeToChannels(Dictionary<string,string> channelDetails)
- public virtual bool UnsubscribeFromChannels()
- public virtual bool SendAcknowledge(object ackTag)
- public virtual void Dispose()
These methods are overridden to the default behavior of MQ adaptor.