Spring batch Multithreading approach -Chaining reader or processor? - spring

I have requirement for job that needs to get report for total appointments created at all locations and appointment types for data range.
Below is sequence to achieve the same.
Read list of 50000 locations from excel
For each of above location call a Soap Service A to get list of appointments created at that location for a data range and appointment type. The request takes in appt type and location.
For each of above appointments call SOAP Service B to get order number.
I was thinking to create multiple steps for each appointment type and implement multithreading for each chunck size.
If I have 100 locations with chunk size of 10, have 10 threads execute step.
Each step will have reader that will read excel file and that I was thinking if I need to implement composite reader to call Service A to fetch appointments and pass it to processor which will call service B for each appointment returned in list by service A or is it better to implement composite processor which will:
Call Service A to get list of appointments (Use Async Processor) for each location chunk returned from reader
Pass list to second processor
Iterate over each item of list and pass appointment to service B to get order number. (Use Async Processor)
Use async item writer to generate excel
Then after all steps are done,combine excels for each step into one excel
Is there a better design to handle scenario.

Related

Is it possible to extract data from the body of an outlook email and throw it in SQL automatically?

Situation: We get audit emails every morning. The body of the email contains a table with various columns. The column labelled 'ID' is the unique key for each row. I have to copy the data from the ID column, format it in note++, and then paste it in a pre-filled query in SQL were I run it.
Question: Is it possible to automate this process? if so, where could I start? I would be nice if I could have something that either runs automatically or manually, reads the email, extracts the data from the column, formats it, and throws it in a query and executes.
Additional Details: The emails are always from the same distro, fire at the same time every day, and the table columns are static.
My skill Level: Beginner but resourceful and eager to learn, so please don't crucify me if I am not clear.
Yes, it is possible. You can develop a VBA macro or a COM add-in if you need to distribute your solution on multiple machines. Basically you are interested in handling the NewMailEx event of the Application class which is fired when a new message arrives in the Inbox and before client rule processing occurs. You can use the Entry ID returned in the EntryIDCollection array to call the NameSpace.GetItemFromID method and process the item. This event fires once for every received item that is processed by Microsoft Outlook. The item can be one of several different item types, for example, MailItem, MeetingItem, or SharingItem.
After retrieving the incoming item you can process it by getting property values and adding them to the SQL Db.
You may find the Walkthrough: Create your first VSTO Add-in for Outlook article helpful.

Event Sourcing - Data supplied to Command and data saved in Events

I am looking into event sourcing and I have a few thoughts that I need to get my head round.
Take for example an online shop -
The customer adds an item to the basket and saves their order.
The command handler could create an order on the customer aggregate root and add an OrderCreated event which contained the customer id, order id, item id, quantity and unit price. All pretty straight forward but what if the aggregate needed to check to see if that item was on special offer?
If this was for example a basket service would it subscribe to events from the catalog service and store it's own projections of the catalog service which it could then use, so then the basket service would comprise an event store and also some form of projection of the catalog service?
Or if in the example I've just described, if the basket and catalog functionality were part of the same application and they only held event data, then when a customer creates an order the handler would pull all ordered items from the event store via a repository, apply all events to them and then return them to the handler in order to check if the item was on special offer.
what if the aggregate needed to check to see if that item was on special offer?
It needs to execute a query to get the information it needs.
From the aggregate point of view those data are external, so it (or the handler sending the command to it) needs a query to access that information.
How the query work is up to you (there are pros and cons for each way), the query handler can:
Call a repository that loads an aggregate and check for the special offer (you can also think to have event sourcing in just one part of your system and having this part using another way to store dara, or not)
Make a remote call to the Catalog Service API to check for the special offer
Do a query to a local db, that is populated reading events emitted by the catalog service and stored "locally" to the basket service

Information recording for Charging

