Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Code Block
java.naming.factory.initial = org.apache.camel.util.jndi.CamelInitialContextFactory

Dynamically assigning ports

Available as of Camel 2.7

Tests that use port numbers will fail if that port is already on use. AvailablePortFinder provides methods for finding unused port numbers at runtime.

Code Block

// Get the next available port number starting from the default starting port of 1024
int port1 = AvailablePortFinder.getNextAvailable();
/* Get another port. Note that just getting a port number does not reserver it so
 * we look starting one past the last port number we got.
 */
int port2 = AvailablePortFinder.getNextAvailable(port1 + 1);

See Also