/** * @param destination */ public static ActiveMQDestination Transform(IDestination destination) { ActiveMQDestination result = null; if (destination != null) { if (destination is ActiveMQDestination) { result = (ActiveMQDestination)destination; } else { if (destination is ITemporaryQueue) { result = new ActiveMQTempQueue(((IQueue)destination).QueueName); } else if (destination is ITemporaryTopic) { result = new ActiveMQTempTopic(((ITopic)destination).TopicName); } else if (destination is IQueue) { result = new ActiveMQQueue(((IQueue)destination).QueueName); } else if (destination is ITopic) { result = new ActiveMQTopic(((ITopic)destination).TopicName); } } } return(result); }
/** * Create a Destination * @param type * @param pyhsicalName * @return */ public static ActiveMQDestination CreateDestination(int type, String pyhsicalName) { ActiveMQDestination result = null; if (pyhsicalName == null) { return(null); } else if (type == ACTIVEMQ_TOPIC) { result = new ActiveMQTopic(pyhsicalName); } else if (type == ACTIVEMQ_TEMPORARY_TOPIC) { result = new ActiveMQTempTopic(pyhsicalName); } else if (type == ACTIVEMQ_QUEUE) { result = new ActiveMQQueue(pyhsicalName); } else { result = new ActiveMQTempQueue(pyhsicalName); } return(result); }
/// <summary> /// Create a Destination /// </summary> /// <param name="type"></param> /// <param name="pyhsicalName"></param> /// <returns></returns> public static ActiveMQDestination CreateDestination(int type, String pyhsicalName) { ActiveMQDestination result = null; if (pyhsicalName == null) { return(null); } else { switch (type) { case ACTIVEMQ_TOPIC: result = new ActiveMQTopic(pyhsicalName); break; case ACTIVEMQ_TEMPORARY_TOPIC: result = new ActiveMQTempTopic(pyhsicalName); break; case ACTIVEMQ_QUEUE: result = new ActiveMQQueue(pyhsicalName); break; default: result = new ActiveMQTempQueue(pyhsicalName); break; } } return(result); }
public TopicPublisher(string topicName, string brokerUri) { this.topicName = topicName; this.connectionFactory = new ConnectionFactory(brokerUri); this.connection = this.connectionFactory.CreateConnection(); this.connection.Start(); this.session = connection.CreateSession(); ActiveMQTopic topic = new ActiveMQTopic(topicName); this.producer = this.session.CreateProducer(topic); }
public TopicSubscriber(string topicName, string brokerUri, string clientId, string consumerId) { this.topicName = topicName; this.connectionFactory = new ConnectionFactory(brokerUri); this.connection = this.connectionFactory.CreateConnection(); this.connection.ClientId = clientId; this.connection.Start(); this.session = connection.CreateSession(); ActiveMQTopic topic = new ActiveMQTopic(topicName); this.consumer = this.session.CreateDurableConsumer(topic, consumerId, "2 > 1", false); this.consumer.Listener += new MessageListener(OnMessage); }
public override Object Clone() { // Since we are a derived class use the base's Clone() // to perform the shallow copy. Since it is shallow it // will include our derived class. Since we are derived, // this method is an override. ActiveMQTopic o = (ActiveMQTopic)base.Clone(); // Now do the deep work required // If any new variables are added then this routine will // likely need updating return(o); }
public void WhenRequestDeferredMessages_AMessageIsSentToTheAMQSchedulerTopic() { IMessage sentMessage = null; var destination = new ActiveMQTopic("someTopic"); var session = this.SetupCreateSession(); var producer = SetupCreateTopicProducer(session, ScheduledMessage.AMQ_SCHEDULER_MANAGEMENT_DESTINATION); producer.Setup(p => p.Send(It.IsAny<IMessage>())).Callback<IMessage>(m => sentMessage = m); this.testee.RequestDeferredMessages(destination); sentMessage.Should().NotBeNull(); sentMessage.NMSReplyTo.Should().Be(destination); sentMessage.Properties.Keys.Should().Contain(ScheduledMessage.AMQ_SCHEDULER_ACTION); sentMessage.Properties[ScheduledMessage.AMQ_SCHEDULER_ACTION].Should().Be(ScheduledMessage.AMQ_SCHEDULER_ACTION_BROWSE); }
public ActiveMq(bool durable) { _connectionFactory = new ConnectionFactory("tcp://localhost:61616"); _connectionFactory.AsyncSend = true; _connectionFactory.ProducerWindowSize = int.MaxValue; _connection = _connectionFactory.CreateConnection(); _connection.ClientId = "13AC0CF8-65FE-4638-8B85-62210DD89BEE"; _connection.Start(); _session = _connection.CreateSession(); ActiveMQTopic topic = new ActiveMQTopic("topic"); _consumer = _session.CreateDurableConsumer(topic, "durable", "2 > 1", false); _producer = _session.CreateProducer(topic); _producer.DeliveryMode = durable ? MsgDeliveryMode.Persistent : MsgDeliveryMode.NonPersistent; }
public virtual void SetUp() { this.nmsMessageID = "testid"; this.nmsCorrelationID = "testcorrelationid"; this.nmsDestination = new ActiveMQTopic("test.topic"); this.nmsReplyTo = new ActiveMQTempTopic("test.replyto.topic:001"); this.nmsDeliveryMode = MsgDeliveryMode.NonPersistent; this.nmsRedelivered = true; this.nmsType = "test type"; this.nmsPriority = MsgPriority.High; this.nmsTimestamp = DateTime.Now; this.consumerIDs = new long[3]; for(int i = 0; i < this.consumerIDs.Length; i++) { this.consumerIDs[i] = i; } }
public void TestCopy() { this.nmsMessageID = "ID:1141:45278:429"; this.nmsCorrelationID = "testcorrelationid"; this.nmsDestination = new ActiveMQTopic("test.topic"); this.nmsReplyTo = new ActiveMQTempTopic("test.replyto.topic:001"); this.nmsDeliveryMode = MsgDeliveryMode.NonPersistent; this.nmsType = "test type"; this.nmsPriority = MsgPriority.High; this.nmsTimestamp = DateTime.Now; ActiveMQMessage msg1 = new ActiveMQMessage(); msg1.NMSMessageId = this.nmsMessageID; msg1.NMSCorrelationID = this.nmsCorrelationID; msg1.FromDestination = this.nmsDestination; msg1.NMSReplyTo = this.nmsReplyTo; msg1.NMSDeliveryMode = this.nmsDeliveryMode; msg1.NMSType = this.nmsType; msg1.NMSPriority = this.nmsPriority; msg1.NMSTimestamp = this.nmsTimestamp; msg1.ReadOnlyProperties = true; ActiveMQMessage msg2 = msg1.Clone() as ActiveMQMessage; Assert.IsTrue(msg1.NMSMessageId.Equals(msg2.NMSMessageId)); Assert.IsTrue(msg1.NMSCorrelationID.Equals(msg2.NMSCorrelationID)); Assert.IsTrue(msg1.NMSDestination.Equals(msg2.NMSDestination)); Assert.IsTrue(msg1.NMSReplyTo.Equals(msg2.NMSReplyTo)); Assert.IsTrue(msg1.NMSDeliveryMode == msg2.NMSDeliveryMode); Assert.IsTrue(msg1.NMSRedelivered == msg2.NMSRedelivered); Assert.IsTrue(msg1.NMSType.Equals(msg2.NMSType)); Assert.IsTrue(msg1.NMSPriority == msg2.NMSPriority); Assert.IsTrue(msg1.NMSTimestamp == msg2.NMSTimestamp); }
/// <summary> /// Create a Destination /// </summary> /// <param name="type"></param> /// <param name="pyhsicalName"></param> /// <returns></returns> public static ActiveMQDestination CreateDestination(int type, String pyhsicalName) { ActiveMQDestination result = null; if(pyhsicalName == null) { return null; } else switch(type) { case ACTIVEMQ_TOPIC: result = new ActiveMQTopic(pyhsicalName); break; case ACTIVEMQ_TEMPORARY_TOPIC: result = new ActiveMQTempTopic(pyhsicalName); break; case ACTIVEMQ_QUEUE: result = new ActiveMQQueue(pyhsicalName); break; default: result = new ActiveMQTempQueue(pyhsicalName); break; } return result; }
/// <summary> /// </summary> /// <param name="destination"></param> /// <returns></returns> public static ActiveMQDestination Transform(IDestination destination) { ActiveMQDestination result = null; if(destination != null) { if(destination is ActiveMQDestination) { result = (ActiveMQDestination) destination; } else { if(destination is ITemporaryQueue) { result = new ActiveMQTempQueue(((IQueue) destination).QueueName); } else if(destination is ITemporaryTopic) { result = new ActiveMQTempTopic(((ITopic) destination).TopicName); } else if(destination is IQueue) { result = new ActiveMQQueue(((IQueue) destination).QueueName); } else if(destination is ITopic) { result = new ActiveMQTopic(((ITopic) destination).TopicName); } } } return result; }
private IMessageProducer GetTopic(string topic) { if (!Connecting()) { return null; } if (mqSession == null) { return null; } if (topics.ContainsKey(topic)) { return topics[topic]; } ActiveMQTopic dest = new ActiveMQTopic(topic); IMessageProducer producer = mqSession.CreateProducer(dest); topics[topic] = producer; return producer; }