I am using Apigee Usergrid to create a car service database. My scenario is as such.
A customer can book his car for a service with his mobile app. This creates a service request in the car service db .
Now, many a times, the customers do not turn up on the booked date and time. In such a case, I want to mark the slot NO-SHOW as soon the stipulated date and time gets over.
As of now, I have a job that runs every day to clear up all such no-shows. But now, we have a requirement to mark such slots NO-SHOW almost as soon as the stipulated hour + 2 passes by.
E.g. if the reservation is on 24th Sept at 0900hrs and the car owner doesn't show up even after 1100hrs, the reservation booking has to be marked NO-SHOW.
Is there a way to achieve this implicitly in user grid?
Unfortunately this isn't available out of the box. You might try wiring up a Node.js service in Edge (enterprise.apigee.com) to do this?
Related
I have product service, category service, promotions service, search service.
When User want to add product. CreateProductRequest come to product service. Request includes product data and datas of other services like categoryId,uncalculated price , too. After product is added. I need to send other servie datas. Category service needs productId and CategoryId. Promotions service needs productId and price.
After creat eproduct transaction commited;
1) I put all data in ProductCreatedEvent that includes saved productId, categoryId, uncalculated price etc. Every service get what it needs from event and save to own db. I publish event with RabbitMQ
2) Send via seperated commands to services.I send commands with RabbitMQ
And What If there is no category that id come with event and Category services didn't save. But Product saved at product Services ?
or what do you suggest ?
To answer the question, it's important to keep in mind the difference between a command and event. A command is a request to do something. An event is a record of something that has happened. One key difference is that a command can be rejected.
When looking at your use case, publishing events to other services makes the most sense. The product has been created and you are notifying the other bounded contexts that care about the change. If you issue a command, you are telling other bounded context to make a change that may or may not fail.
That said, you each bounded context may receive the event and produce a command within their own context to update aggregates managed within. As such, the difference is subtle between these two:
- Issue a command to each bounded context
- Issue an event to each bounded context and they can then trigger a command as needed
But given the above, the notification of the creation of the product should not fail. It has happened already. From there, each context can decide what to do about it.
I would like to integrate my web application with the Square POS.
The goal would be to be notified each time a transaction (sale/refund/etc) is processed by Square for an account so that I can update inventory levels etc, ultimately so I can update inventory levels as transactions occur.
From what I can tell, it seems that the Square API's seem to be designed around my application initiating the transaction, then handing off to Square to process the payment. I simply want to be notified that a transaction has happened so that I can update inventory.
Is it possible to do this? Or is the Square API just for processing payments?
edit: After some more reading, I still haven't found a webhook to be notified, but it looks like I can ListTransactions, and RetrieveTransaction, so if I poll I should be ok.
You’re correct. Square’s API Webhooks will be what you’ll use to be notified each time a transaction is created or updated. We have a quick setup guide available in Square’s Developer Doc (https://docs.connect.squareup.com/api/connect/v1/?q=webhooks#setupwebhooks).
The PAYMENT_UPDATED webhook will alert you every time a payment is made, so that you can update your inventory.
I have a tested app that will hopefully go live in the short term.
However, it has 3 in app purchases.
If the situation arises where I need to do a further test of purchasing the in-app-purchases, is there any way I can cancel my own personal in-app-purchases up to that point so I will be testing from scratch?
Note: I am using the new Windows.Services.Store.StoreContext method, and not the old one.
First, there's no such API that can cancel your in-app-purchase currently. But you can still do your further test.
If the situation arises where I need to do a further test of
purchasing the in-app-purchases, is there any way I can cancel my own
personal in-app-purchases up to that point so I will be testing from
scratch?
According to your description, it seems your IAP type is durable. If so, you can specify the duration for the product as 1 day so that you can repurchase it after it expires.
If your IAP is developer-managed consumable type, you need to report the previous IAP as fulfilled after the user consumes all the items. Then they purchase it again.
If your IAP is Store-managed consumable type, you need to report any items consumed by user as fulfilled to the Store and the Store updates user's balance. After users consume all the items, the user can purchase that IAP again.
For more details, you may refer to In-app purchases and trials.
Requirement-
The requirement is to send notifications to devices on specific times. That is, if a user has setup a schedule at 07:00 AM for breakfast, he'll get a notification for the same like 'Its time for breakfast, blah blah blah!'.
However, if the user has already had his breakfast before 07:00 AM, he'll make his diary entry on what he had etc. and then the notification must not be sent to him.
This is a recurring schedule and the user will only change this if he needs to, otherwise, the schedule will mostly be the same.
What we have achieved?-
So, for now what we do is to register devices with tags like '{TimeZone:EST},{Breakfast:07:00:00}' on the app's launch.
In case, the user has already had his breakfast, we update his registration on notification hub to also contain a tag like '{HadBreakfast}' - So, the set of tags user's device is registered to becomes - '{TimeZone:EST},{Breakfast:07:00:00},{HadBreakfast}'
What are we stuck at?-
This approach will work very well because, when sending notifications, we use tag expression like - '{TimeZone:EST} && {Breakfast:07:00:00} && !{HadBreakfast}'
So, this will send a notification to all users that wants a notification for breakfast at 07:00:00 AM for EST timezone but not to the ones who already had their breakfast.
However, if the user is registered with a tag like {HadBreakfast}, then the next day, he might not get the notification based on the logic just described.
So, we came up with the workaround to de-register only the {HadBreakfast} tag at the end of day for all the devices which has that tag by running a scheduler.
But, somewhere in our mind, we think that is not the best solution for this problem.
Other Alternative-
We also thought of another alternative that we can run a scheduler for every hour within which, it will do the same thing of removing such tags for the past hour for all the user devices which has that tag - and this process seems to be effective than running it once in a day.
But we wanted to know thoughts from the community on what I can try out? If the method that we use is correct or not? What else could be done to do this more simply OR smoothly? What if we have a million plus devices? Will this work?
I would suggest exploring the option for modifying registration in bulk and using the Azure Scheduler for the reaccuring task
I am dealing with subscriptions where a user is subscribed to a plan and it has an expiration.
So basically each user store has an expiration field.
I want to be able to get notified when a user plan is expired as soon as it is actually expired.
Right now, I have a job that runs on all users once a day and check if anyone has expired but ideally I would like to get a server postback or some sort of event whenever a user is expired without running this each day.
Can you think of any third party service / database / other tool that deals with these sort of things ?
A lot of services, Stripe for example, notify you with a webhook whenever a user's subscription is renewed / expired. Are they just running a job repeatedly like I am ?
Hope I made myself clear enough, would appreciate help in how to focus my search in Google as well.
My current stack is Mongodb, Node.js, AWS
Thanks
We do not know for sure, how Stripe handles it.
There are two solutions coming to my mind. Let's start with the simple one:
Cronjob
As you mentioned, you already have a Cronjob solution, but you can instead make it run each hour, or each 10 minutes. Just ensure you optimize your query to the maximum, so that it is not super-heavy to run.
It is attractive, easy to implement, very few edge cases, but as you might have though can be a performance drag once you reach millions of clients.
Timers
Implementation varries, and you need to worry about the edge cases, but the concept:
On day start* (00:00) query for all clients who are set to expire today, save them into array (in-memory). Sort the array by time (preferably descending).
Create timer to execute on last array's element time.
Function: If Client X expires now, query database to ensure subscription was not extended. Notify if it wasn't.
Remove Client X from the tracked array. Repeat step 2.
On day start* - Also run it on script launch.