Nservice bus ... Publisher subscriber Filtering subscribers - c#

I am beginner in Nservice bus
I have an webapplication and a desktop windows applicaton
the web application will publish some events and the desktop windows will subscribe to receive that events.
The windows application will be installed on multiple different machines
and i imagin that every instance will act as subscriber.
each instance would be used by different user , the user would not be intrested in receiving everything ,he should receive the message only depending on his category .
is it possible to filter the subscribers who should recieve this message before publishing it in case they already subscribed

The scenario you are describing is content based routing, not supported in NSB v5.x.
A solution can be to discard of the message in the message handler on the subscriber...

Related

RabbitMQ - Stop publishing and subscribing

We have a system which publishes messages to the RabbitMQ and subscribes from it and each of this is done as Task in C#.
Is there any way I could stop the publish and subscribe when some matching criteria is found.
Lets say, for example i got an exception while publishing a particular message (just hypothetical), so now i want to stop publishing to the queue and also consumers from consuming from the same queue.
Is there any way this could be achieved?
We have a control bus implementation and Tasks based one.
Every message is published via different Tasks.
Thanks in Advance.

Retrieve only messages that publisher send after subscriber connected(masstransit)

I have created an application that works using MassTransit and Azure Service Bus as transport. Publish, send, retrieve events and commands - this is all works good. But now I want to create subscriber that will retrieve messages that publisher send after subscriber connected. How to do that? I do not want to get all messages that was sended by publisher before connection.
What you are asking for is not possible.
By definition, a publisher only sends to subscribers. If a subscriber is not connected at the time an event is published, that subscriber would not receive it. Only the subscribers that are connected at the time the event is published receive the event.
In the future, MassTransit will add support for Kafka and Event Hub, which will support what you want, but the semantics for those transports are quite different.

How to implement single publisher and multiple subscribers asynchronous message system in C# using WCF and MSMQ?

I have searched a lot, but still I had few doubts about MSMQ implementation of WCF service.
Hence I have put this quetion.
I want to implement single publisher and multiple subscribers asynchronous message system.
I have decided to use WCF service as the publisher.
I have multiple instances of the window service on different machines as the multiple subscribers.
Q. I want to know that, how this model can be implemented as the old MSMQ approach?
The object of following type would be used in the message
[Serializable]
public class Message
{
public string Signal{get;set;}
public Guid Identifier{get;set;}
}
In the above class, Identifier would be used by the windows service to decide whether the message was published for that service or not.
Q. How the different window services will read the same queue?
Q. Where the queue should be hosted?
Q. Is it possible to send the acknowledgement from Window service(subscriber) to WCF service(publisher)?
Any help would be appreciated.
In answer to your questions:
I want to know that, how this model can be implemented as the old
MSMQ approach?
First off, MSMQ does not support publish subscribe out of the box.
How the different window services will read the same queue?
So in publish subscribe, there in no ONE queue. Instead there are multiple queues, in fact one per participant in the pub sub scenario. So each publisher has a queue and each subscriber has a queue.
This configuration enables subscribers to send subscribe/unsubscribe messages to the publisher, and allows the publisher to send messages to the subscribers as necessary after evaluating the subscriptions.
Where the queue should be hosted?
These queues can be hosted locally to each participant, or can be hosted together in some clustered location.
Is it possible to send the acknowledgement from Window
service(subscriber) to WCF service(publisher)?
MSMQ does provide basic support for request/response messaging via response-queue and correlation-id message header fields, though this is not truly out of the box (as you are required to consume and program against these values)
If you are not required to use WCF there is a fairly mature platform called nservicebus which sits on top of MSMQ and does provide support for all the messaging patterns you need.

How to update my desktop application from a Windows Phone 7.5 Mobile application

Our desktop application require to be updated directly when a mobile employee sends any message from his/her windows phone 7 mobile.
Currently our requirement is that send a message from our desktop application to a Windows Phone 7.5 which we are able to achive easily using PUSH Notifications, Now when the user takes some action against the sent message the windows phone app calls the WCF service and pass the message to that WCF which receives the message and puts into the database and application reads it later and this is where problem lies. Because our WCF is putting that message into database our application is polling it every 5 second and if any replies received from any of our drivers then it is updating the UI.
What we want to achieve is when we receive any reply our desktop applicaton should be notified automatically and udpates the UI and then put it into the database.
So please share your experience on this issue.
Thanks
Why not update the WCF service to notify any registered "listeners" (i.e. running instances of your client app) that the database has been updated with new information?
You could do this by having your service expose a service that can be called by clients wanting to register for some/all event types. The client app(s) host a service implementing a callback contract that the service can call when the registered events are raised.
There's a good MSDN article one-way, callback and pub-sub messaging with WCF: http://msdn.microsoft.com/en-us/magazine/cc163537.aspx.
Be sure to keep track of and throttle how many events your client app is receiving per second - the last thing you want to have happen is for 100 client apps to all hit the server 50 times each if 50 events are raised sumultaneously!
Richard's solution is probably more proper, since it describes using nicely packaged WCF APIs that will do a lot for you. Another way could be to implement long-polling yourself. You could then also update your Windows Phone clients when they need to receive an immediate update. I wrote an article on that some time ago which you can find if you google long polling on Windows Phone.

Windows System Notification Event Service & Custom Events

I know with the Windows System Notification Event Service (SNES) I can subscribe to many different system events.
Is it possible to create my own type of System Event and publish events to the System Notification Event Service?
Have you tried developing your own COM object and seeing if these events are captured by the SENS service? If so, you should be able to create a listener based on the CLSID.

Categories