本文整理汇总了C#中Exchange类的典型用法代码示例。如果您正苦于以下问题:C# Exchange类的具体用法?C# Exchange怎么用?C# Exchange使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
Exchange类属于命名空间,在下文中一共展示了Exchange类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: createListener
protected RabbitListener createListener(IRegistration registration, Exchange exchange)
{
// create a channel
var connection = _connFactory.ConnectTo(exchange);
// create a listener
RabbitListener listener = new RabbitListener(registration, exchange, connection);
listener.OnEnvelopeReceived += dispatcher =>
{
Log.Debug("Got an envelope from the RabbitListener: dispatching.");
// the dispatcher encapsulates the logic of giving the envelope to handlers
dispatcher.Dispatch();
};
listener.OnClose += _listeners.Remove;
//TODO: Resolve that RabbitListener does not implement OnConnectionError
//listener.OnConnectionError(new ReconnectOnConnectionErrorCallback(_channelFactory));
// store the listener
_listeners.Add(registration, listener);
// put it on another thread so as not to block this one
// don't continue on this thread until we've started listening
ManualResetEvent startEvent = new ManualResetEvent(false);
Thread listenerThread = new Thread(listener.Start);
listenerThread.Name = string.Format("{0} on {1}:{2}{3}", exchange.QueueName, exchange.HostName, exchange.Port, exchange.VirtualHost);
listenerThread.Start(startEvent);
return listener;
}
示例2: ConfigureConnectionFactory
public override void ConfigureConnectionFactory(ConnectionFactory factory, Exchange exchange)
{
base.ConfigureConnectionFactory(factory, exchange);
factory.UserName = _username;
factory.Password = _password;
}
示例3: PublishJob
protected PublishJob(IBroker broker, Exchange exchange, String routingKey)
{
Broker = broker;
_exchange = exchange;
_routingKey = routingKey;
_stopwatch = new Stopwatch();
}
示例4: ConnectTo
public IConnection ConnectTo(Exchange exchange)
{
_log.Debug("Getting connection for exchange: " + exchange.ToString());
IConnection connection = null;
// first, see if we have a cached connection
if (_connections.ContainsKey(exchange))
{
connection = _connections[exchange];
if (!connection.IsOpen)
{
_log.Info("Cached connection to RabbitMQ was closed: reconnecting");
connection = this.CreateConnection(exchange);
}
}
else
{
_log.Debug("No connection to the exchange was cached: creating");
connection = this.CreateConnection(exchange);
// add the new connection to the cache
_connections[exchange] = connection;
}
return connection;
}
示例5: ConfigureConnectionFactory
public override void ConfigureConnectionFactory(ConnectionFactory factory, Exchange exchange)
{
// try to get a certificate
X509Certificate2 cert = _certProvider.GetCertificate();
if (null != cert)
{
_log.Info("A certificate was located with subject: " + cert.Subject);
}
else
{
throw new RabbitException("Cannot connect to an exchange because no certificate was found");
}
base.ConfigureConnectionFactory(factory, exchange);
// let's set the connection factory's ssl-specific settings
// NOTE: it's absolutely required that what you set as Ssl.ServerName be
// what's on your rabbitmq server's certificate (its CN - common name)
factory.AuthMechanisms = new AuthMechanismFactory[] { new ExternalMechanismFactory() };
factory.Ssl.Certs = new X509CertificateCollection(new X509Certificate[] { cert });
factory.Ssl.ServerName = exchange.HostName;
factory.Ssl.Enabled = true;
// TLS will enable more secure cipher suites to use in the exchange, encryption, and HMAC algorithms
// used on a secure connection. Also, if the Windows OS the client runs on has the FIPS Mode security
// policy enabled (Windows STIG), this will ensure successful connections to the Message Broker.
factory.Ssl.Version = System.Security.Authentication.SslProtocols.Tls;
}
示例6: Start
/**
* The Start method is called automatically by Monobehaviors,
* essentially becoming the constructor of the class.
* <p>
* See <a href="http://docs.unity3d.com/ScriptReference/MonoBehaviour.Start.html">docs.unity3d.com</a> for more information.
*/
private void Start() {
exchange = this.transform.parent.parent.GetComponentInParent<Exchange>();
tooltip = this.transform.FindChild("Item Tooltip").gameObject;
tooltip.SetActive(false);
BuildTooltipText();
clickDelta = 0.0f;
}
示例7: BetfairClientSync
public BetfairClientSync(Exchange exchange,
string appKey,
Action preNetworkRequest = null,
WebProxy proxy = null)
{
client = new BetfairClient(exchange, appKey, preNetworkRequest, proxy);
}
示例8: testWriting
public void testWriting()
{
string path = @"C:\Users\Phil\Desktop\out.txt";
Exchange ex = new Exchange();
string response = WebInterface.queryAPI("JPM");
Utilities.arrayify("JPM", response, ex);
FileInterface.writeExchangeToFile(path, gl);
}
示例9: GetExchangeBindings
public static IEnumerable<ExchangeBindingSettings> GetExchangeBindings(this ReceiveSettings settings, string exchangeName)
{
var exchange = new Exchange(exchangeName, settings.Durable, settings.AutoDelete, settings.ExchangeType);
var binding = new ExchangeBinding(exchange);
yield return binding;
}
示例10: SendResponse
/// <inheritdoc/>
public override void SendResponse(INextLayer nextLayer, Exchange exchange, Response response)
{
// A response must have the same token as the request it belongs to. If
// the token is empty, we must use a byte array of length 0.
if (response.Token == null)
response.Token = exchange.CurrentRequest.Token;
base.SendResponse(nextLayer, exchange, response);
}
示例11: RabbitListener
public RabbitListener(IRegistration registration, Exchange exchange, IConnection connection)
{
_registration = registration;
_exchange = exchange;
_connection = connection;
_log = LogManager.GetLogger(this.GetType());
}
示例12: GetExchangeBinding
public static ExchangeBindingSettings GetExchangeBinding(this SendSettings settings, string exchangeName)
{
var exchange = new Exchange(exchangeName, settings.Durable, settings.AutoDelete);
var binding = new ExchangeBinding(exchange);
return binding;
}
示例13: GetErrorExchangeBinding
public static ExchangeBindingSettings GetErrorExchangeBinding(this SendSettings settings)
{
var exchange = new Exchange(settings.ExchangeName, true, false);
var binding = new ExchangeBinding(exchange);
return binding;
}
示例14: StartDataGeneration
public void StartDataGeneration(int refreshInterval, Exchange exchange)
{
_refreshInterval = refreshInterval;
this._exchange = exchange;
//Start data fetch in another thread
Task tskPollData = new Task(new Action(UpdateData));
tskPollData.Start();
}
示例15: DeliverResponse
/// <inheritdoc/>
public void DeliverResponse(Exchange exchange, Response response)
{
if (exchange == null)
throw ThrowHelper.ArgumentNull("exchange");
if (response == null)
throw ThrowHelper.ArgumentNull("response");
if (exchange.Request == null)
throw new ArgumentException("Request should not be empty.", "exchange");
exchange.Request.Response = response;
}