经过多次尝试,组合 xa-datasource <-> postgres 驱动程序似乎不支持具有非默认端口(5432)的故障转移配置。我猜,驱动程序并没有实现 xa 期望的所有方法。
如果有人能告诉我我错了,我会很高兴...
此示例有效,但使用默认端口:
<xa-datasource jndi-name="java:/Foo" pool-name="Foo" enabled="true" use-ccm="true" statistics-enabled="true">
<xa-datasource-property name="url">
jdbc:postgresql://server1,server2/db_name
</xa-datasource-property>
<xa-datasource-property name="ApplicationName">
MyApp
</xa-datasource-property>
<xa-datasource-class>org.postgresql.xa.PGXADataSource</xa-datasource-class>
<driver>postgresql-jdbc4</driver>
<url-delimiter>,</url-delimiter>
<xa-pool>
<min-pool-size>6</min-pool-size>
<max-pool-size>40</max-pool-size>
<prefill>true</prefill>
<is-same-rm-override>false</is-same-rm-override>
<interleaving>false</interleaving>
<pad-xid>false</pad-xid>
<wrap-xa-resource>false</wrap-xa-resource>
</xa-pool>
<security>
<user-name>foo</user-name>
<password>blah</password>
</security>
<validation>
<validate-on-match>false</validate-on-match>
<background-validation>false</background-validation>
</validation>
<timeout>
<blocking-timeout-millis>3000</blocking-timeout-millis>
<idle-timeout-minutes>60</idle-timeout-minutes>
</timeout>
<statement>
<share-prepared-statements>false</share-prepared-statements>
</statement>
</xa-datasource>