本文整理汇总了C#中ISession.CreateTemporaryQueue方法的典型用法代码示例。如果您正苦于以下问题:C# ISession.CreateTemporaryQueue方法的具体用法?C# ISession.CreateTemporaryQueue怎么用?C# ISession.CreateTemporaryQueue使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ISession
的用法示例。
在下文中一共展示了ISession.CreateTemporaryQueue方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ClientResultStream
public ClientResultStream(OpenGammaFudgeContext fudgeContext, MQTemplate mqTemplate, bool checkSeqNumber)
{
_mqTemplate = mqTemplate;
_fudgeMessageDecoder = new FudgeMessageDecoder(fudgeContext, checkSeqNumber);
_connection = _mqTemplate.CreateConnection();
_session = _connection.CreateSession();
_destination = _session.CreateTemporaryQueue();
_consumer = _session.CreateConsumer(_destination);
_consumer.Listener += RawMessageReceived;
_connection.Start();
}
示例2: TestQueueRollbackConsumerListener
public void TestQueueRollbackConsumerListener()
{
connection.Start();
this.session = connection.CreateSession(AcknowledgementMode.Transactional);
ITemporaryQueue queue = session.CreateTemporaryQueue();
IMessageProducer producer = session.CreateProducer(queue);
IMessage message = session.CreateTextMessage("Test Message");
producer.Send(message);
session.Commit();
IMessageConsumer consumer = session.CreateConsumer(queue);
consumer.Listener += new MessageListener(OnMessageListener);
Thread.Sleep(500);
// first try.. should get 2 since there is no delay on the
// first redeliver..
Assert.AreEqual(2, counter);
Thread.Sleep(1000);
// 2nd redeliver (redelivery after 1 sec)
Assert.AreEqual(3, counter);
Thread.Sleep(2000);
// 3rd redeliver (redelivery after 2 seconds) - it should give up after
// that
Assert.AreEqual(4, counter);
// create new message
producer.Send(session.CreateTextMessage("Test Message Again"));
session.Commit();
Thread.Sleep(500);
// it should be committed, so no redelivery
Assert.AreEqual(5, counter);
Thread.Sleep(1500);
// no redelivery, counter should still be 5
Assert.AreEqual(5, counter);
session.Close();
}
示例3: GetReplyDestination
private IDestination GetReplyDestination(ISession session)
{
if (replyDestination != null)
{
return replyDestination;
}
if (replyDestinationName != null)
{
AssertUtils.ArgumentNotNull(this.destinationResolver,
"DestinationResolver is required when relying upon the 'replyDestinationName' property.");
return destinationResolver.ResolveDestinationName(
session, replyDestinationName, pubSubDomain);
}
return session.CreateTemporaryQueue();
}
示例4: 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);
}
}
示例5: 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;
}