Implement sync api.

Fix loops. Only publish in-channel once and fix exchanges.