locked
Message Filter Problems CTP April RRS feed

  • Question

  • Hi,

     

    First I want to say that I spent about an hour typing out a long and detailed post with lots of code examples and explanation of my problem. I hit "Preview", there were errors, so I hit "Edit". When I did that, it brought me to the login page, and when I logged in, it brought me back to a blank post. I lost everything!

     

    I'm furious at these forums!!!!!!

     

    BUT, unfortunately I need this problem resolved ASAP so I will RELUCTANTLY retype a watered down version of my previous post.

     

     

    Now, to make a long story SHORT, jumping straight to my conclusion without supporting evidence or test cases, when I have two message filters in a subscribe request (call them "Filter1" and "Filter2"), only the message corresponding to the first filter on the list gets through.

     

    I verified this by reversing the order that the filters were added to the list. If I added "Filter1" and then "Filter2", only "Filter1" messages were received. If I added "Filter2" and then "Filter1", only "Filter2" messages were received.

     

    If I remove the filters from the SendNotification() functions, of course both messages are received.

     

    Now, just to make sure I am adding these filters correctly, I will go through that code (AGAIN):

     

    My filters come in as a List<string> object (called Messages), contained in the SubscribeRequest:

     

    Code Snippet

    public IEnumerator<ITask> SelectiveSubscribeHandler(SelectiveSubscribe subscribeRequest)

    {

    submgr.InsertSubscriptionMessage request =

    new submgr.InsertSubscriptionMessage(

    subscribeRequest.Body.Subscriber,

    subscribeRequest.Body.Expiration,

    submgr.FilterType.Default,

    new submgr.QueryType(subscribeRequest.Body.Messages.ToArray())

    );

     

    submgr.InsertSubscription ins = new submgr.InsertSubscription(request);

    ins.Body.NotificationCount = subscribeRequest.Body.NotificationCount;

    _subMgr.Post(ins);

     

    ...

     

    }

     

     

    I create a QueryType object from this List<string>.ToArray(), which creates one QueryType object with a KeyList that contains both of the messages, in the order originally specified. I verified that this QueryType is being populated correctly when sent to the Subscription Manager in both cases.

     

    Could there be a bug causes the subscription manager to behave this way or is there something wrong with the way I am passing my Filters list onto the Subscription Manager?

     

    Thanks,

    Don

    Thursday, July 3, 2008 6:39 PM

Answers

  • I found a fix, although I'm not sure why the above code doesn't work.

     

    Instead of passing all of my filters into the KeyList of a single QueryType object, I pass each filter it's own QueryType object, and then pass in the array of QueryType objects. This seems to work.

     

    The code is:

     

    Code Snippet

    public IEnumerator<ITask> SelectiveSubscribeHandler(SelectiveSubscribe subscribeRequest)

    {

    List<submgr.QueryType> queryList = new List<submgr.QueryType>();

     

    foreach (string item in subscribeRequest.Body.Messages)

    {

    queryList.Add(new submgr.QueryType(item));

    }

     

    submgr.InsertSubscriptionMessage request =

    new submgr.InsertSubscriptionMessage(

    subscribeRequest.Body.Subscriber,

    subscribeRequest.Body.Expiration,

    submgr.FilterType.Default,

    queryList.ToArray()

    );

     

    ...

     

    }

     

     

    -Don

    Friday, July 4, 2008 4:48 PM

All replies

  • I found a fix, although I'm not sure why the above code doesn't work.

     

    Instead of passing all of my filters into the KeyList of a single QueryType object, I pass each filter it's own QueryType object, and then pass in the array of QueryType objects. This seems to work.

     

    The code is:

     

    Code Snippet

    public IEnumerator<ITask> SelectiveSubscribeHandler(SelectiveSubscribe subscribeRequest)

    {

    List<submgr.QueryType> queryList = new List<submgr.QueryType>();

     

    foreach (string item in subscribeRequest.Body.Messages)

    {

    queryList.Add(new submgr.QueryType(item));

    }

     

    submgr.InsertSubscriptionMessage request =

    new submgr.InsertSubscriptionMessage(

    subscribeRequest.Body.Subscriber,

    subscribeRequest.Body.Expiration,

    submgr.FilterType.Default,

    queryList.ToArray()

    );

     

    ...

     

    }

     

     

    -Don

    Friday, July 4, 2008 4:48 PM
  • You know, i'm so glad i searched.  I was looking for a similar thing, where i would have a string and want to filter parts of the string into different functions as values.  I was hoping to be able to do this in VPL, as the string would have 8 different values.  I am not too good at C#.  can we communicate more on this?
    Tuesday, July 22, 2008 2:40 PM
  • Don, try the LINQ filtering support. It uses C# code to express condition on your types, and in many ways its much easier to get write. Our service Tutorial12, in CTP2 talks about it and also the subMgr documentation in the CHM file with CTP2 has details on it

     

    Tuesday, July 22, 2008 6:27 PM