Hi again,
October 26. 2019 at 15:30 (3:30PM) CEST (UTC+2) I presented kbmMW core features.
The presentation focused on the central pieces of kbmMW like the transport, transport stream, custom service and simple client, in addition to showing a little bit about the traditional query service and client features.
Find the replay at: https://www.youtube.com/watch?v=6sNyFkO_P7E
If you have a great idea for a topic, and perhaps even would like to present it yourself, then just contact me on email at kbm@components4developers.com. I welcome just about anything of interest for Delphi, as long as its legal and can be viewed by minors. Even presentations about competing products are valid topics!
This is the itinerary for the next upcoming meetings:
Nov 9, 2019 03:30 PM – kbmMW authorization features explained
Nov 23, 2019 03:30 PM – ?
Dec 7, 2019 03:30 PM – ?
Dec 21, 2019 03:30 PM – ?
Please download and import the following iCalendar (.ics) files to your calendar system.
Download ICS calendar file
Kim,
Some questions:
1. When I have a service derived from TkbmMWCustomQueryService how can I make it multi-threaded? I.e. when there are multiple users and threads requesting TkbmMWClientQueries how can I make them run in different threads so that one long query of one user would not make everybody wait? Where can I read more on that subject?
2. Is it possible to have TkbmMWClientQuery on a client side but on a server side to have a procedure that would construct the dataset ‘manually’ instead of using pre-made query components? Is there any documentation or sample code?
Thanks in advance,
Alex Liberov
Hi Alex, I will try to answer you with the things I have already learned.
1) Any KbmmwXXService is Multithreaded, the only thing you need to set the service flags that is if there will be a Pool for a limited number of instances of a service:
—-
// Return the maximum number of instances that is allowed to run.
{$IFNDEF CPP}class{$ENDIF} function TkbmMWCustomServiceXXXX.GetMaxInstances:integer;
begin
Result:=-1; //unlimited
end;
—
or you must create an instance per thread/session (stateful). In the kbmmw service wizard, select ‘stateful’ service.
——-
{$IFNDEF CPP}class{$ENDIF} function TkbmMWCustomQueryServiceXXXX.GetFlags:TkbmMWServiceFlags;
begin
Result:=[mwsfListed,mwsfStateful];
end;
——
check demo: Demo\Basic\Stateful
2) Dont understand exactly your question, do you mean to use a clientside query like ‘select * from XXxxxx’ , withotu having to have a corresponding Server side qury object for that select? the queyr servcie is for that, ti create a new TkbmMWXXXquery (FireDAC, ODAC, ADO, Etc) on the fly when a sql query is submitted via kbmMWClientQuery.
check demo:
Demo\Basic\Client (Coomont client demo)
Demo\Basic\SQLiteServer (serve side demo using SQLite database)
Hi Alex,
regarding your second question, there are several ways to do this.
1. Put a kbmMemtable on the service. You can populate that e.g. using the before open event. On your client you simply call the memtable (using named queries, the @NAME in SQL on client) to get that data on your client.
2. Call a custom service (the first part of Kim’s presentation) to receive a streamed dataset to your client. At your client you can then populate a kbmMemtable to present that data.
Both have the disadvantage of not automatically resolving (not 100% sure in case of option 1). But you can keep track of the changes on the client using a custom delta handler to transfer the changes back to the server.
I often use these techniques to present data in a screen or on a report that needs some work to make, e.g. a lot of calculations, or a query that would become very complex any other way.
When I need to transfer a delta back to the server to resolve, I often “abuse” the way Kim has made it. I place a normal query (often a Firedac server query) on my service, that has a sql to produce an empty result set (eg using where 1=0). It will return all the fields I need to be able to resolve to. If needed I also create the origins (needed when you use joined tables). Then I open this query on the server and resolve my delta stuff line by line to this dataset.
kbmMW also has the onInsert, onUpdate and onDelete events where you can plug in code on the server to handle code using different ways than the standard.
Hope this helps. kbmMW takes some time to learn but once you do it is very flexible and powerfull.