0

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)''

SMSk
  • 693
  • 8
  • 25
  • What's the version of symmetricDs that you're using? – Boris Pavlović Sep 02 '15 at 12:29
  • @BorisPavlović the latest, 3.7.19 – SMSk Sep 02 '15 at 12:30
  • The router seems fine, could you see if after inserting/updating a row in the db that is routed by this router there's a new row in `sym_outgoing_batch` table? This table can be joined with `sym_data_event` and `sym_data` to see which data belongs to a routed outgoing batch. – Boris Pavlović Sep 02 '15 at 12:36
  • In `sym_data_event` I have two rows for common router and none for router, that is supposed to split data between different clients. So I suppose it means that my data is not routed – SMSk Sep 02 '15 at 12:45
  • Yes, data hasn't been routed. Next suggestion is to enable logging of symmetricDs's sql statements and see if the router is really used. – Boris Pavlović Sep 02 '15 at 12:51
  • @BorisPavlović but if that helps, I have three data_events, that have `?` as router and they were in `outgoing_batches` to my client node (I just left one for testing purpuses) in `reload` channel – SMSk Sep 02 '15 at 12:51
  • Sorry, but can't understand the last comment. – Boris Pavlović Sep 02 '15 at 12:54
  • @BorisPavlović here is the extract from `select * from sym_data_event`: http://tinypic.com/r/jl5u36/8 – SMSk Sep 02 '15 at 12:58
  • getting it now, understand – Boris Pavlović Sep 02 '15 at 13:05
  • @BorisPavlović I've got nothing, man :-( – SMSk Sep 03 '15 at 12:26

1 Answers1

2

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.

SMSk
  • 693
  • 8
  • 25