Reputation: 705
I've been trying to make a conditional sync with SymmetricDS. Problem is, no matter what I do it just ignores the table that is supposed to be synced conditionally and just syncs tables without conditions.
So I suppose, I use those conditions wrong. I couldn't find this material in User guide for current version, so I have the following:
insert into sym_router
(router_id,source_node_group_id,target_node_group_id,router_type,router_expression,create_time,last_update_time)
values('corp_2_one_store', 'corp', 'store', 'column','STORE_ID=:EXTERNAL_ID or OLD_STORE_ID=:EXTERNAL_ID',current_timestamp, current_timestamp);
insert into sym_trigger_router
(trigger_id,router_id,initial_load_order,initial_load_select,last_update_time,create_time)
values('item_selling_price','corp_2_one_store',100,'store_id=''$(externalId)''',current_timestamp,current_timestamp);
from samples packaged with SymmetricDS, but I changed "store" to "client" and "corp" to "server" in my own configs and it doesn't work anymore. And quite frankly, I have no idea what's going on here with STORE_ID=:EXTERNAL_ID or OLD_STORE_ID=:EXTERNAL_ID
and store_id=''$(externalId)''
and why there is two of them.
From the site I have from earlier versions this example:
insert into SYM_TRIGGER
(source_table_name, source_node_group_id, target_node_group_id, channel_id,
sync_on_insert, sync_on_update, sync_on_delete,
node_select,
initial_load_order, last_updated_by, last_updated_time, create_time)
values
('sale_transaction', 'corp', 'store', 'sale_transaction',
1, 1, 1,
'and external_id = $(curTriggerValue).store',
105, 'demo', current_timestamp, current_timestamp);
But this obviously doesn't work since half of this info is now stored in different place, but even removing colums that are not there anymore (who knows, maybe these new tables only store the same info for readability?) I can't get it to work.
Any suggestions?
Update
When I run just the training example everything works. So real question here is: what do these mean:
STORE_ID=:EXTERNAL_ID or OLD_STORE_ID=:EXTERNAL_ID
and store_id=''$(externalId)''
? And how can I change that if my nodes are called server
instead of corp
and client
instead of store
?
Update 2
According to this, my router is okay, and I have some problems with my sym_trigger_router
configuration, namely, store_id=''$(externalId)''
Upvotes: 0
Views: 926
Reputation: 705
So, I found my problem. I had a typo in my table name, so no triggers were created for it.
For those, who somehow stumble upon this question:
1) what is STORE_ID=:EXTERNAL_ID or OLD_STORE_ID=:EXTERNAL_ID
?
It's clearly written here, but in two words, STORE_ID
is a column name, OLD_
means previous value of the column and :EXTERNAL_ID
is one of SymmetricDS internal variables, along with :NODE_ID
and so on.
This string is used to determine, whether to fetch current row or not and it is a parameter of the router. (If you decide to use router of another type, beware, it has other parameters, be diligent!)
2) what is store_id=''$(externalId)''
This is described to some point here, but again, in two words: During initial load by default symmetric gathers all the data from the table (select * from ...
). This parameter is what is appended to where
clause and t
can be used to reference the table that is being synced. $(externalId)
is one of the variables, that SymmetricDS initializes during startup, there is a list of such variables somewhere in the User Guide.
Upvotes: 2