<bean name="myConnectionPool" class="org.jboss.remoting3.pool.BasicConnectionPool" scope="singleton"> <constructor> <parameter> <bean class="org.jboss.remoting3.pool.BasicConnectionPool$Builder"> <set name="endpoints"> <list> <value>remote://localhost:8080</value> <value>remote://127.0.0.1:8080</value> </list> </set> <property name="maxConnections" value="10"/> <property name="maxPending" value="50"/> </bean> </parameter> </constructor> </bean> import org.jboss.remoting3.Connection; import org.jboss.remoting3.Endpoint; import org.jboss.remoting3.Remoting; import org.jboss.remoting3.spi.ConnectionProvider; import java.io.IOException; import java.util.concurrent.TimeUnit; public class ConnectionPoolExample { public static void main(String[] args) throws IOException, InterruptedException { Endpoint endpoint = Remoting.createEndpoint("myEndpoint"); ConnectionProvider connectionProvider = endpoint.getConnectionProvider(); Connection connection = connectionProvider.getConnection("remote://localhost:8080", 5000, TimeUnit.MILLISECONDS); connection.close(); endpoint.close(); } }


上一篇:
下一篇:
切换中文