本文整理汇总了C#中ISession.GetQueue方法的典型用法代码示例。如果您正苦于以下问题:C# ISession.GetQueue方法的具体用法?C# ISession.GetQueue怎么用?C# ISession.GetQueue使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ISession
的用法示例。
在下文中一共展示了ISession.GetQueue方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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: Client
public Client()
{
InitializeComponent();
listBox2.DataSource = publisher;
//客户端
String brokerUri2 = "stomp:tcp://" + host + ":" + port;
factory2 = new NMSConnectionFactory(brokerUri2);
connection2 = factory2.CreateConnection(user, password);
connection2.Start();
session2 = connection2.CreateSession(AcknowledgementMode.AutoAcknowledge);
dest2 = session2.GetQueue(se_destination);
producer = session2.CreateProducer(dest2);
consumer = session2.CreateConsumer(session2.GetQueue(re_destination));
consumer.Listener += (lllll) =>
{
publisher.Add(String.Format("Receive {0} CorrelationId {1}", listenercount++, lllll.NMSCorrelationID));
};
publisher.Add("Starting up Publisher.");
publisher.Add("Sending messages...");
t2 = new Thread(new ThreadStart(StartPublisher));
}
示例3: Stomp
public Stomp(bool durable)
{
_connectionFactory = new ConnectionFactory("tcp://localhost:61613");
_connection = _connectionFactory.CreateConnection();
_connection.ClientId = "13AC0CF8-65FE-4638-8B85-62210DD89BEE";
_connection.Start();
_session = _connection.CreateSession();
var topic = _session.GetQueue("exampleQueue");
_producer = _session.CreateProducer(topic);
_producer.DeliveryMode = durable ? MsgDeliveryMode.Persistent : MsgDeliveryMode.NonPersistent;
_consumer = _session.CreateConsumer(topic);
}
示例4: run
public void run()
{
log("started");
IConnectionFactory factory = new ConnectionFactory();
connection = factory.CreateConnection();
connection.Start();
session = connection.CreateSession();
qtt_fills = session.GetQueue("TT_Fills");
qtt_quotes = session.GetQueue("TT_Quotes");
//System.Timers.Timer exportDepth = new System.Timers.Timer();
//exportDepth.Interval = 10000;
//exportDepth.Elapsed += new System.Timers.ElapsedEventHandler(ExportDepths);
//exportDepth.Enabled = true;
//exportDepth.Start();
configure();
while(true) {
Thread.Sleep(200);
}
}
示例5: Server
public Server()
{
InitializeComponent();
listBox1.DataSource = listener;
//服务端
String brokerUri = "stomp:tcp://" + host + ":" + port + "?transport.useLogging=true";
factory = new NMSConnectionFactory(brokerUri);
connection = factory.CreateConnection(user, password);
connection.Start();
session = connection.CreateSession(AcknowledgementMode.AutoAcknowledge);
consumer = session.CreateConsumer(session.GetQueue(re_destination));
producer = session.CreateProducer();
listener.Add("Starting up Listener.");
listener.Add("Waiting for messages...");
t1 = new Thread(new ThreadStart(StartListener));
}
示例6: ResolveQueue
/// <summary> Resolve the given destination name to a Queue.</summary>
/// <param name="session">the current NMS Session
/// </param>
/// <param name="queueName">the name of the desired Queue.
/// </param>
/// <returns> the NMS Queue name
/// </returns>
/// <throws>NMSException if resolution failed </throws>
protected internal virtual IDestination ResolveQueue(ISession session, string queueName)
{
return session.GetQueue(queueName);
}
示例7: CreateDestination
public IDestination CreateDestination(ISession session, DestinationType type, string name)
{
if(name == "")
{
name = "TEST." + this.GetType().Name + "." + Guid.NewGuid();
}
switch(type)
{
case DestinationType.Queue:
return session.GetQueue(name);
case DestinationType.Topic:
return session.GetTopic(name);
case DestinationType.TemporaryQueue:
return session.CreateTemporaryQueue();
case DestinationType.TemporaryTopic:
return session.CreateTemporaryTopic();
default:
throw new ArgumentException("type: " + type);
}
}
示例8: GetDestination
/// <summary>
/// Get the destination by parsing the embedded type prefix.
/// </summary>
/// <param name="session">Session object to use to get the destination.</param>
/// <param name="destinationName">Name of destination with embedded prefix. The embedded prefix can be one of the following:
/// <list type="bullet">
/// <item>queue://</item>
/// <item>topic://</item>
/// <item>temp-queue://</item>
/// <item>temp-topic://</item>
/// </list>
/// </param>
/// <param name="defaultType">Default type if no embedded prefix is specified.</param>
/// <returns></returns>
public static IDestination GetDestination(ISession session, string destinationName, DestinationType defaultType)
{
IDestination destination = null;
DestinationType destinationType = defaultType;
if(null != destinationName)
{
if(destinationName.Length > QueuePrefix.Length
&& 0 == String.Compare(destinationName.Substring(0, QueuePrefix.Length), QueuePrefix, false))
{
destinationType = DestinationType.Queue;
destinationName = destinationName.Substring(QueuePrefix.Length);
}
else if(destinationName.Length > TopicPrefix.Length
&& 0 == String.Compare(destinationName.Substring(0, TopicPrefix.Length), TopicPrefix, false))
{
destinationType = DestinationType.Topic;
destinationName = destinationName.Substring(TopicPrefix.Length);
}
else if(destinationName.Length > TempQueuePrefix.Length
&& 0 == String.Compare(destinationName.Substring(0, TempQueuePrefix.Length), TempQueuePrefix, false))
{
destinationType = DestinationType.TemporaryQueue;
destinationName = destinationName.Substring(TempQueuePrefix.Length);
}
else if(destinationName.Length > TempTopicPrefix.Length
&& 0 == String.Compare(destinationName.Substring(0, TempTopicPrefix.Length), TempTopicPrefix, false))
{
destinationType = DestinationType.TemporaryTopic;
destinationName = destinationName.Substring(TempTopicPrefix.Length);
}
}
switch(destinationType)
{
case DestinationType.Queue:
if(null != destinationName)
{
destination = session.GetQueue(destinationName);
}
break;
case DestinationType.Topic:
if(null != destinationName)
{
destination = session.GetTopic(destinationName);
}
break;
case DestinationType.TemporaryQueue:
destination = session.CreateTemporaryQueue();
break;
case DestinationType.TemporaryTopic:
destination = session.CreateTemporaryTopic();
break;
}
return destination;
}
示例9: OpenWireProducer
/// <summary>
/// 消息发送
/// </summary>
/// <param name="brokerUri">Apollo地址</param>
/// <param name="username">用户名</param>
/// <param name="psw">密码</param>
/// <param name="qsenddest">队列发送目的地</param>
/// <param name="isClient">true 客户端;false 服务端</param>
public OpenWireProducer(string brokerUri,string username,string psw,string qsenddest,bool isClient)
{
NMSConnectionFactory _factory = new NMSConnectionFactory(brokerUri);
_connection = _factory.CreateConnection(username, psw);
_connection.Start();
_session = _connection.CreateSession(AcknowledgementMode.AutoAcknowledge);
if (isClient)
{
_qSendDest = _session.GetQueue(qsenddest);
_messageProducer = _session.CreateProducer(_qSendDest);
}
else
{
//服务端不需要发送地址
_messageProducer = _session.CreateProducer();
}
_messageProducer.DeliveryMode = MsgDeliveryMode.NonPersistent;//非持久化
}