I have an application which consists of storing custom queries against some objects. These objects are managed in another application so I only receive events whenever something happens on these objects.
Now every time a new instance of such an object appears - which I know by an event - I want to check if it matches any of my custom queries and if so, emit an event that there is a new match.
The query does not know in advance which objects might match, and the objects in turn do not know of the existence of any of these queries. So from my understanding, a saga will not help me solve this problem.
But I think an event handler should not directly emit new events. So I wonder if I should create a command to send to my query objects so it can execute and check for a match, or if there is some other pattern I can apply.
I don't think my custom query aggregate is the right place to check for new matches, since it actually does not care; it just manages the query. But having to introduce a new aggregate and send it a command, just to let it check for new matches, feels like it might not be the right place either.
Any advice on this issue?
It looks like a Set Based Validation to me!
If that is the case, AxonIQ has a pretty good blog about this problem/pattern and ways of solving it using AxonFramework!
https://axoniq.io/blog-overview/set-based-validation
Basically, you can have a projection close to your Aggregate where you can check for those values, if they exist or not. Mind you that those projections should never be exposed to the outside world and only used by the Aggregate itself configured with a Subscribing Event Processor, meaning they will be updated right away.
Related
I'm trying to replicate a common design pattern used by many PHP frameworks where the properties of a class are populated with live data taken from the database. For example, you pass an ID to the constructor of the Product class and the class properties are filled with the related database fields. The problem I'm encountering is basically due to the asynchronous nature of database queries in Node.js. Either you choose callbacks or Promises or even the latest and (IMHO) exciting features of async/await, you have always to deal with a new scope where the binding to the main object is gone. If you can point me to the right direction, I'll surely appreciate it very much.
Thanks in advance for your time.
I have a database component that I'm trying to make as general as possible. Is it possible to accomplish this:
Take in a custom class that I don't have the definition for
Recreate that class locally from the foreign instance
Basically I can't include the definition of objects that will be stored in the database but I want the database to process the raw data of whatever class passed in, store it, and be able to provide it again as an object.
Ideally I could cast it back to it's custom class when the Object gets back from the database.
It sounds like what you are asking for is serialization.
Serialzation in AS3 is possible through a few different methods. I recommend you refer to this article as it describes the method quite clearly.
To elaborate, once you serialize your object, you send it to the server and pair it with a key in a database. Then you can serialize it back into the original object by downloading it from the server again.
I think you're going to find that there are a lot of pitfalls with what you want to do. I suspect that you'll find over the long haul that you can solve the problem in other ways, since someone, somewhere needs a definition of the Class you're instantiating (you also need to think about what happens if you have two instances with conflicting definitions).
Probably a better way to go is to make your app more data driven--where every object can be built based on the data about it. If you need to be able to swap out implementations, consider storing the Class definitions in external swfs and downloading those based on paths or other information stored in the database. Again, you need to consider what will happen if the implementations collide between multiple swfs.
Can you expand on what you're trying to do? It's easier to give you clearer instructions with more information.
I'm trying to figure out, if or how it would be possible to implement some custom call back written in C that would get called when a table row was inserted, deleted or updated. The background is, that I have to implement some kind of view to specific data tables and one easy and generic approach would be to implement some kind of triggers, that can call a C function.
Polling is not really an option and changing the design is cause the next thing to do, if I'm confident that what I'm trying to do is not feasible.
BTW: Might this be doable with an Oracle DB?
At the moment I'm stuck with the need to debug several functions in our system to determine if they're working or not.
The situation is basicly that I'm left with someone elses CakePHP structure which makes me unable to know the code in and out. This is due to lack of time and lack of documentation.
I need to run tests on this system, however it will cause incorrect data on our reports page when I create new orders etc. This is not allowed and basicly there's a lot of models which saves data to the reports by simply creating other rows.
The easiest solution here would be to make no report rows get created if I'm logged in as a certain user. Then I'd simply just do a condition and determine if I should insert the report row in the database or not. (if ($bool_tester) return FALSE; else /* Insert data */)
This would however require to fetch the Session data within the Model, which I've read is a bad solution. I can't simply run an extra parameter in the function, since the function is called on so many places in so many files.
So my question is basicly; Should I include Session data within the Model regardless or is there any other nifty solution that makes me not insert these rows when I'm testing.
Defining a session value through the controllers isn't a smooth solution either here.
Do the testing in your development environment, not on the live site.
Do you use unit testing for the tests? CakePHP does support that. When you are, you could stub or mock the data within your setup for the test. Cake also supports that.
How to handle transaction within a scope using Enterprise library. I've 3 stored procedures, which I need to execute in a single scope. I dont want to use System.Transaction name space
You can call the BeginTransaction method on a connection object to get a DbTransaction object. Then use the Entlib Database object's overloads that take a DbTransaction. However, it's a giant pain to manage. You'll need to create and close least one connection manually rather than relying on Entlib to do the right thing, and you'll have to pass the DbTransaction object around to everything that needs it.
TransactionScope really is the right answer here. If you've got some blocking scenario that really prevents you from using it that isn't some brain-dead corporate policy, I'd love to know what it is.