public MessageProducer(Session session, ProducerId id, ActiveMQDestination destination, TimeSpan requestTimeout) { this.session = session; this.RequestTimeout = requestTimeout; this.info = new ProducerInfo(); this.info.ProducerId = id; this.info.Destination = destination; this.info.WindowSize = session.Connection.ProducerWindowSize; this.messageTransformation = session.Connection.MessageTransformation; // If the destination contained a URI query, then use it to set public // properties on the ProducerInfo if(destination != null && destination.Options != null) { URISupport.SetProperties(this.info, destination.Options, "producer."); } // Version Three and higher will send us a ProducerAck, but only if we // have a set producer window size. if(session.Connection.ProtocolVersion >= 3 && this.info.WindowSize > 0) { Tracer.Debug("MessageProducer created with a Window Size of: " + this.info.WindowSize); this.usage = new MemoryUsage(this.info.WindowSize); } }
public Connection(Uri connectionUri, ITransport transport, IdGenerator clientIdGenerator) { this.brokerUri = connectionUri; this.clientIdGenerator = clientIdGenerator; this.transport = transport; this.transport.Command = new CommandHandler(OnCommand); this.transport.Exception = new ExceptionHandler(OnTransportException); this.transport.Interrupted = new InterruptedHandler(OnTransportInterrupted); this.transport.Resumed = new ResumedHandler(OnTransportResumed); ConnectionId id = new ConnectionId(); id.Value = CONNECTION_ID_GENERATOR.GenerateId(); this.info = new ConnectionInfo(); this.info.ConnectionId = id; this.info.FaultTolerant = transport.IsFaultTolerant; this.messageTransformation = new ActiveMQMessageTransformation(this); }
// Constructor internal to prevent clients from creating an instance. internal MessageConsumer(Session session, ConsumerId id, Destination destination, string name, string selector, int prefetch, bool noLocal) { if (destination == null) { throw new InvalidDestinationException("Consumer cannot receive on Null Destinations."); } this.session = session; this.redeliveryPolicy = this.session.Connection.RedeliveryPolicy; this.messageTransformation = this.session.Connection.MessageTransformation; this.info = new ConsumerInfo(); this.info.ConsumerId = id; this.info.Destination = Destination.Transform(destination); this.info.SubscriptionName = name; this.info.Selector = selector; this.info.PrefetchSize = prefetch; this.info.MaximumPendingMessageLimit = session.Connection.PrefetchPolicy.MaximumPendingMessageLimit; this.info.NoLocal = noLocal; this.info.DispatchAsync = session.DispatchAsync; this.info.Retroactive = session.Retroactive; this.info.Exclusive = session.Exclusive; this.info.Priority = session.Priority; this.info.AckMode = session.AcknowledgementMode; // If the destination contained a URI query, then use it to set public properties // on the ConsumerInfo if (destination.Options != null) { // Get options prefixed with "consumer.*" StringDictionary options = URISupport.GetProperties(destination.Options, "consumer."); // Extract out custom extension options "consumer.nms.*" StringDictionary customConsumerOptions = URISupport.ExtractProperties(options, "nms."); URISupport.SetProperties(this.info, options); URISupport.SetProperties(this, customConsumerOptions, "nms."); } }
public Connection(Uri connectionUri, ITransport transport, IdGenerator clientIdGenerator, [NotNull] StompConnectionSettings stompConnectionSettings) { stompConnectionSettings.ThrowIfNull(nameof(stompConnectionSettings)); _stompConnectionSettings = stompConnectionSettings; _transportFactory = new TransportFactory(_stompConnectionSettings); BrokerUri = connectionUri; _clientIdGenerator = clientIdGenerator; SetTransport(transport); _info = new ConnectionInfo { ConnectionId = new ConnectionId { Value = ConnectionIdGenerator.GenerateId() }, Host = BrokerUri.Host, UserName = _stompConnectionSettings.UserName, Password = _stompConnectionSettings.Password }; MessageTransformation = new StompMessageTransformation(this); }
private void PushLocalBuffer(byte[] buffer, int offset, int count) { if ((_ReceiveOffset + count) > _ReceiveBuffer.Length) { throw new Exception("客户端信息数据超出当前接收缓存大小!"); } Array.Copy(buffer, offset, _ReceiveBuffer, _ReceiveOffset, count); _ReceiveOffset += count; Console.WriteLine("添加数据缓存 当前缓存长度:{0}", _ReceiveOffset); List <byte[]> messagebuffers = MessageCoder.MessageDecoding(ref _ReceiveBuffer, ref _ReceiveOffset); foreach (var mm in messagebuffers) { MemoryStream ms = new MemoryStream(mm, 0, mm.Length); CMD_BASE_MESSAGE mss2 = MessageTransformation.Deserialize <CMD_BASE_MESSAGE>(ms); strReceiveMessage += "|" + mss2.Message; } }
// Constructor internal to prevent clients from creating an instance. internal MessageConsumer(Session session, ConsumerId id, ActiveMQDestination destination, String name, String selector, int prefetch, int maxPendingMessageCount, bool noLocal, bool browser, bool dispatchAsync) { if (destination == null) { throw new InvalidDestinationException("Consumer cannot receive on Null Destinations."); } else if (destination.PhysicalName == null) { throw new InvalidDestinationException("The destination object was not given a physical name."); } else if (destination.IsTemporary) { String physicalName = destination.PhysicalName; if (String.IsNullOrEmpty(physicalName)) { throw new InvalidDestinationException("Physical name of Destination should be valid: " + destination); } String connectionID = session.Connection.ConnectionId.Value; if (physicalName.IndexOf(connectionID) < 0) { throw new InvalidDestinationException("Cannot use a Temporary destination from another Connection"); } if (!session.Connection.IsTempDestinationActive(destination as ActiveMQTempDestination)) { throw new InvalidDestinationException("Cannot use a Temporary destination that has been deleted"); } } this.session = session; this.redeliveryPolicy = this.session.Connection.RedeliveryPolicy; this.messageTransformation = this.session.Connection.MessageTransformation; if (session.Connection.MessagePrioritySupported) { this.unconsumedMessages = new SimplePriorityMessageDispatchChannel(); } else { this.unconsumedMessages = new FifoMessageDispatchChannel(); } this.info = new ConsumerInfo(); this.info.ConsumerId = id; this.info.Destination = destination; this.info.SubscriptionName = name; this.info.Selector = selector; this.info.PrefetchSize = prefetch; this.info.MaximumPendingMessageLimit = maxPendingMessageCount; this.info.NoLocal = noLocal; this.info.Browser = browser; this.info.DispatchAsync = dispatchAsync; this.info.Retroactive = session.Retroactive; this.info.Exclusive = session.Exclusive; this.info.Priority = session.Priority; // If the destination contained a URI query, then use it to set public properties // on the ConsumerInfo if (destination.Options != null) { // Get options prefixed with "consumer.*" StringDictionary options = URISupport.GetProperties(destination.Options, "consumer."); // Extract out custom extension options "consumer.nms.*" StringDictionary customConsumerOptions = URISupport.ExtractProperties(options, "nms."); URISupport.SetProperties(this.info, options); URISupport.SetProperties(this, customConsumerOptions, "nms."); } }
private static MessageAttachment TransformMessage(MessageAttachment attachment, SlackMessageSubject subject, MessageTransformation transformation) { var attachmentTransformer = AttachmentTransformerFactory.GetAttachmentTransformer(subject, transformation); return(attachmentTransformer.TransformAttachment(attachment)); }
// Constructor internal to prevent clients from creating an instance. internal MessageConsumer(Session session, ConsumerId id, ActiveMQDestination destination, String name, String selector, int prefetch, int maxPendingMessageCount, bool noLocal, bool browser, bool dispatchAsync ) { if(destination == null) { throw new InvalidDestinationException("Consumer cannot receive on Null Destinations."); } else if(destination.PhysicalName == null) { throw new InvalidDestinationException("The destination object was not given a physical name."); } else if (destination.IsTemporary) { String physicalName = destination.PhysicalName; if(String.IsNullOrEmpty(physicalName)) { throw new InvalidDestinationException("Physical name of Destination should be valid: " + destination); } String connectionID = session.Connection.ConnectionId.Value; if(physicalName.IndexOf(connectionID) < 0) { throw new InvalidDestinationException("Cannot use a Temporary destination from another Connection"); } if(!session.Connection.IsTempDestinationActive(destination as ActiveMQTempDestination)) { throw new InvalidDestinationException("Cannot use a Temporary destination that has been deleted"); } } this.session = session; this.redeliveryPolicy = this.session.Connection.RedeliveryPolicy; this.messageTransformation = this.session.Connection.MessageTransformation; if(session.Connection.MessagePrioritySupported) { this.unconsumedMessages = new SimplePriorityMessageDispatchChannel(); } else { this.unconsumedMessages = new FifoMessageDispatchChannel(); } this.info = new ConsumerInfo(); this.info.ConsumerId = id; this.info.Destination = destination; this.info.SubscriptionName = name; this.info.Selector = selector; this.info.PrefetchSize = prefetch; this.info.MaximumPendingMessageLimit = maxPendingMessageCount; this.info.NoLocal = noLocal; this.info.Browser = browser; this.info.DispatchAsync = dispatchAsync; this.info.Retroactive = session.Retroactive; this.info.Exclusive = session.Exclusive; this.info.Priority = session.Priority; // If the destination contained a URI query, then use it to set public properties // on the ConsumerInfo if(destination.Options != null) { // Get options prefixed with "consumer.*" StringDictionary options = URISupport.GetProperties(destination.Options, "consumer."); // Extract out custom extension options "consumer.nms.*" StringDictionary customConsumerOptions = URISupport.ExtractProperties(options, "nms."); URISupport.SetProperties(this.info, options); URISupport.SetProperties(this, customConsumerOptions, "nms."); } }
protected virtual void CopyInto(IMessageCloak msg) { MessageTransformation.CopyNMSMessageProperties(this, msg); msg.AckHandler = this.AckHandler; }
// Constructor internal to prevent clients from creating an instance. internal MessageConsumer(Session session, ConsumerId id, ActiveMQDestination destination, String name, String selector, int prefetch, int maxPendingMessageCount, bool noLocal, bool browser, bool dispatchAsync ) { if(destination == null) { throw new InvalidDestinationException("Consumer cannot receive on Null Destinations."); } this.session = session; this.redeliveryPolicy = this.session.Connection.RedeliveryPolicy; this.messageTransformation = this.session.Connection.MessageTransformation; if(session.Connection.MessagePrioritySupported) { this.unconsumedMessages = new SimplePriorityMessageDispatchChannel(); } else { this.unconsumedMessages = new FifoMessageDispatchChannel(); } this.info = new ConsumerInfo(); this.info.ConsumerId = id; this.info.Destination = destination; this.info.SubscriptionName = name; this.info.Selector = selector; this.info.PrefetchSize = prefetch; this.info.MaximumPendingMessageLimit = maxPendingMessageCount; this.info.NoLocal = noLocal; this.info.Browser = browser; this.info.DispatchAsync = dispatchAsync; this.info.Retroactive = session.Retroactive; this.info.Exclusive = session.Exclusive; this.info.Priority = session.Priority; // If the destination contained a URI query, then use it to set public properties // on the ConsumerInfo if(destination.Options != null) { // Get options prefixed with "consumer.*" StringDictionary options = URISupport.GetProperties(destination.Options, "consumer."); // Extract out custom extension options "consumer.nms.*" StringDictionary customConsumerOptions = URISupport.ExtractProperties(options, "nms."); URISupport.SetProperties(this.info, options); URISupport.SetProperties(this, customConsumerOptions, "nms."); } }
public static IAttachmentTransformer GetAttachmentTransformer(SlackMessageSubject subject, MessageTransformation transformation) { switch (subject) { case SlackMessageSubject.BuildCompleted: return(new BuildCompletedTransformer(transformation)); default: return(new MessageNoChangeTransformer()); } }
public void SetUp() { this.transformer = new ActiveMQMessageTransformation(null); }
public BuildCompletedTransformer(MessageTransformation transformation) { _transformation = transformation; }