Two way communication in Catel MessageMediator - catel

What is the recommended way to set up two way communication through the messagemediator?
My instinct was to create 2 channels (request/reply). I don't see any way to create channels within the MessageMediator.
Then my idea was to have 2 instances of the messageMeditor but this seems clumsy.
Last I could have a callback as part of my message. Is this the recommended way to achieve this?

Related

How to decide what to name a stream in Rails Event Store

This is a bit of a newb question but I struggle with how to decide what a stream should be called and I can't seem to find documentation on how to go about it.
For instance, a lot of the examples in the documentation just have "Customer$1", "Customer$2", etc. I'm presuming Customer is the resource here and the integer is the customer ID?
For my use case, I have UnitAllocated and UnitDeallocated events happening for multiple different Operators. Ideally, I want to have a stream of unit allocations and unit deallocations for a given operator.
Should I embed the operator ID in the stream name as an easy way to tap into multiple stream for the same operator? Or is this the wrong way to go about this?

Open multiple positions in Backtrader

Does someone know if it's possible to open multiple positions with only a single data feed? I am trying to do a second buy whilst in a position, which doesn't seem to be possible.
Nobody seems to adress this issue. Does anyone have any experience with Backtrader and have any input?
If you are just trying to buy more stock to add to your position, then yes, you should be able to do this and if you cannot recheck your strategy code in next.
If you are trying to track two separate positions of the same data...
One cannot have two separate positions in the same data feed. You may trade additional positions if you like but they will be combined in Backtrader. Even if you use two strategies you will still have one combined broker.
The reason for this is to simulate as near as possible real world conditions. If you have a brokerage account you most likely would have just one postion. (I know there are exceptions)
One solution would be to track your trading manually in a dictionary trades that result from different signals/sub-strategies. It's a bit more tedious to develop but very doable.

How to track time taken on each step in RASA chatbot

I am pretty new to RASA. Our bot uses a lot of custom actions on each step of the conversation. There is a new requirement in my project to track the time a user spends on each step and log it into a separate data-store.
I have tried to use a simple class lo keep a track of the steps (current and previous steps) and calculate the time between steps on each interaction.
Not sure how to scale this solution to track the time taken for multiple sessions (or whether this is a right approach in first place).
Not really sure of the life-cycle of the classes
Would really appreciate any insights/pointers on how to achieve this specially for each individual user/dialog.
The easiest solution is probably to store all of this information in the tracker. E.g. you can create an unfeaturized slot called step_times and store a dict in there with the timing for each step.
You can then configure the sessions not to erase these slots https://rasa.com/docs/rasa/core/domains/#session-configuration (or create a custom action_session_start )

Approach to find duplicate - Kafka and queue

Question asked in interview ---Suppose there are two kafaka topic or lets say queue - Q1 & Q2
Both are having some messages suppose 10 messages each.
The condition here is if both the queue are having same messages exctaly same in both queue it's fine but if there is even one odd or non. matching message we need to error out or notify.
the approach i suggested for this problem.
1- Using hashset We can find.. we will add first queue message in add set and while adding other add method will notify us if message is not already there.
2- we can use the Hashmap and store it as key value form..while adding it i will check if the key -message is already there.
but he was not satisfied he did not share the right answer or problem. with above approach.
Let me know if better solution exist and the problem with this approach
He may have been aiming to get into a discussion about the difficulties of balancing in a real-time streaming situation. Let's say there is a continuous stream of messages going through the two topics how do you know if things are balanced?
There is no single answer, it depends on the situation but generally has to consider some kind of time window.
My guess is that the interviewer's dissatisfaction (if any) would be because he was looking to talk about options rather than going to one specific solution to a specific situation.
We can't know what he was thinking without asking (which I would always recommend) but when I'm interviewing I always look for candidates who can consider and discuss problems and trade-offs, not necessarily ones who have the 'right' solution.

How to implement If condition in Cucumber Scenarios

I have a specific scenario as follows:
if (element shows up on UI)
validate it
else
no harm done; move on...
If I know upfront if the element shows up or not, I can frame two different scenarios, when the element shows up and when not.
But, in this case, it may or may not be present. If it is present, it should function as expected.
Any suggestions on how this can be implemented in a Cucumber scenario(s) ?
I am using Cucumber-jvm.
You have two separate scenarios, you just need to be able to make sure you setup the preconditions to assume one scenario vs the other.
In general, you should not be implementing a conditional inside a single scenario, because your intent is to test two scenarios.

Resources