I am working on a labour management service that allows it's user to enter their timesheets, allows manager to modify those timesheets and sync attendance over web connectors or web services. Now, we need to have a feature that sends users email if there total week hours are more than weekly hours limit. It's event driven like as soon as added shifts for the user is more than limit, send an email unlike scheduler jobs.
I'd like to know some best practices that I can use to achieve this. I don't want to get into my existing code and add number of lines in existing code, I'd like to accomplish it with as little as possible change in existing code base and add code only related to trigger an event and rest event handler should be taking care of sending emails.
Techs used:
Spring4, Java7
PS:
I know it's like a story and it may not suited for StackOverflow, please feel free to move this question to a place in SO network where it fits well.
Related
I work for a company that has a java based eCommerce site. We have a new initiative to monitor when things aren't happening when they should be, such as guests not signing in and lack of completed orders. For example, we expect x amount of orders at y time of day and when they are below the standard deviation we want to know about this through an alerting system. We are already monitoring (the solutions we use are below) the health of the application and have a pulse on exceptions being thrown. We are looking to catch when the app appears to be in good working order, but events we expect to be triggered aren't happening. For example - our credit card authorizer could start declining all of the credit authorizing attempts so no orders are coming through, etc.
We are capable of building this ourselves, probably with Drools, but would prefer to find an out of the box solution. In our research we have not found anything that really fits what we are looking for and didn't find the functionality in we are already using. If any of the monitoring solutions we already use are capable of delivering this functionality that would be the route we would prefer.
dynaTrace
Truesite
Hyperic
Coremetrics analytics
Thank you for your help and time!
If you already have dynatrace then go with it. It can do all of what you are looking for. It can monitor your Credit Card Service and alert you in case reponse time goes down or in case it throws errors. It goes much broader than that use case - it actually tells you which end users are affected - whether this is just for certain types of users (from a certain region, from a certain type of device, ...) or if it is for everyone.
If you have questions on how to use dynatrace for your use cases I suggest you put a question on the dynatrace community forum - they are pretty active over there: https://community.compuwareapm.com/community/display/DTFORUM/dynaTrace+Forums+Home
You can also watch some of the video tutorials on youtube to make yourself more familiar with its capabilities: http://bit.ly/dttutorials
I have a java application with newrelic agent. The overview dashboard displays "Web transactions response time" chart, but it does not break it down any further - just total time.
How to make it be more specific - how to divide whole "JVM" into several "subevents"?
The chart I'm referring to:
And here's how it could look like (random screen from the web):
In order to see the information you are looking for like we see in the screenshots you helpfully provided you'll need to do some configuration on your end. The Java agent can pick up the information you're looking for but you'll need to tell it to do so.
To give you a few specific examples:
Database: Provided you're using a supported database, we should get calls made to the database and make that part of the transaction. (See Java compatibility JDBC ) You would then see those reflected in the chart.
Web External: Calls you make to an outside service will show up if they are properly instrumented. You can find out more about capturing these calls from this KB document and this one.
Request queueing This is what happens before the request actually reaches your application (which is where the agent lives). You can learn more about this functionality in this KB document
What you are currently seeing in the graph is the remainder of the time the transaction took after the request was queued, any database or external calls were made and responses received.
If you need clarification or have further questions, please don't hesitate to ask.
Cheers,
Adrienne Kincaid | Tech Support Engineer | New Relic, Inc
Bit of a random question :). I'm running a few Steam Team Fortress 2 (TF2) idle accounts to acquire items for the production of metal.
I've set up a few bash scripts to connect each account a couple of hours a day through the night. What I've found over the last couple of years that various things will cause the automatic account logins to fail. Which I wouldn't normally notice until I decide to look at the server, which I do rarely.
So I thought one way to ensure thing were working correctly would be to write a script that would log into each account (say daily) and list/count the number items it has. Log it have something like Splunk pick it up (which I already have running for other stuff).
So after that long winded explanation, my question is, does anyone know how to write a script that can retrieve the item information from a TF2 account. My current bash scripts can perform the log in to Steam and can start up TF2, but I have no idea if that is the correct/best way to retrieve item info or even if I can be done from the same bash script used to log in.
Happy to use any language, but do have a fondness for Python.
Thanks.
Valve has released a web api which provides a flexible way to query your items from outside the game. First, grab an api key by following the instructions at http://steamcommunity.com/dev.
Next, in your script, fetch http://api.steampowered.com/IEconItems_440/GetPlayerItems/v0001/?key=API_KEY&steamid=STEAMID where API_KEY and STEAMID are your api key and 64-bit steam id respectively. This returns a JSON file which contains a list of all the items in your inventory. Just grab the size of the items array.
I'm working on porting a desktop application (WinForm) to a web application (Java/Spring/JPA). The problems are many and I'm struggling a bit...
Now the problem is threading!
In the original application, that performs the export of certain data from the DB, there is a progress-bar indicating the progress of the process.
I want to port this progress-bar in the new web application. To do this I thought of using AJAX and use a separate thread to run the data export.
The main concerns are:
Am I following the right approach? Are there problems using multi-threading in web applications?
If during the export process F5 or refresh button are pressed what exactly happens? How can I stop the process?
How do I update the progress bar periodically? Do I have to make calls via ajax to the server?
I'm primarily an ASP.Net developer but from what I know of the HTTP protocol this just isn't the way to go about it. I've seen a lot of fairly clever solutions for this but in the end what becomes clear is that the HTTP protocol simply isn't designed to work like this.
Obviously you're aware that a flash or silverlight app would be able to do this but that comes with it's own set of issues.
Myself I prefer to keep all the weirdness on the server. In the past I've had to come up with a way to deliver several thousand emails through a web application and update the user on how it's coming along. I designed a set of tables to act as a queue. The web application would simply place any delivery requests in this queue and the progress bar would be determined by a request that checks the status of the items in the queue. Running in the background was a windows service which would also check this queue and was actually responsible for delivering the mail and setting the status of each item as it completed or failed.
It was a bit difficult to develop since windows services can be tricky but once it was up and running it was extremely smooth and reliable. Depending on your circumstances perhaps a simple scheduled task set to run every few minutes would do the trick for you.
I wouldn't necessarily jump straight to running a separate thread explicitly for the export. While it would be ideal to do this, the capability of the web container to do this is going to be a limiting factor. Your traditional Java EE app server generally discourages spawning threads for this (though you can hook up to a thread pool for this). Some containers are great at freeing up the threads from blocking until the work is done (Karaf with Jetty and Camel, for instance) so that they can service other web requests while the export is occurring. But my guess is that you're probably okay with the "start export" thread blocking until it receives a response.
How long does this export take? A couple of seconds, or are we talking closer to minutes here? If it's shorter, I'd think that just putting a little "Waiting" icon with the little circular spinner on it (using your favorite Ajax library, whatever that is) would be sufficient.
If you really want a true status bar that periodically refreshes itself, then yes you'd have to poll for it at some frequency. Presumably that could be a simple request that would load some kind of progress for the job from a database table for that job ID.
Find my answers Inline
I am following the right approach? Are there problem in using multi-threading in web applications?
-Yes you are on correct path. No there is no such problem in multi-threading in web application and its as easy as you do it in WinForm. Instead of using Dispatcher to update the UI, you would be making AJAX calls and with javascript DOM manipulation would take place.
If during the export process F5 or refresh button are pressed what exactly happens? How an I stop the process?
-Unfortunately there is no easy way. The standard way is, when such kind of processing is done and the user hits F5, you would show a dialog(with help of javascript) and inform user that the job is still running. If the user still wants to refresh then you have make another request to the server for cancelling the task.(You need to store thread id or cancellation token some where to cancel the task)
How do I update the progress bar periodically? Do I have to make calls via ajax to the server?
-The standard way is, generally you show show a loading image. IF you want to show a context senstive progress bar, it would mean you have to do polling. Here is an example by Dino Espito. Though its in ASP.NET, you could understand the underlying principle
Dino Espito
What framework can I start with to create a simple chatbot? the focus of the bot is very limited(for my project management website http://ayeboss.com).
One can compare it with SIRI on iPhone. I want to create a simple "answering" chat which will answer questions like "give me all completed tasks so far" or "show me last completed task" or "show|list|give me my pending tasks" etc. After user asks the question I want to present the data to the user
As of now I am creating a regex dictionary of possible questions and if there is no match then I do a lucene search to find the nearest match.
Am I doing it right?
Typically, chatbots within a narrow field like yours typically rely on 2 important concepts:
Intent detection: identifying what the user is requesting
Entity Extraction: Identifying entites in the users request. For instance in a flight reservation bot examples of entities are the source, destination and travel dates. In a weather bot the entities can be the desired date for the weather or the location where the weather is required.
For your specific type of chatbot, which has a definite goal of retrieving list of completed tasks and retrieving the last completed task. To develop this, you need to define the intents of interest. From you examples we can easily define 2 intents:
COMPLETED_TASKS_REQUEST
LAST_COMPLETED_TASK
Based on this 2 intents, there is really no entity to be detected. You simply query your service API to retrieve the requested information in each scenario.
The next phase will be to train a classifier to identify the intents. This can be done by getting some sample sentences for each request type and training over those.
The flow is then reduced to the following:
Bot receives message
Bot identifies intent
Bot extracts relevant entities (if required)
If intent is recognised bot queries data source to retrieve answer else bot complains it doesn't understand the request. Alternatively if bot needs an entity to complete request, bot asks user to provide the information and completes its task. This is usually called a slot based approach. You can read more on how a Dialog Manager works.
Note that if you're not into Machine Learning or NLP you can easily train an intent detector on platforms like wit.ai or api.ai and the entity classification part of this task will be reduced to simple http API requests. Though when building genuinely complicated or sophisticated bots it is almost always better to build your own models since you can have full control and can handle edge cases better. Platforms like wit.ai or api.ai generally need to perform well across multiple fields while you can focus on making yours an expert in task management.
Hope this helps.
PS: To make your bot more interesting we can add one more intent like retrieving the status of a specific task given the id. E.g a user can ask what is the status of task 54. This intent can be called:
TASK_STATUS_REQUEST. In this example, the intent has an entity which is the id of the requested task so you will need to extract that :)
This is a NLP task, and for building a system like this require lot of R&D. You can start by building a set of question that might be asked. Analyzing the questions and coming up with word patterns for each type of question. The next step would be to transform the English sentence into some form of formal structure( maybe SQL or lambda calculus). The backend DB should have the data stored in it which can be queried by the formal language.
The main problem lies in converting the English sentence to a formal language. You can start with regex and progress to make it more complex by checking Part of Speech, Syntactic structure of input sentences. Check out NLTK package for doing NLP tasks.
On top of chat bot library, you can integration instant messaging library like Hyphenate to enable chat bot for mobile and web communication.
Here're few simple steps:
Hyphenate Console: Create a chatbot entity by sign up an account at Hyphenate console (console.hyphenate.io) to give your chatbot an identity and a voice by creating Hyphenate IM account for the bot.
Platform SDK: Integrate your app (iOS, Android, or Web) with Hyphenate IM services and open source UI library.
Webhooks (event callback): Set up Hyphenate webhooks to receive the messages from the user that push to your developer backend, then process it in with your chatbot AI library.
Backend REST API: push chatbot's messages to the user via REST APIs provided by Hyphenate from your developer backend.
Hooray! Webhooks + backend REST API = relay messages between chatbot and user.
http://docs.hyphenate.io/docs/chat-bot-integration
You can use Microsoft NLP frameworks which are pretty straight forward and easy to use for beginners. Also was earlier know as LUIS, it's one of the Cognitive services that Microsoft provides.
It's basically a combination of API calls.
Not sure which language you are familiar with, but in Java you can do it using Apache OpenNLP library. This is a very good & easy to use library for natural language processing. To give very basic approach, you can break sentences & tokenize them into words. Then you can lemmatize words to get them to basic word forms. Then you can classify or categorize them using categorizer with proper training data. better the training, smarter the chat bot. Also you can select categories to make chat bot have conversation in more engaging way. Here is a very good article with detailed example & demo.