public void CanCreateMessage() { IChannel channel = AmqChannel.CreateDisconnectedChannel(); IMessage msg = channel.CreateMessage(); Assert.IsNotNull(msg); }
/// <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 BasicMessageProducer(string exchangeName, string routingKey, bool transacted, ushort channelId, AmqChannel channel, long producerId, DeliveryMode deliveryMode, long timeToLive, bool immediate, bool mandatory, int priority) { _exchangeName = exchangeName; _routingKey = routingKey; _transacted = transacted; _channelId = channelId; _channel = channel; _producerId = producerId; _deliveryMode = deliveryMode; _timeToLive = timeToLive; _immediate = immediate; _mandatory = mandatory; _messagePriority = priority; _channel.RegisterProducer(producerId, this); }
public void CanCreateMessageFromMimeType() { IChannel channel = AmqChannel.CreateDisconnectedChannel(); IMessage msg = channel.CreateMessage("text/xml"); Assert.IsNotNull(msg); Assert.IsInstanceOfType(typeof(ITextMessage), msg); }
public void CanCreateTextMessageWithContent() { IChannel channel = AmqChannel.CreateDisconnectedChannel(); const string CONTENT = "1234567890"; ITextMessage msg = channel.CreateTextMessage(CONTENT); Assert.IsNotNull(msg); Assert.AreEqual(CONTENT, msg.Text); }
public void AddSessionByChannel(ushort channelId, AmqChannel channel) { if (channel == null) { throw new ArgumentNullException("Attempt to register a null channel"); } _logger.Debug("Add channel with channel id " + channelId); _channelId2SessionMap[channelId] = channel; }
/// <summary> /// Starts the process of closing a channel /// </summary> /// <param name="channel" the AmqChannel being closed</param> public void CloseSession(AmqChannel channel) { _logger.Debug("closeSession called on protocol channel for channel " + channel.ChannelId); ushort channelId = channel.ChannelId; // we need to know when a channel is closing so that we can respond // with a channel.close frame when we receive any other type of frame // on that channel _closingChannels[channelId] = channel; }
public void Stop() { CheckNotClosed(); if (_started) { foreach (DictionaryEntry lde in _sessions) { AmqChannel s = (AmqChannel)lde.Value; s.Stop(); } _started = false; } }
public void CloseSession(AmqChannel channel) { // FIXME: Don't we need FailoverSupport here (as we have SyncWrite). _protocolSession.CloseSession(channel); AMQFrame frame = ChannelCloseBody.CreateAMQFrame( channel.ChannelId, 200, "JMS client closing channel", 0, 0); _log.Debug("Blocking for channel close frame for channel " + channel.ChannelId); _protocolWriter.SyncWrite(frame, typeof(ChannelCloseOkBody)); _log.Debug("Received channel close frame"); // When control resumes at this point, a reply will have been received that // indicates the broker has closed the channel successfully }
/// <summary> /// Called from the ChannelClose handler when a channel close frame is received. /// This method decides whether this is a response or an initiation. The latter /// case causes the AmqChannel to be closed and an exception to be thrown if /// appropriate. /// </summary> /// <param name="channelId">the id of the channel (session)</param> /// <returns>true if the client must respond to the server, i.e. if the server /// initiated the channel close, false if the channel close is just the server /// responding to the client's earlier request to close the channel.</returns> public bool ChannelClosed(ushort channelId, int code, string text) { // if this is not a response to an earlier request to close the channel if (!_closingChannels.ContainsKey(channelId)) { _closingChannels.Remove(channelId); AmqChannel channel = (AmqChannel)_channelId2SessionMap[channelId]; channel.ClosedWithException(new AMQException(_logger, code, text)); return(true); } else { return(false); } }
protected override object operation() { ushort channelId = _connection.NextChannelId(); if (_log.IsDebugEnabled) { _log.Debug("Write channel open frame for channel id " + channelId); } // We must create the channel and register it before actually sending the frame to the server to // open it, so that there is no window where we could receive data on the channel and not be set // up to handle it appropriately. AmqChannel channel = new AmqChannel(_connection, channelId, _transacted, _acknowledgeMode, _prefetchHigh, _prefetchLow); _connection.ProtocolSession.AddSessionByChannel(channelId, channel); _connection.RegisterSession(channelId, channel); bool success = false; try { _connection.CreateChannelOverWire(channelId, _prefetchHigh, _prefetchLow, _transacted); success = true; } catch (AMQException e) { throw new QpidException("Error creating channel: " + e, e); } finally { if (!success) { _connection.ProtocolSession.RemoveSessionByChannel(channelId); _connection.DeregisterSession(channelId); } } if (_connection._started) { channel.Start(); } return(channel); }
internal BasicMessageConsumer(ushort channelId, string queueName, bool noLocal, MessageFactoryRegistry messageFactory, AmqChannel channel, int prefetchHigh, int prefetchLow, bool exclusive, bool browse) { _channelId = channelId; _queueName = queueName; _noLocal = noLocal; _messageFactory = messageFactory; _channel = channel; _acknowledgeMode = _channel.AcknowledgeMode; _prefetchHigh = prefetchHigh; _prefetchLow = prefetchLow; _exclusive = exclusive; _browse = browse; if (_acknowledgeMode == AcknowledgeMode.SessionTransacted) { _receivedDeliveryTags = new LinkedList <long>(); } }
internal void RegisterSession(int channelId, AmqChannel channel) { _sessions[channelId] = channel; }