In TS-0001chapter 12 "Information Element Recording" triggers (e.g. a request on Mcc/Mca or any other interface) are described.
In clause 12.2.2 "Filtering of Recorded Information for Offline Charging" it is described how to derive charging information from recorded information which means that charging data is being derived from IERs.
In clause 10.2.11.14, "Service Statistics collection record" is described.
There are 3 questions:
First, is there any correlation between Service Statistics Collection record and IER? It looks like Service statistics collection record is a subset of IER derived on the basis of eventConfig and statsCollect resources. If it is a subset, then there is no field in IER which maps to "collectingEntityID" as Service Statistics Collection Record are derived corresponding to "collectingEntityID".
Second, there is no description for charging data records (CDRs). It is described as subset of IER. As a result of statsCollect, Service Statistics Collection Records are generated. When will the CDRs be generated?
Third, there is no linking between Service Statistics Collection record and CDR, both needs to be transferred on Mch interface.
For your first and third questions, I understand the confusion. The Service Statistics Collection record and a M2M Event Record probably should be combined or consolidated. In fact, based on your question we will shortly bring in contributions to the oneM2M standard to make this change.
For the second question, TS-0001 clause 12.2.4 describes CDRs. This clause defines Accounting-Request and Accounting-Answer messages that flow between an IN and a billing system over Mch. Within the Accounting-Request there is an M2M Information element defined in which M2M Event Record information is stored. This is effectively the CDR. Depending on the requirements of the billing system, the charging function of the IN will filter the required information from the M2M Event Record and store this information in the M2M Information element of the Accounting-Request message for transfer to the billing system.
In addition, TS-0004 A.2 "Diameter Commands on Mch" defines how to bind the Mch Accounting-Request and Accounting-Answer messages to the Diameter protocol for deployments which use Diameter.

How to pass parameters to Stored Procedure in Microsoft Flow

This is my first time to use Microsoft Flow
it looks easy but I am stuck at the moment
I want to pass data from MS Forms to my Stored Procedure using MS Flow
I managed to get the response ID but that is not enough,
I want the rest of the data in the MS Forms
as in the image below
List of response notifications Response id will send the ID of the response
but
Current item will send this data
{"webhookId":"f912d0db-1dd4-4c7e-b655-ae75d4bb3d7a","eventType":"ResponseAdded","resourceData":{"formId":"dVLH1V-fFkuoPzxppiOnlzixU_JOYMlMpqOmPhdZrLpUREV0OU5VFFNJVE5XUE0GS15DQVVWTlFaMC4u","responseId":3},"eventTime":"2018-12-10T01:13:15.4185181Z"}
my question is how to pass user entry in the MS Forms to the SP?
You should add an extra action to your flow, to get the details of each row.

How to launch one thread group from another in jmeter

I am very new to Jmeter. In my application I have two scenarios.
1. Create: Here we book a hotel room. After booking application returns a transaction ID.
2. Cancel: We need to pass the transaction Id to the application to cancel booking.
I want to test with jmeter in such a way that after a create call is made, the cancel call of the respective create is called with the generated transaction ID automatically.
Don't have any clue how to do this. Application is written using spring, REST web service. There is one BeanShell Preprocessor in my existing .jmx file. Using that jmx file I call the create & cancel service individually.
Normally you can use a variable to store a string and use it later on, however it is not possible to pass a variable from one thread to another. To do this you need to use a property: this site explains how.
Of course if you need to save a lot of transaction ID's it might make more sense to have the first thread group store them in a csv file and have the second one read them from the file. Have a look at the CSV Data Set Config.
Create: Here we book a hotel room. After booking application returns a transaction ID.
User regular expression extractor to extract transaction Id from it and store it in a variable.
Provide the name of the parameter you get in response in regular Expression text field
Here it will extract transactionId from the response of create and stores it in transactionID variable.
Cancel: We need to pass the transaction Id to the application to cancel booking.
Provide the variable name in which transactionId is stored to as the parameter value of cancel request.

Resources