Using many Resource URI to create a Record and handling failure

Hi Guys,

I have a decision to make to solve a problem, I’m describing the problem below.

Application Overview

I have an ASP.NET MVC 4 webApp which uses Rest Api for almost all the tasks, from Login to CRUD on the records.

The rest api is being developed by a separate disjoint team and the webApp is being developed my me.

enter image description here

There is a particular scenario which leads me to think that something is not right may be the Api is having an issue or I’m not developing the WebApp the right way.

I made a screen for Employee creation, it collects several information related to an employee, on submit to the server I collect these information serialize them into json and send them to Resource URI using the POST method.

enter image description here

The problem is in order to create a single employee I would need to hit four Resource URI one by one,the Person needs to be created first (its the independent record) and then I can proceed with the person_id to create Phone,Email and Address.

Person > (Phone | Email | Address)

Possible Issues:
Now If the Person creation fails I would show user that the operation failed and he/she could try again.
If the person creation succeeds but one or more preceding record creation fails then actually Employee creation fails,it’s kind of a transaction all record should be created to successfully create employee.
Also a useless person will be hanging around of no worth and then the Application user might try to create the employee again and this problem may happen again.

Possible Solutions

A) Solution at my End:
Make a windows service running with a scheduler,which checks a DB if failed requests are there,and if it finds any it performs the api request to complete the tasks.

enter image description here

B) API Level Solution:
Make an Employee Resource URI which is able to receive the json of all the distinct json objects in a single go and respond with result.
Of course these separate json object may correspond to separate DB tables and the API developer will handle them through transaction.

C) Use QueueBackgroundWorkItem
use the QBWI to quickly make several async request for the failed resources and return with failed and success message also log and email the admin,no need to manage a separate Windows Service and a DB.

for more details on QBWI.

Remarks:
I will go for the solution B ,its seems like the best option but due to time constraint I might need to apply the solution (C)

Guys I need you to critically examine the scenario and the solution sections and provide me analysis and the best possible solution.

B definitely sounds like the only sane choice.

A means depending on implementation details of the REST API. It makes the “transaction” very fragile, breaks encapsulation, and other bad things.

C I’m not entirely sure what you’re saying you’ll do with a QBWI (beyond the email to admin part), but it doesn’t sound like an actual solution to the problem. Something as simple and fundamental as transaction semantics definitely needs to be handled by the software, not by human admins.

In the real world, the “disjoint team” may fail to deliver a real solution. This would be when you talk to business managers and explain to them that you can do a hacky workaround (A or C) in the short term but you really need the other team to give you a proper API someday. They’re the ones in a position to decide whether it’s better for the company to do the workaround now or have you do something else for the time being.

2

there is problem in ur requirement gathering
1st u said “…(its the independent record) and then I can proceed with the person_id to create Phone,Email and Address

then u said : If the person creation succeeds but one or more preceding record creation fails then actually Employee creation fails

means it is not independent.

lets assume its independent
then it means user can add orr update its address resource, phone resource etc after words.

solution like u can redesign this screen in way that first u create user with Person Resource and then get his other informations afterwards.

and if its dependent then u cannot disjoint the resource like that, in API u have give complete information to perform task.
User creation is a task and its complete information is all together.

4

Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa Dịch vụ tổ chức sự kiện 5 sao Thông tin về chúng tôi Dịch vụ sinh nhật bé trai Dịch vụ sinh nhật bé gái Sự kiện trọn gói Các tiết mục giải trí Dịch vụ bổ trợ Tiệc cưới sang trọng Dịch vụ khai trương Tư vấn tổ chức sự kiện Hình ảnh sự kiện Cập nhật tin tức Liên hệ ngay Thuê chú hề chuyên nghiệp Tiệc tất niên cho công ty Trang trí tiệc cuối năm Tiệc tất niên độc đáo Sinh nhật bé Hải Đăng Sinh nhật đáng yêu bé Khánh Vân Sinh nhật sang trọng Bích Ngân Tiệc sinh nhật bé Thanh Trang Dịch vụ ông già Noel Xiếc thú vui nhộn Biểu diễn xiếc quay đĩa Dịch vụ tổ chức tiệc uy tín Khám phá dịch vụ của chúng tôi Tiệc sinh nhật cho bé trai Trang trí tiệc cho bé gái Gói sự kiện chuyên nghiệp Chương trình giải trí hấp dẫn Dịch vụ hỗ trợ sự kiện Trang trí tiệc cưới đẹp Khởi đầu thành công với khai trương Chuyên gia tư vấn sự kiện Xem ảnh các sự kiện đẹp Tin mới về sự kiện Kết nối với đội ngũ chuyên gia Chú hề vui nhộn cho tiệc sinh nhật Ý tưởng tiệc cuối năm Tất niên độc đáo Trang trí tiệc hiện đại Tổ chức sinh nhật cho Hải Đăng Sinh nhật độc quyền Khánh Vân Phong cách tiệc Bích Ngân Trang trí tiệc bé Thanh Trang Thuê dịch vụ ông già Noel chuyên nghiệp Xem xiếc khỉ đặc sắc Xiếc quay đĩa thú vị
Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa

Using many Resource URI to create a Record and handling failure

Hi Guys,

