if (address.getHost() == null)
{
throw new MessengerException("unable to send to address: " + m.getAddress());
}
int port = address.getPort() < 0 ? defaultPort(address.getScheme()) : address.getPort();
Sender sender = getLink(address.getHost(), port, new SenderFinder(cleanPath(address.getPath())));
adjustReplyTo(m);
byte[] tag = String.valueOf(_nextTag++).getBytes();
Delivery delivery = sender.delivery(tag);
int encoded;
while (true)
{
try
{
encoded = m.encode(_buffer, 0, _buffer.length);
break;
} catch (java.nio.BufferOverflowException e) {
_buffer = new byte[_buffer.length*2];
}
}
sender.send(_buffer, 0, encoded);
_outgoing.add(delivery);
sender.advance();
}
catch (URISyntaxException e)
{
throw new MessengerException("Invalid address: " + m.getAddress(), e);
}