0

我目前正在尝试在我的 Cypher 请求的标头中添加一个字段,以告诉负载均衡器它是写入请求还是读取请求,以便将查询定向到 Master 或 Slave Neo4j 实例。

HttpClientWrapper clientWrapper = new HttpClientWrapper(ConfigurationManager.AppSettings["Neo4jUserName"], ConfigurationManager.AppSettings["Neo4jPassword"]);

Uri uri = new Uri(ConfigurationManager.AppSettings["Neo4jClient"]);
GraphClient client = new GraphClient(uri, clientWrapper);
client.JsonConverters.Add(new CoordinateConverter());
client.Connect();
...        
NameValueCollection collection = new NameValueCollection();
collection.Add("X:Write", "1");
...
client.Cypher.CustomHeader(collection)...

但是在执行查询时,我得到了异常,例如:

System.FormatException:“标头名称格式无效。”

我的问题是, .CustomHeader(collection) 是否覆盖标准 Header 而不是仅添加字段 X:Write ?我正在努力寻找有关 CustomHeader 的文档以及它应该如何工作。

提前感谢您阅读我。

编辑:这是我找到的一些代码示例,应该可以工作:https ://github.com/Readify/Neo4jClient/pull/149/files

4

1 回答 1

0

错误是我无法在标题名称中使用':',将名称更改为“IsWrite”解决了问题。

于 2016-03-29T07:44:52.907 回答