Subscription Model in asp.net mvc - asp.net-mvc

I am looking to design a notification service which on certain conditions when met would send status report to users.I am not able to understand how to save those conditions in database like model wise ( for example user is interested in seeing report where job is 100% or user is interested in report which has failed status).The approach I was thinking was to have either columns for each of those conditions or serialize those conditions and save it as json in db.
Please provide some insights to it?

Depending on your requirements you could look into a message queue based system where you would put a message on a queue to indicate that you want to send a report to someone.
A message handler like NServicebus can then monitor the queue and handle the actual sending of reports via email or other means.

Related

Anylogic How to queue and process received messages by agents

--This post has been edited as #Benjamin has suggested in his answer
I am trying to model peer influence for churn situations. Agents will send messages to their peers depending on different conditions. I have also created a List called MessagesReceived to store received messages.(The number of these messages may be >1).
I have tried processing (i.e. adding the message to a list of received messages) these messages in Connections>OnMessageReceived but although I can access message and sender objects, I don't know how to access the receiving agent there.
what would you suggest in this case?
P.S: variable names and types may be a little different in screenshots but the problem I described here does not come from that.
Please always only ask one question per issue, else it gets too confusing.
So let me answer your first question:
although I can access message and sender objects, I don't know how to access the receiving agent there
You can simply type this. in the code box below and you have access to "yourself". In fact, you do not even need that, simply access the fields from "yourself" here. If you are in an agent with variable myVar, you simply use that.
For the other questions, please open separate issues, see this.

Custom alert rules with Application Insights

Need the help of the crowd.
I'm wondering if the below monitoring scenario is possible with Application Insights.
I want to have an alert if one event occurred (on a certain entity) but another event did not follow it.
We have a job scheduling machine, we want to monitor cases in which a job creation was requested but a job was not created.
So we log everything of course, we have an event that a job was requested, and we have an event when a job was created.
And we want to be alerted if jobs were requested but was not created.
What would be the best practice? Is it even possible to AI?
Thanx!
Oh... I now found there is a way to define alerts on custom log searches.
We will give it a try and keep this post updated.
If anyone has other ideas - lets me know.

Write in the Database from within the database

Hopefully the title is clear, I couldn't find a better name but if someone can improve it please update it, thanks.
I would like the Firebase database to write on a node if a certain condition is met. For example, if one node receives an input from a client (say an angular app) then another node in the database should write certain data, something like a callback that is fired when a node receives some data.
I know there are 4 rule types (.read .write .validate .indexOn), what I am thinking of is some kind of .callback rule that is fired and writes on a node after some other node has received an input.
Obviously this can be achieved via a server side script but Firebase is about a server-less approach so I am trying to understand what are its current limits and what I can do with it.
Thanks for your responses
firebaser here
Running the multi-location update client-side or on a server-side process that you control are currently the only ways to accomplish this.
There is currently no way to trigger updates based on modifications to the database on Firebase servers. It is no big secret that we've been working on such functionality for a while now, but we have made no announcement as to when that will be available.
Also see Can I host a listener on Firebase?, which (I realize now) is probably a duplicate.

Multi user authorisation on controller actions

I’m building a small application that will have multiple users using ASP.NET MVC, but I’m not sure how to handle user authorisation in the scenario below. I may be missing something obvious as I’m still learning, so any advice is appreciated.
Basically, to illustrate my problem, consider that I’m building a very small email like messaging system. Here is the action to read a message:
/Message/ReadMessage/1
Where Message is the controller, ReadMessage the action and 1 is the MessageId.
Now this message was for “Bob” and in the db his UserId is stored with the message. Another user called “Fred” has also received a message and the MessageId for this is 2.
In my application, there would be no way for Bob to see Fred’s messages on the page directly or through links (messages should be private to each user), so what is the best way for me to protect from Bob simply changing the MessageId in the URL manually from 1 to 2 and viewing Fred's message?
As a current solution to this, I have a very simple check at the beginning of my controller action which compares the UserId stored with the message to the current UserId and if they don’t match, the user is redirected (to say, their inbox).
Is this a suitable solution for such a scenario? I get the feeling that while this works now, it isn’t the best approach to this problem. Thanks for the help.
your controller needs to check that the current user is allowed to access the resource ( message in this case )

Concurrent moderating on a CMS

I'm building a custom CMS which allow user to post message to it. Messages are short and like tweets.
The problem is that these message are moderated by real moderators. And there are multiple moderators working on the messages stream at the same time. And my concern is that what if these moderator are processing a same message. This is both inefficient and inconsistent. Since one message can be rejected by one moderator and then passed by another.
Therefore I want to build some kind of mechanism so that the CMS can distribute these messages to different moderator and avoiding duplication. The CMS is expecting to deal with large volume of message in a short time. Therefore this problem become more serious.
Any Idea is appreciated. Cheers.
I would do it like this:
Each logged-in moderator gets his own queue of messages to moderate
There is a central queue which will be used as a buffert
Posted messages go into the central queue
Each moderator queue fetches, say, 10 messages at a time.
When there's only 5 left in a moderator queue that queue will automatically fetch 10 new messages.
The downside is that you will need a central queue with a locking mechanism. If you want to avoid even that locking I propose one of two solutions:
Remove the central queue entirely and post messages on-the-fly into one of the moderator queues (maybe a randmoly chosen one), or,
Have a central queue and let each moderator have a randmoly chosen message from the top part of the queue (e.g., let them have one from the top-20). If there is "double moderation" due to absense of locking, just ignore the second moderation and accept the time-waste.
You could have the moderators pull the message off a queue before moderating. Sort-of like a check-out? So the moderator clicks something that assigns them a number of messages to process. They deal with those, then grab another batch off the queue.
Have your update action for Messages do this
def update
# perform regular update stuff ;)
rescue ActiveRecord::StaleObjectError
flash[:message] = "Someone else has updated this message"
redirect_to message_path(#message)
end
Check out http://railscasts.com/episodes/59-optimistic-locking or other pages on 'locking' (optimistic or otherwise) in Rails.

Resources