本文整理汇总了C#中IMessageConsumer类的典型用法代码示例。如果您正苦于以下问题:C# IMessageConsumer类的具体用法?C# IMessageConsumer怎么用?C# IMessageConsumer使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
IMessageConsumer类属于命名空间,在下文中一共展示了IMessageConsumer类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: AddMessageConsumer
/// <summary>
/// Add a message consumer to monitor for messages received
/// </summary>
public void AddMessageConsumer(IMessageConsumer consumer)
{
consumer.Listener += (m) =>
{
_lastMsgRecd = DateTime.UtcNow;
};
}
示例2: MessageHandler
public MessageHandler(IMessageConsumer consumer, MessagingClient.EventDelegate callback)
{
this.consumer = consumer;
this.callback = callback;
AddListener();
}
示例3: Subscribe
public void Subscribe(IMessageConsumer consumer)
{
if (_consumers.Contains(consumer))
{
return;
}
_consumers.Add(consumer);
}
示例4: NMSConsumer
public NMSConsumer(IMessageConsumer consumer, String clientId, String subscriptionId)
{
this.consumer = consumer;
this.clientId = clientId;
this.subscriptionId = subscriptionId;
consumer.Listener += onMessage;
}
示例5: Unsubscribe
public void Unsubscribe(IMessageConsumer consumer)
{
if (!_consumers.Contains(consumer))
{
return;
}
_consumers.Remove(consumer);
}
示例6: Consumer
public Consumer(IMessageConsumer messageConsumer, string clientId, string topicName)
{
_consumer = messageConsumer;
_clientId = clientId;
_topicName = topicName;
_consumer.Listener += Update;
_running = true;
Delays = new List<TimeSpan>();
}
示例7: RegisterImpl
public void RegisterImpl(IMessageConsumer impl, string serviceId)
{
var rule = MetaData.GetServiceRoutingRule(serviceId);
if (rule == null)
{
throw new Exception();
}
implements[rule.GateRule.GetServiceId()] = impl;
}
示例8: RegisterDelegate
public void RegisterDelegate(IMessageConsumer consumer, string serviceId)
{
var rule = MetaData.GetServiceRoutingRule(serviceId);
if (rule == null)
{
throw new Exception();
}
delegates[rule.GateRule.GetServiceId()] = consumer;
}
示例9: FudgeDecodeMessage
public IMessage FudgeDecodeMessage(ISession session, IMessageConsumer consumer, IMessage message)
{
try
{
return new ActiveMQObjectMessage { Body = DecodeObject(GetMessage(message)) };
}
catch (Exception e)
{
return new ActiveMQObjectMessage { Body = e };
}
}
示例10: DistributableCommandBus
public DistributableCommandBus(ICommandHandlerProvider handlerProvider,
ILinearCommandManager linearCommandManager,
IMessageConsumer commandConsumer,
string receiveEndPoint,
bool inProc)
: base(handlerProvider, linearCommandManager, receiveEndPoint, inProc)
{
_commandConsumer = commandConsumer as IInProcMessageConsumer;
_commandDistributor = _commandConsumer;
_isDistributor = _commandDistributor is IMessageDistributor;
}
示例11: btnSubscribe_Click
private void btnSubscribe_Click(object sender, EventArgs e)
{
try
{
if (!GlobalFunction.CheckControlInput(txtTopicName, "Topic Name", 0, false)) return;
if (m_consumer != null)
{
m_consumer.Close();
}
if (txtSelector.Text != "")
{
m_consumer = m_mq.CreateConsumer(rdTopic.Checked, txtTopicName.Text, txtSelector.Text);
}
else
{
m_consumer = m_mq.CreateConsumer(rdTopic.Checked, txtTopicName.Text);
}
m_consumer.Listener += new MessageListener(consumer_listener);
}
catch (System.Exception ex)
{
GlobalFunction.MsgBoxException(ex.Message, "btnSubscribe_Click");
}
}
示例12: 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);
}
};
}
示例13: Dispose
public void Dispose()
{
lock (this)
{
this.isDisposed = true;
this.consumer.Dispose();
this.consumer = null;
if (this.replyProducer != null)
{
this.replyProducer.Dispose();
this.replyProducer = null;
}
this.requestReplyCallback = null;
this.session.Dispose();
this.session = null;
this.connection.ConnectionInterrupted -= new EventHandler<NmsConnectionEventArgs>(connection_ConnectionInterrupted);
this.connection.ConnectionResumed -= new EventHandler<NmsConnectionEventArgs>(connection_ConnectionResumed);
this.connection = null;
}
}
示例14: 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;
}
示例15: SetUp
override public void SetUp()
{
base.SetUp();
acknowledgementMode = AcknowledgementMode.Transactional;
Drain();
consumer = Session.CreateConsumer(Destination);
producer = Session.CreateProducer(Destination);
}