I have a decision to make to solve a problem, I’m describing the problem below.

Application Overview

I have an ASP.NET MVC 4 webApp which uses Rest Api for almost all the tasks, from Login to CRUD on the records.

The rest api is being developed by a separate disjoint team and the webApp is being developed my me.

enter image description here

There is a particular scenario which leads me to think that something is not right may be the Api is having an issue or I’m not developing the WebApp the right way.

I made a screen for Employee creation, it collects several information related to an employee, on submit to the server I collect these information serialize them into json and send them to Resource URI using the POST method.

enter image description here

The problem is in order to create a single employee I would need to hit four Resource URI one by one,the Person needs to be created first (its the independent record) and then I can proceed with the person_id to create Phone,Email and Address.

Person > (Phone | Email | Address)

Possible Issues:
Now If the Person creation fails I would show user that the operation failed and he/she could try again.
If the person creation succeeds but one or more preceding record creation fails then actually Employee creation fails,it’s kind of a transaction all record should be created to successfully create employee.
Also a useless person will be hanging around of no worth and then the Application user might try to create the employee again and this problem may happen again.

Possible Solutions

A) Solution at my End:
Make a windows service running with a scheduler,which checks a DB if failed requests are there,and if it finds any it performs the api request to complete the tasks.

enter image description here

B) API Level Solution:
Make an Employee Resource URI which is able to receive the json of all the distinct json objects in a single go and respond with result.
Of course these separate json object may correspond to separate DB tables and the API developer will handle them through transaction.

C) Use QueueBackgroundWorkItem
use the QBWI to quickly make several async request for the failed resources and return with failed and success message also log and email the admin,no need to manage a separate Windows Service and a DB.

for more details on QBWI.

Remarks:
I will go for the solution B ,its seems like the best option but due to time constraint I might need to apply the solution (C)

Guys I need you to critically examine the scenario and the solution sections and provide me analysis and the best possible solution.

B definitely sounds like the only sane choice.

A means depending on implementation details of the REST API. It makes the “transaction” very fragile, breaks encapsulation, and other bad things.

C I’m not entirely sure what you’re saying you’ll do with a QBWI (beyond the email to admin part), but it doesn’t sound like an actual solution to the problem. Something as simple and fundamental as transaction semantics definitely needs to be handled by the software, not by human admins.

In the real world, the “disjoint team” may fail to deliver a real solution. This would be when you talk to business managers and explain to them that you can do a hacky workaround (A or C) in the short term but you really need the other team to give you a proper API someday. They’re the ones in a position to decide whether it’s better for the company to do the workaround now or have you do something else for the time being.

2

there is problem in ur requirement gathering
1st u said “…(its the independent record) and then I can proceed with the person_id to create Phone,Email and Address

then u said : If the person creation succeeds but one or more preceding record creation fails then actually Employee creation fails

means it is not independent.

lets assume its independent
then it means user can add orr update its address resource, phone resource etc after words.

solution like u can redesign this screen in way that first u create user with Person Resource and then get his other informations afterwards.

and if its dependent then u cannot disjoint the resource like that, in API u have give complete information to perform task.
User creation is a task and its complete information is all together.

4

Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa Dịch vụ tổ chức sự kiện 5 sao Thông tin về chúng tôi Dịch vụ sinh nhật bé trai Dịch vụ sinh nhật bé gái Sự kiện trọn gói Các tiết mục giải trí Dịch vụ bổ trợ Tiệc cưới sang trọng Dịch vụ khai trương Tư vấn tổ chức sự kiện Hình ảnh sự kiện Cập nhật tin tức Liên hệ ngay Thuê chú hề chuyên nghiệp Tiệc tất niên cho công ty Trang trí tiệc cuối năm Tiệc tất niên độc đáo Sinh nhật bé Hải Đăng Sinh nhật đáng yêu bé Khánh Vân Sinh nhật sang trọng Bích Ngân Tiệc sinh nhật bé Thanh Trang Dịch vụ ông già Noel Xiếc thú vui nhộn Biểu diễn xiếc quay đĩa Dịch vụ tổ chức tiệc uy tín Khám phá dịch vụ của chúng tôi Tiệc sinh nhật cho bé trai Trang trí tiệc cho bé gái Gói sự kiện chuyên nghiệp Chương trình giải trí hấp dẫn Dịch vụ hỗ trợ sự kiện Trang trí tiệc cưới đẹp Khởi đầu thành công với khai trương Chuyên gia tư vấn sự kiện Xem ảnh các sự kiện đẹp Tin mới về sự kiện Kết nối với đội ngũ chuyên gia Chú hề vui nhộn cho tiệc sinh nhật Ý tưởng tiệc cuối năm Tất niên độc đáo Trang trí tiệc hiện đại Tổ chức sinh nhật cho Hải Đăng Sinh nhật độc quyền Khánh Vân Phong cách tiệc Bích Ngân Trang trí tiệc bé Thanh Trang Thuê dịch vụ ông già Noel chuyên nghiệp Xem xiếc khỉ đặc sắc Xiếc quay đĩa thú vị
Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa
Thiết kế website Thiết kế website Thiết kế website Cách kháng tài khoản quảng cáo Mua bán Fanpage Facebook Dịch vụ SEO Tổ chức sinh nhật