Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7838265
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T15:03:10+00:00 2026-06-02T15:03:10+00:00

I am designing a 2 WCF services that all my clients will connect to.

  • 0

I am designing a 2 WCF services that all my clients will connect to. One of these services will be a notifications service.

I would like each client to connect to the service, subscribe to it and then receive notifications, using a duplex Callback interface (the service will fire the ‘Notify’ operation in the clients).

This is my Design Idea:

enter image description here

My question is: When each client connects to my service, I will validate it against the ‘Users’ table in my database (I will be using a UserNamePasswordValidator and implement the ‘Validate’ function).

Requirement: Each user needs to receive different notifications, based on rules defined in the database, but they all use the same contract.

For example:

John Smith‘s rules in the DB might be : Notify me on all new products that have a price
of over 100 dollars.

Jane Doe‘s rules in the DB might be : Notify me on all new products that their names begin with ‘JA’.

Jim Jabra‘s rules in the DB might be : Notify me on all new products that are of type ‘Food’.

My service will have a worker thread that detects a change in the database (a new product was inserted to the database).

It should then loop over all the clients connected – and for each client send him a notification of the new product, only if it matches the client’s notification requests.

Again – all clients receive the same type of update (new products), but each client should receive different products according to the rule in the database.

One approach I thought to implement this would be to use a Singleton service, that holds a list of :

  • Client Enpoint
  • User Object (from database)

This way – each time the worker thread detects a new product, it loops over this list and send notifications to whome ever needs it.
The problem with this approach is that in order to have one global list of clients – I need to have the service as a Singlton, right ?

The second approach would be … well … I don’t have another idea of how I can access a list of clients connected to the service from a worker thread …

I guess the main problem I have is that each client might want different kinds of product notified to him. Meaning – the pub\sub method is not so good here, because my scenario requires the service to know about the clients.

Any suggestions on how I can solve this headaches ?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-02T15:03:12+00:00Added an answer on June 2, 2026 at 3:03 pm

    In any way with duplex communication, you need to maintain TCP channel opened from server to client to be able to send notification.

    Client is the one who initiate connection to server, and you need to keep this connection open, if this connection is lost you can’t (shouldn’t) initiate connection from server to client, because client can be behind NAT, have firewall, etc.

    So in any way there must be some static (singleton) object on server side that keeps clients connections list, thought this is not necessarily WCF service. You can dependency inject this object into service constructor.

    public class ProductRepository
    {
        private EventAggregator eventAggregator;
    
        public void Add(Product product)
        {
            //...
            eventAggregator.Publish(new NewProductEvent(product))
        }
    }
    [ServiceBehavior(InstanceContextMode=InstanceContextMode.PerSession)]
    public class EventPublishingService
    {
        private IClientCallback client;
        private EventAggregator eventAggregator;
        private Func<Product, bool> predicate;
    
        public EventPublishingService(...)
        {
            eventAggregator.Subscibe<NewProductEvent>(OnNewProduct);
        }
        private void OnNewProduct(NewProductEvent e)
        {
            if (predicate(e.Product)==true) client.Notify(e.Product);
        }
    
        public void Subscribe()
        {
            client = OperationContext.Current.GetCallbackChannel<IClientCallback>()
            var user = ServiceSecurityContext.PrimaryIdentity;
            predicate = GetFilterForUser(user);
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm designing a WCF service that will return a list of objects that are
I'm designing a WCF service that will return a response code (such as 0
I'm designing a set of web services to allow our clients to connect from
I am designing a distributed application that will consist of RESTful services and a
I am designing a WCF service which have some operations that i expose to
Let's say that I'm considering designing a WCF service whose primary purpose is to
I'm designing some services and I would like to get some feedback about the
I created a simple WCF web service that has one method: SubmitTicket(flightticket ft, string
One of our products contains multiple WCF services whose business layers all sit on
I'm designing a WCF webservice that will potentially get called by 10,000+ plus separate

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.