mirror of https://github.com/apache/activemq.git
disabled logging by default but allow it to be specified via a URI query argument of tcp://localhost:port?logging=true
git-svn-id: https://svn.apache.org/repos/asf/incubator/activemq/trunk@428225 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
98f3545303
commit
0462d1d3d0
|
@ -20,43 +20,48 @@ using System.Net;
|
||||||
using System.Net.Sockets;
|
using System.Net.Sockets;
|
||||||
using ActiveMQ.Transport;
|
using ActiveMQ.Transport;
|
||||||
|
|
||||||
namespace ActiveMQ.Transport.Tcp
|
namespace ActiveMQ.Transport.Tcp {
|
||||||
{
|
public class TcpTransportFactory : ITransportFactory {
|
||||||
public class TcpTransportFactory : ITransportFactory
|
private bool useLogging = false;
|
||||||
{
|
|
||||||
|
public bool UseLogging {
|
||||||
|
get { return useLogging; }
|
||||||
|
set { useLogging = value; }
|
||||||
|
}
|
||||||
|
|
||||||
public ITransport CreateTransport(Uri location) {
|
public ITransport CreateTransport(Uri location) {
|
||||||
|
|
||||||
// Console.WriteLine("Opening socket to: " + host + " on port: " + port);
|
// Console.WriteLine("Opening socket to: " + host + " on port: " + port);
|
||||||
Socket socket = Connect(location.Host, location.Port);
|
Socket socket = Connect(location.Host, location.Port);
|
||||||
ITransport rc = new TcpTransport(socket);
|
ITransport rc = new TcpTransport(socket);
|
||||||
// TODO: use URI query string to enable the LoggingTransport
|
|
||||||
|
// TODO use URI query string to configure properties on this object
|
||||||
|
|
||||||
|
// TODO - dirty hack - replace with better URI query parsing later
|
||||||
|
if (location.Query.IndexOf("logging=true") >= 0) {
|
||||||
|
UseLogging = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (UseLogging) {
|
||||||
rc = new LoggingTransport(rc);
|
rc = new LoggingTransport(rc);
|
||||||
|
}
|
||||||
rc = new ResponseCorrelator(rc);
|
rc = new ResponseCorrelator(rc);
|
||||||
rc = new MutexTransport(rc);
|
rc = new MutexTransport(rc);
|
||||||
return rc;
|
return rc;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
protected Socket Connect(string host, int port)
|
protected Socket Connect(string host, int port) {
|
||||||
{
|
|
||||||
// Looping through the AddressList allows different type of connections to be tried
|
// Looping through the AddressList allows different type of connections to be tried
|
||||||
// (IPv4, IPv6 and whatever else may be available).
|
// (IPv4, IPv6 and whatever else may be available).
|
||||||
IPHostEntry hostEntry = Dns.Resolve(host);
|
IPHostEntry hostEntry = Dns.Resolve(host);
|
||||||
foreach (IPAddress address in hostEntry.AddressList)
|
foreach (IPAddress address in hostEntry.AddressList) {
|
||||||
{
|
Socket socket = new Socket(address.AddressFamily, SocketType.Stream, ProtocolType.Tcp);
|
||||||
Socket socket = new Socket(
|
|
||||||
address.AddressFamily,
|
|
||||||
SocketType.Stream,
|
|
||||||
ProtocolType.Tcp);
|
|
||||||
socket.Connect(new IPEndPoint(address, port));
|
socket.Connect(new IPEndPoint(address, port));
|
||||||
if (socket.Connected)
|
if (socket.Connected) {
|
||||||
{
|
|
||||||
return socket;
|
return socket;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
throw new SocketException();
|
throw new SocketException();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue