本文整理汇总了C#中ISession.GetDestination方法的典型用法代码示例。如果您正苦于以下问题:C# ISession.GetDestination方法的具体用法?C# ISession.GetDestination怎么用?C# ISession.GetDestination使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ISession
的用法示例。
在下文中一共展示了ISession.GetDestination方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: OpenWireConsumer
/// <summary>
/// 消息消费构造器
/// </summary>
/// <param name="brokerUri">地址</param>
/// <param name="username">用户名</param>
/// <param name="psw">密码</param>
/// <param name="clientId">客户端标识 兼做队列接收目的地</param>
/// <param name="isClient">true 客户端;false 服务端</param>
public OpenWireConsumer(string brokerUri, string username, string psw, string clientId,bool isClient)
{
NMSConnectionFactory _factory = new NMSConnectionFactory(brokerUri, clientId);
_connection = _factory.CreateConnection(username, psw);
_connection.Start();
_session = _connection.CreateSession(AcknowledgementMode.AutoAcknowledge);
if (isClient)
{
_qReceiveDest = _session.GetDestination(clientId, DestinationType.TemporaryQueue);
}
else
{
_qReceiveDest = _session.GetQueue(clientId);
}
_messageConsumer = _session.CreateConsumer(_qReceiveDest);
_messageConsumer.Listener += (message) =>
{
if (Listener != null)
{
Listener(message);
}
};
}
示例2: Queue
public Queue(MsgDeliveryMode mode = MsgDeliveryMode.NonPersistent)
{
Uri msgQueue = new Uri("activemq:tcp://localhost:61616");
_factory = new ConnectionFactory(msgQueue);
try
{
_connection = _factory.CreateConnection();
}
catch (NMSConnectionException ex)
{
Log.FatalException("Error connecting to MQ server", ex);
throw;
}
// TODO check _connection for null
_connection.RequestTimeout = TimeSpan.FromSeconds(60);
Session = _connection.CreateSession();
// TODO need to find out if queue exists.
// It creates a new queue if it doesn't exist.
_destination = Session.GetDestination("queue://TwitterSearchStream");
_consumer = Session.CreateConsumer(_destination);
_producer = Session.CreateProducer(_destination);
_producer.RequestTimeout = TimeSpan.FromSeconds(60);
_producer.DeliveryMode = mode;
_connection.Start();
_connection.ExceptionListener += _connection_ExceptionListener;
_connection.ConnectionInterruptedListener += _connection_ConnectionInterruptedListener;
}
示例3: Configure
private void Configure(string destination)
{
Destination dest = new Destination(destination);
Uri connectionUri = new Uri(dest.Host);
_factory = new NMSConnectionFactory(connectionUri);
_connection = _factory.CreateConnection();
_session = _connection.CreateSession();
_connection.Start();
_destination = _session.GetDestination(dest.Queue);
}
示例4: Configure
/// <summary>
/// Configurate the Connection
/// </summary>
/// <param name="destination">Destionation</param>
private void Configure(string destination)
{
Destination dest = new Destination(destination);
Uri connectionUri = new Uri(dest.Host);
factory = new Apache.NMS.ActiveMQ.ConnectionFactory(connectionUri);
connection = factory.CreateConnection();
session = connection.CreateSession();
connection.Start();
this.destination = session.GetDestination(dest.Queue);
}
示例5: Search
public Search(IEnumerable<string> searchFilter)
{
// TODO app setting
Uri msgQueue = new Uri("activemq:tcp://localhost:61616");
_factory = new ConnectionFactory(msgQueue);
try
{
_connection = _factory.CreateConnection();
}
catch (NMSConnectionException ex)
{
Log.FatalException("Error connecting to MQ server", ex);
throw;
}
// TODO handle -- throws connectionclosedexception
_session = _connection.CreateSession();
// TODO app setting
_destination = _session.GetDestination("queue://TwitterSearchStream");
_producer = _session.CreateProducer(_destination);
_connection.Start();
_producer.DeliveryMode = MsgDeliveryMode.NonPersistent;
_producer.RequestTimeout = TimeSpan.FromSeconds(60);
// TODO app setting -- Put your username/password here
searchStream = new SearchStream(uri, "username", "password");
searchStream.StatusReceived += new EventHandler<StreamEvent>(searchStream_StatusReceived);
var searchTerms = new Dictionary<string, string>();
searchTerms.Add("track", string.Join(",", searchFilter.Select(HttpUtility.UrlEncode)));
searchStream.StartStream(searchTerms);
while (true)
{
Thread.Sleep(1000);
}
}
示例6: Configure
/// <summary>
/// Configurate the Connection
/// </summary>
/// <param name="destination">Destionation</param>
protected void Configure()
{
if (close) return;
if (nbrretry++ >= maxretries)
handling = EExceptionHandling.ForwardException;
try
{
Destination dest = new Destination(string_destination);
Uri connectionUri = new Uri(dest.Host);
factory = new Apache.NMS.ActiveMQ.ConnectionFactory(connectionUri);
connection = factory.CreateConnection();
session = connection.CreateSession();
connection.Start();
this.destination = session.GetDestination(dest.Queue);
nbrretry = 0;
}
catch
{
switch (handling)
{
case EExceptionHandling.ForwardException:
{
throw;
}
case EExceptionHandling.Retry:
{
Configure();
break;
}
}
}
}