/// <summary> /// Deliver a message to the appropriate session, removing the unprocessed message /// from our map /// <param name="channelId">the channel id the message should be delivered to</param> /// <param name="msg"> the message</param> private void DeliverMessageToAMQSession(ushort channelId, UnprocessedMessage msg) { AmqChannel channel = (AmqChannel)_channelId2SessionMap[channelId]; channel.MessageReceived(msg); _channelId2UnprocessedMsgMap.Remove(channelId); }
public void MessageContentBodyReceived(ushort channelId, ContentBody contentBody) { UnprocessedMessage msg = (UnprocessedMessage)_channelId2UnprocessedMsgMap[channelId]; if (msg == null) { throw new AMQException("Error: received content body without having received a BasicDeliver frame first"); } if (msg.ContentHeader == null) { _channelId2UnprocessedMsgMap.Remove(channelId); throw new AMQException("Error: received content body without having received a ContentHeader frame first"); } try { msg.ReceiveBody(contentBody); } catch (UnexpectedBodyReceivedException e) { _channelId2UnprocessedMsgMap.Remove(channelId); throw e; } if (msg.IsAllBodyDataReceived()) { DeliverMessageToAMQSession(channelId, msg); } }
public Task SendMessageAsync(UnprocessedMessage message, CancellationToken cancellationToken = default) { return(this.SendMessageAsync(message, () => { return this.Dialog.SendMessageAsync(message, cancellationToken); })); }
public void SendMessage(UnprocessedMessage message) { this.SendMessage(message, () => { this.Dialog.SendMessage(message); }); }
public void MethodReceived(AMQStateManager stateManager, AMQMethodEvent evt) { UnprocessedMessage msg = new UnprocessedMessage(); msg.DeliverBody = (BasicDeliverBody)evt.Method; msg.ChannelId = evt.ChannelId; _logger.Debug("New JmsDeliver method received"); evt.ProtocolSession.UnprocessedMessageReceived(msg); }
public void MethodReceived(AMQStateManager stateManager, AMQMethodEvent evt) { _logger.Debug("New Basic.Return method received"); UnprocessedMessage msg = new UnprocessedMessage(); msg.DeliverBody = null; msg.BounceBody = (BasicReturnBody)evt.Method; msg.ChannelId = evt.ChannelId; evt.ProtocolSession.UnprocessedMessageReceived(msg); }
public void MessageContentHeaderReceived(ushort channelId, ContentHeaderBody contentHeader) { UnprocessedMessage msg = (UnprocessedMessage)_channelId2UnprocessedMsgMap[channelId]; if (msg == null) { throw new AMQException("Error: received content header without having received a JMSDeliver frame first"); } if (msg.ContentHeader != null) { throw new AMQException("Error: received duplicate content header or did not receive correct number of content body frames"); } msg.ContentHeader = contentHeader; if (contentHeader.BodySize == 0) { DeliverMessageToAMQSession(channelId, msg); } }
/** * Called from the AMQSession when a message has arrived for this consumer. This methods handles both the case * of a message listener or a synchronous receive() caller. * * @param messageFrame the raw unprocessed mesage * @param channelId channel on which this message was sent */ internal void NotifyMessage(UnprocessedMessage messageFrame, int channelId) { if (_logger.IsDebugEnabled) { _logger.Debug("notifyMessage called with message number " + messageFrame.DeliverBody.DeliveryTag); } try { AbstractQmsMessage jmsMessage = _messageFactory.CreateMessage((long)messageFrame.DeliverBody.DeliveryTag, messageFrame.DeliverBody.Redelivered, messageFrame.ContentHeader, messageFrame.Bodies); _logger.Debug("Message is of type: " + jmsMessage.GetType().Name); PreDeliver(jmsMessage); if (IsMessageListenerSet) { // We do not need a lock around the test above, and the dispatch below as it is invalid // for an application to alter an installed listener while the session is started. #if __MonoCS__ _messageListener(jmsMessage); #else _messageListener.Invoke(jmsMessage); #endif PostDeliver(jmsMessage); } else { _messageQueue.Enqueue(jmsMessage); } } catch (Exception e) { _logger.Error("Caught exception (dump follows) - ignoring...", e); // FIXME } }
/// <summary> /// Callback invoked from the BasicDeliverMethodHandler when a message has been received. /// This is invoked on the MINA dispatcher thread. /// </summary> /// <param name="message">the unprocessed message</param> /// <exception cname="AMQException">if this was not expected</exception> public void UnprocessedMessageReceived(UnprocessedMessage message) { _channelId2UnprocessedMsgMap[message.ChannelId] = message; }