How to make Async adapter calls within adapter - ibm-mobilefirst

Adapter Mashup - IBM MFP 8
I have a common adapter which call other streams to get info. I need to send the consolidate result back to client side.
Ex: I have 4 API call, 1 (2Sec), 2 (2Sec), 3(3Sec), 4(2Sec)
Total time taken for the adapter is 9Sec instead of max as 3Sec. Calls are triggering sequentially instead of Parallel.

In case of adapter mashup, the calls are synchronous and sequential. This is by design.
You can submit a Request for Enhancement for this here.

Related

JMeter performance test for webhooks

I'm a Newbie in using JMeter tool and could not find a approach in JMeter to run End to end performance test of below use case:-
I have https webhook(Hosted on my node JS server) that is invoked on new device creation on Azure IotHub(Webhook subscription is done on Azure IotHub).
Once invoked, I parse the webhook(request) body and generate a unique token.
Once unique token generated, I set that token in the device configuration for which the webhook was called.(I get the deviceId in webhook body)
Once the device configuration set I return the response of webhook as 200.
Now, In JMeter how can I achieve step 1-4. My initial approach is to:-
Write python script to simulate new device creation on IoT hub.
After step 1 I'm not sure how will I capture the webhook invoked and response returned from webhook in JMeter.
Basically, Im not sure how I can successfully capture Step 2 and 4. Step 3 is basically the nodejs code for my webhook hosted on my server.
And I need to run step 2 and 4 200K times to measure the performance.
In summary, I have a script which registers device on cloud which triggers my webhook/api and I will calculate the response time in my script i.e. everything will be written in my script just that I want JMeter to show all the charts etc. based on the calculations I do in my script.And the script should be invoked n number of times as per the load required.
Any help in guiding me the approach would be very appreciated.
I have a solution for this now, in case anyone needs it.
Thread Group --> OS process sampler --> Response time graph
Above are the components I used in my JMeter tool. OS process sampler can run any script on your machine.

Is there a way to wait for the reception of a rabbitmq message?

I have a use case where I need my controller action to wait for the reception of a specific rabbitmq message so I can return the result to the client, this message would come from a separate worker performing a certain task.
My api project and the worker project are separated and rabbitmq bus is the only intermediary between them.
EDIT: This is the current Scenario:
Client sends request to the web api to ask for let's call it 'DATA'
The web api publishes a Message-A through rabbitmq
A separate service project handles the published Message-A, does some work, and publishes a new Message-B that contains the result of that work which we called 'DATA'
Here is the problem: My web api controller have to return the results contained in Message-B, so the controller action should wait for that message before returning to the client
You need to use a TaskCompletionSource<T>.
You need to subscribe to the reply messages and, if it's the reply you're waiting for, set the result of the task completion source.
Then await the task of the task completion source.

AspNetCore SignalR Streaming Clarifications

I have been going through the recent signalr documentation, and i stumbled across the new feature called Streaming. I also, and i managed to get it running with a JS client. However, i am still not clear on when to use it.
1- Does ChannelReader stream data to a single client?
2- If yes, what is the difference than calling this.Clients.Caller.Invoke()
3- Lets say i am listening to an external realtime feed e.g. stock exchange, is it recommended to use signalr stream?
4- According to this post, the writer lives within a Task.Run(). So how is this scalable if i need to push a real time feed using streams to lets say 1000 clients? Are there any scalability concers of using signalr streams generally?
1- Does ChannelReader stream data to a single client?
Yes.
2- If yes, what is the difference than doing this.Clients.Caller.Invoke()
You can only invoke a single method at a time (sequentially). As long as you are in an invocation, the rest will be queued for that connection until the previous one is finished. With streaming methods, you can start a stream and pump data to the client while still invoking other methods on the same hub.
3- Lets say i am listening to an external realtime feed e.g. stock exchange, is it recommended to use signalr stream?
Streams are for streaming data triggered from a client action. You can still do unsolicited (not from the client) streaming by just calling a method on the IHubContext.
4- According to this post, the writer lives within a Task.Run(). So how is this scalable if i need to push a real time feed using streams to lets say 1000 clients? Are there any scalability concers of using signalr streams generally?
It scales fine. The Task.Run kicks off the Stream but you're never holding a thread hostage.

VM or Flow-Ref for eCommerce system

I am developing a mule application where I have to take orders from One system System-1 & have to send it to the another system say System-2 through soap (which actually takes care of creation of orders, invoices etc) & the response from System-2 is routed back to system-1 with success or failure response. Now what approach should be the best, will a VM be the best approach for referencing purpose or a flow reference ? The number of orders coming could be like 100 per hour. Also for both cases what should be the ideal worker size ?
If the system 2 is to be called SOAP web service, you should be using web service consumer component or an http requester component.
Lets understand the difference between flowref and vm.
Both flowref and vm are used to call another flow within the mule application.
Major difference between both is vm uses in-memory queue to refer to other flow and it creates a transport barrier, hence flow variable and inbound properties wont be propagated across, hence use of vm component should be considered only of it creating a transport barrier is necessary.
If thats(creating transport barrier) not the requirement, usage of flow ref is recommended.

Multiple calls to service not handling all requests

I have a Silverlight app that uses WCF for communication with my SQL Server via Entity Framework. When I send multiple requests to the service it fails to send all. If I use the Callback event and send each request as the previous one completes all is well. How can I get this to work without this workaround?
Edited:
For i As Integer = 0 To someNumberOfTimesInLoop
serv.CloseElement_IncAsync(Params...)
Next
So I wonder if it's a concurrency problem as they hit at the same time and the Id fields for these tables are not incremented in time?
I have added this code in my App.xaml.vb based on this blog:
WebRequest.RegisterPrefix("http://", WebRequestCreator.ClientHttp)
Any ideas?