已锁定 Azure AppFabric Queues - MQ Series?

  • Sonntag, 16. Oktober 2011 00:23
     
     

    I am working on a project where we will be processing a large amount of messages from systems outside our environment.    It is not clear yet if the messages will be pushed or if we need to pull the messages but I know the other side is using MQ Series.  Is there any support for MQ Series within Azure AppFabric Queues?

Alle Antworten

  • Montag, 17. Oktober 2011 05:57
     
     Beantwortet Enthält Code
    Hi Ryan,
    There is no direct support for WebSphere MQ in the Azure Service Bus Messaging. However, this Pub/Sub interoperability can be done using Using WebSphere MQ custom channels for WCF and WCF RoutingService.
    In the Push scenario, the RoutingService can be configured for forwarding inbound (WebSphere MQ) messages to the specific Namespace/Topic Service Bus based on the routing table.  
    The BrokeredMessageProperty bag for outbound messages can be created in the custom endpoint behavior with a message inspector.
    The following code snippet shows an example of this message inspector: 
      public class MessagePropertyActionClientInspector : IClientMessageInspector
        {
            public string Expression { get; set; }
    
            void IClientMessageInspector.AfterReceiveReply(ref System.ServiceModel.Channels.Message reply, object correlationState)
            {
                // nothing to do
            }
    
            object IClientMessageInspector.BeforeSendRequest(ref System.ServiceModel.Channels.Message request, IClientChannel channel)
            {
                if (request.Properties.ContainsKey(BrokeredMessageProperty.Name))
                {
                    var bmp = request.Properties[BrokeredMessageProperty.Name] as BrokeredMessageProperty;
                    var sra = new SqlRuleAction(this.Expression);
                    sra.Preprocess().Execute(bmp.Message);
                }
                else
                {
                    var bmp = new BrokeredMessageProperty();
                    var sra = new SqlRuleAction(this.Expression);
                    var bm = sra.Preprocess().Execute(bmp.Message);
                    request.Properties.Add(BrokeredMessageProperty.Name, bmp);
                 }
                return null;
            }
        }
    
     
    Note, that this solution requires only config file and assembly of the above message inspector and also can be deployed on the cloud as a generic gateway/bridge (messaging between Topics, Namespace/Topics, etc,)
    The same concept can be considered for Pull scenario, where a routing service is configured as Service Bus Subscriber. In this case, the custom filter can handle SqlExpression match for BrokeredMessagePropert bag.
    The following code snippet shows a custom filter for BrokeredMessageproperty: 
     public class BrokeredMessageFilter : MessageFilter
        {
            public string Expression { get; set; }
    
            public BrokeredMessageFilter(string expression)
            {
                this.Expression = expression;
            }
    
            public override bool Match(System.ServiceModel.Channels.Message message)
            {
                if (message.Properties.ContainsKey(BrokeredMessageProperty.Name))
                {
                    var bmp = message.Properties[BrokeredMessageProperty.Name] as BrokeredMessageProperty;                             
                    var filter = new SqlFilter(this.Expression);
                    bool bMatch = filter.Preprocess().Match(bmp.Message);
                    return bMatch;
                }
                else
                {
                    Trace.TraceInformation("BrokeredMessageFilter: Message doesn't have object BrokeredMessageProperty");
                    return false;
                }
            }
    
            public override bool Match(System.ServiceModel.Channels.MessageBuffer buffer)
            {
                throw new NotImplementedException();
            }
        }
    
    Roman

    Roman Kiss, MVP Connected System Developer
    • Als Antwort vorgeschlagen Ben Cline1MVP Dienstag, 25. Oktober 2011 03:11
    • Als Antwort markiert Ryan Finnesey Donnerstag, 3. November 2011 07:48
    •  
  • Donnerstag, 3. November 2011 19:03
     
     

     

    Ryan,

    - have a look at my recently article Using Windows Azure Service Bus Messaging.

     

     

    Thanks

    Roman

     


    Roman Kiss, MVP Connected System Developer