c# - .Net messaging pub/sub pattern -


so have .net application running on nancyfx (needs platform agnostic). have requirement need send notification when event happens (subscription). notification implement interface:

public interface inotification {     public void notify(); } 

there many different implementations e.g. email, pushbullet, pushover etc.

what struggling how implement implementations of inotification execute notify() when there subscription.

can point me in right direction.

i don't want use sort of external queues, since application running on users machines.

so application self-hosted, client , server located on users machine , not talk outside world, it's internal.

excuse me second, i'll want make sure got right. have not written what's exact problem, assume stuck somewhere @ basics. i'll ignore nancyfx, don't know it, assume if supported case, you'd find in docs.

to let client know has changed, have 3 options:
(a) there's list of old events on server, server updates when events happen, clients periodically read them , invoke 'notify' ping!
(b) each client opens connection server , keeps open, server remembers connections , when new happens, sends message clients on already-opened connections, clients message , invoke 'notify' ping!
(c) clients send registration message server, contains callback address/port/etc, server stores that. when event occurs, server reads list , sends infos these addresses, clients handle these requests , call notify according request

since use words 'publish-subscribe', assume meant (c).

for option, regarding notifications, roles of client/server reversed. in normal case, server exposes api client, client connects it, sends request, server handles , returns response. here, both sides must same. client app must expose callable api server, when "event" occurs, server can connect client's api , send him request notification data.

now, how you'd structure api - it's you. can have 1 notify(string xmlizedorjsonizeddata) method, can have parameters notify(string infotype, datetime, data), or many methods notifyemal(...) notifybullet(...) ... - after implementing registration , subscription bookkeeping, need server call client's api correct request data, client same time.

now that's bit of work write of , reinvent wheel. there lots of libraries can it. looked , didn't find in nancyfx docs that. use create client-side api, create server-side api, .. there's catch.

client-side , server-side differ.

when client talks sever, there 1 server send , listen to. can in naive way, blocking ui if like. when server sends notifications back, there can 10000s of clients. should not start writing in naive way. looping on many clients , waiting till finished can freeze server completely, , if not freeze, cause slowdowns , timeouts. furthermore, server out there in public. clients not. clients behind nats, firewalls, , other funny things pass traffic client->to->server may block traffic in other direction. basic example blocking ports. :80 on server passed through firewalls, :80 on client unavailable , when client opens api on :23122 won't configured on firewalls/routers .. unless handle upnp/etc.

that's why it's pick library can of you.. sorry, can't recall name now, check i.e. google publishsubscribe pattern, or client-notification or push-notification server-side library.

that's why thing called "websockets" invented. that's option (b) talked in beginning. it's worth investigating. whole concept of subscribe-publish implementable calls/responses server/client apis/interfaces on websocket, saves lot of work , network problems.

i've found info it's possible use nancy , signalr may start.


Comments

Popular posts from this blog

java - Run spring boot application error: Cannot instantiate interface org.springframework.context.ApplicationListener -

python - pip wont install .WHL files -

Excel VBA "Microsoft Windows Common Controls 6.0 (SP6)" Location Changes -