public TopicPublisher(ISession session, string topicName) { _session = session; DestinationName = topicName; _topic = new Apache.NMS.ActiveMQ.Commands.ActiveMQTopic(DestinationName); Producer = session.CreateProducer(_topic); }
public Publisher(ISession session, string topicName) { this.session = session; DestinationName = topicName; topic = new ActiveMQTopic(DestinationName); Producer = session.CreateProducer(topic); }
public TopicPublisher(ISession session, string topicName) { this.session = session; DestinationName = topicName; topic = SessionUtil.GetTopic(session, DestinationName); Producer = session.CreateProducer(topic); }
public DomainParticipantTransportSource(IDomainParticipant participant, string senderTopic, string receiverTopic) { _participant = participant; var bdt = new ByteDataTypeSupport(); var result = bdt.RegisterType(participant, bdt.TypeName); if (result != ReturnCode.Ok) throw new Exception("Unable to register type: " + result); _publisher = _participant.CreatePublisher(); _subscriber = _participant.CreateSubscriber(); var senderTopicQos = new TopicQos(); participant.GetDefaultTopicQos(ref senderTopicQos); var receiverTopicQos = new TopicQos(); participant.GetDefaultTopicQos(ref receiverTopicQos); _senderTopic = participant.CreateTopic(senderTopic, bdt.TypeName, senderTopicQos); _receiverTopic = participant.CreateTopic(receiverTopic, bdt.TypeName, receiverTopicQos); _dataWriter = (ByteDataWriter)_publisher.CreateDataWriter(_senderTopic); _dataToSendHandle = _dataWriter.RegisterInstance(_dataToSend); var dataReaderQos = new DataReaderQos(); _subscriber.GetDefaultDataReaderQos(ref dataReaderQos); _dataReader = (ByteDataReader)_subscriber.CreateDataReader(_receiverTopic, dataReaderQos, this, StatusKind.Any); }
public void SaveCommit(ITopic topic, out bool success) { using (IUnitOfWork uow = UnitOfWork.Begin()) { Save(topic, out success); if (success) uow.Commit(); } }
public void Clear() { detailsRichTextBox.Clear(); webBrowser1.Navigate("about:blank"); searchResultLV.VirtualListSize = 0; //Clear ListView _helpTopics = null; _helpTopic = null; }
private void RemoveSubscription(ITopic topic) { lock (_syncRoot) { if (_subscriptions.ContainsKey(topic.Key) == false) return; _subscriptions.Remove(topic.Key); } }
//make it delete any shows it is related to. or not if you want those always kept. public void Delete(ITopic topic) { Checks.Argument.IsNotNull(topic, "topic"); using (IUnitOfWork u = UnitOfWork.Begin()) { _repo.Remove(topic); u.Commit(); } }
/// <summary> /// Create a ContentFilteredTopic /// </summary> /// <param name="topicFName">The name of the topic.</param> /// <param name="topic">The topic to which the filter is applied.</param> /// <param name="arg">The handle to a sequence of strings with the parameter /// value used in the SQL expression.</param> public void createContentFilter(String topicName, ITopic topic, String arg) { String[] tab = new String[1]; tab[0] = arg; String filter = "ticker = %0"; filteredTopic = participant.CreateContentFilteredTopic(topicName, topic, filter, tab); ErrorHandler.checkHandle(filteredTopic, "DomainParticipant.CreateContentFilteredTopic"); }
public Subscription Get(ITopic topic) { lock (_syncRoot) { Subscription sub = null; if (_subscriptions.TryGetValue(topic.Key, out sub) == true) return sub; else return null; } }
public void Connect(string clientId, string topicName, string host, int ip = 61616) { string broker = "tcp://" + host + ":" + ip; m_connection = new ConnectionFactory(broker, clientId).CreateConnection(); m_session = m_connection.CreateSession(); m_topic = new ActiveMQTopic(topicName); //m_clinet = m_session.CreateProducer(m_topic); m_client = CreateClient(m_session, m_topic); }
public MainWindowViewModel(IService<UserQuery, UserResponse> userService, IService<RepoQuery, RepoResponse> repoService, ITopic<RepoNotification> repoTopic) { _userService = userService; _repoService = repoService; _repoTopic = repoTopic; _repoTopic.Messages .Select(n => n.Commit) .ObserveOnDispatcher() .Subscribe(Commits.Add); }
internal static void Remove(ITopic topic, Action<RealTimeMessage> handler) { var subscriptionManager = ObjectFactory.Build<ISubscriptionManager>(); lock (_lock) { var sub = subscriptionManager.Get(topic); if (sub == null) return; sub.Triggered -= handler; if (sub.IsEmpty == true) subscriptionManager.Unsubscribe(topic); } }
public MainWindowViewModel(IService<UserQuery, UserResponse> userService, IService<RepoQuery, RepoResponse> repoService, IService<FavQuery, FavResponse> favService, ITopic<RepoNotification> repoTopic) { _userService = userService; _repoService = repoService; _favService = favService; _repoTopic = repoTopic; _repoTopic.Messages .Select(n => n.Commit) .ObserveOnDispatcher() .Subscribe(Commits.Add); PropertyChangedStream.Where(p => p != "Property").Subscribe(p => Property = p); }
//consider changing the out parameter to a validation type object public void Save(ITopic topic, out bool success) { Checks.Argument.IsNotNull(topic, "topic"); success = false; if (null == _repo.FindByTopicId(topic.TopicId)) { try { _repo.Add(topic); success = true; } catch (Exception ex) { success = false; } } }
internal static void Add(ITopic topic, Action<RealTimeMessage> handler) { if (handler == null) throw new ArgumentException("Event handler cannot be null."); var subscriptionManager = ObjectFactory.Build<ISubscriptionManager>(); lock (_lock) { // Get existing var sub = subscriptionManager.Get(topic); // Create if not exists. if (sub == null) { sub = new Subscription { Topic = topic }; sub.Triggered += handler; subscriptionManager.Subscribe(sub); } else { sub.Triggered += handler; } } }
public virtual void OnInconsistentTopic(ITopic entityInterface, InconsistentTopicStatus status) { }
public HomeController(UserManager <User> userManager, IUser iUser, IPublication iPublication, ITopic iTopic) { _user = iUser; _publication = iPublication; _topic = iTopic; _userManager = userManager; }
public static IFluentProcessMutatorBuilder SequentialMerge(this IFluentProcessBuilder builder, ITopic topic, string name, Action <SequentialMergerBuilder> action) { var subBuilder = new SequentialMergerBuilder(topic, name); action.Invoke(subBuilder); return(builder.ReadFrom(subBuilder.Merger)); }
protected AbstractExecutable(ITopic topic, string name) : base(topic, name) { }
public ITopic CreateTopic( string topicName, string typeName, TopicQos qos, ITopicListener listener, StatusKind mask) { ITopic topic = null; using (OpenSplice.CustomMarshalers.TopicQosMarshaler marshaler = new OpenSplice.CustomMarshalers.TopicQosMarshaler()) { if (marshaler.CopyIn(qos) == ReturnCode.Ok) { if (listener != null) { OpenSplice.Gapi.gapi_topicListener gapiListener; TopicListenerHelper listenerHelper = new TopicListenerHelper(); listenerHelper.Listener = listener; listenerHelper.CreateListener(out gapiListener); using (TopicListenerMarshaler listenerMarshaler = new TopicListenerMarshaler(ref gapiListener)) { IntPtr gapiPtr = Gapi.DomainParticipant.create_topic( GapiPeer, topicName, typeName, marshaler.GapiPtr, listenerMarshaler.GapiPtr, mask); if (gapiPtr != IntPtr.Zero) { topic = new Topic(gapiPtr, listenerHelper); } } } else { // Invoke the corresponding gapi function. IntPtr gapiPtr = Gapi.DomainParticipant.create_topic( GapiPeer, topicName, typeName, marshaler.GapiPtr, IntPtr.Zero, mask); if (gapiPtr != IntPtr.Zero) { topic = new Topic(gapiPtr); } } } } if (topic != null) { DomainParticipantQos dpQos = null; ReturnCode result = GetQos(ref dpQos); if (result == ReturnCode.Ok) { if (dpQos.EntityFactory.AutoenableCreatedEntities) { topic.Enable(); } } } return(topic); }
/*** * Operations ***/ public ITopic CreateSimulatedMultitopic( string name, string type_name, string subscription_expression, string[] expression_parameters) { /* Type-specific DDS entities */ ChatMessageDataReader chatMessageDR; NameServiceDataReader nameServiceDR; NamedMessageDataWriter namedMessageDW; /* Query related stuff */ IQueryCondition nameFinder; string[] nameFinderParams; /* QosPolicy holders */ TopicQos namedMessageQos = new TopicQos(); SubscriberQos subQos = new SubscriberQos(); PublisherQos pubQos = new PublisherQos(); /* Others */ IDataReader parentReader; IDataWriter parentWriter; string partitionName = "ChatRoom"; string nameFinderExpr; ReturnCode status; /* Lookup both components that constitute the multi-topic. */ chatMessageTopic = realParticipant.FindTopic( "Chat_ChatMessage", Duration.Infinite); ErrorHandler.checkHandle( chatMessageTopic, "DDS.DomainParticipant.FindTopic (Chat_ChatMessage)"); nameServiceTopic = realParticipant.FindTopic( "Chat_NameService", Duration.Infinite); ErrorHandler.checkHandle( nameServiceTopic, "DDS.DomainParticipant.FindTopic (Chat_NameService)"); /* Create a ContentFilteredTopic to filter out * our own ChatMessages. */ filteredMessageTopic = realParticipant.CreateContentFilteredTopic( "Chat_FilteredMessage", chatMessageTopic, "userID <> %0", expression_parameters); ErrorHandler.checkHandle( filteredMessageTopic, "DDS.DomainParticipant.CreateContentFilteredTopic"); /* Adapt the default SubscriberQos to read from the * "ChatRoom" Partition. */ status = realParticipant.GetDefaultSubscriberQos(ref subQos); ErrorHandler.checkStatus( status, "DDS.DomainParticipant.GetDefaultSubscriberQos"); subQos.Partition.Name = new string[1]; subQos.Partition.Name[0] = partitionName; /* Create a private Subscriber for the multitopic simulator. */ multiSub = realParticipant.CreateSubscriber(subQos); ErrorHandler.checkHandle( multiSub, "DDS.DomainParticipant.CreateSubscriber (for multitopic)"); /* Create a DataReader for the FilteredMessage Topic * (using the appropriate QoS). */ DataReaderQos drQos = new DataReaderQos(); TopicQos topicQos = new TopicQos(); multiSub.GetDefaultDataReaderQos(ref drQos); filteredMessageTopic.RelatedTopic.GetQos(ref topicQos); multiSub.CopyFromTopicQos(ref drQos, topicQos); parentReader = multiSub.CreateDataReader(filteredMessageTopic, drQos); ErrorHandler.checkHandle( parentReader, "DDS.Subscriber.create_datareader (ChatMessage)"); /* Narrow the abstract parent into its typed representative. */ chatMessageDR = parentReader as ChatMessageDataReader; /* Allocate the DataReaderListener Implementation. */ msgListener = new DataReaderListenerImpl(); /* Attach the DataReaderListener to the DataReader, * only enabling the data_available event. */ status = chatMessageDR.SetListener(msgListener, StatusKind.DataAvailable); ErrorHandler.checkStatus(status, "DDS.DataReader_set_listener"); /* Create a DataReader for the nameService Topic * (using the appropriate QoS). */ DataReaderQos nsDrQos = new DataReaderQos(); TopicQos nsQos = new TopicQos(); status = multiSub.GetDefaultDataReaderQos(ref nsDrQos); ErrorHandler.checkStatus(status, "DDS.Subscriber.GetDefaultDataReaderQos"); nameServiceTopic.GetQos(ref nsQos); multiSub.CopyFromTopicQos(ref nsDrQos, nsQos); parentReader = multiSub.CreateDataReader(nameServiceTopic, nsDrQos); ErrorHandler.checkHandle(parentReader, "DDS.Subscriber.CreateDatareader (NameService)"); /* Narrow the abstract parent into its typed representative. */ nameServiceDR = parentReader as NameServiceDataReader; /* Define the SQL expression (using a parameterized value). */ nameFinderExpr = "userID = %0"; /* Allocate and assign the query parameters. */ nameFinderParams = new string[1]; nameFinderParams[0] = expression_parameters[0]; /* Create a QueryCondition to only read corresponding * nameService information by key-value. */ nameFinder = nameServiceDR.CreateQueryCondition( SampleStateKind.Any, ViewStateKind.Any, InstanceStateKind.Any, nameFinderExpr, nameFinderParams); ErrorHandler.checkHandle( nameFinder, "DDS.DataReader.create_querycondition (nameFinder)"); /* Create the Topic that simulates the multi-topic * (use Qos from chatMessage).*/ status = chatMessageTopic.GetQos(ref namedMessageQos); ErrorHandler.checkStatus(status, "DDS.Topic.GetQos"); /* Create the NamedMessage Topic whose samples simulate * the MultiTopic */ namedMessageTopic = realParticipant.CreateTopic( "Chat_NamedMessage", type_name, namedMessageQos); ErrorHandler.checkHandle( namedMessageTopic, "DDS.DomainParticipant.CreateTopic (NamedMessage)"); /* Adapt the default PublisherQos to write into the * "ChatRoom" Partition. */ status = realParticipant.GetDefaultPublisherQos(ref pubQos); ErrorHandler.checkStatus( status, "DDS.DomainParticipant.get_default_publisher_qos"); pubQos.Partition.Name = new string[1]; pubQos.Partition.Name[0] = partitionName; /* Create a private Publisher for the multitopic simulator. */ multiPub = realParticipant.CreatePublisher(pubQos); ErrorHandler.checkHandle( multiPub, "DDS.DomainParticipant.create_publisher (for multitopic)"); DataWriterQos nmDwQos = new DataWriterQos(); TopicQos nmQos = new TopicQos(); multiPub.GetDefaultDataWriterQos(ref nmDwQos); namedMessageTopic.GetQos(ref nmQos); multiPub.CopyFromTopicQos(ref nmDwQos, nmQos); /* Create a DataWriter for the multitopic. */ parentWriter = multiPub.CreateDataWriter(namedMessageTopic, nmDwQos); ErrorHandler.checkHandle( parentWriter, "DDS.Publisher.CreateDatawriter (NamedMessage)"); /* Narrow the abstract parent into its typed representative. */ namedMessageDW = parentWriter as NamedMessageDataWriter; /* Store the relevant Entities in our Listener. */ msgListener.ChatMessageDR = chatMessageDR; msgListener.NameServiceDR = nameServiceDR; msgListener.NamedMessageDW = namedMessageDW; msgListener.NameFinder = nameFinder; msgListener.NameFinderParams = nameFinderParams; /* Return the simulated Multitopic. */ return(namedMessageTopic); }
public IDataWriter CreateDataWriter(ITopic topic, DataWriterQos qos) { return(CreateDataWriter(topic, qos, null, 0)); }
static void Main(string[] args) { int domain = DDS.DomainId.Default; /* Create a DomainParticipant */ DomainParticipantFactory dpf = DomainParticipantFactory.Instance; IDomainParticipant participant = dpf.CreateParticipant( domain, null, StatusKind.Any); ErrorHandler.checkHandle( participant, "DDS.DomainParticipantFactory.CreateParticipant"); /* Register the required datatype for ChatMessage. */ ChatMessageTypeSupport chatMessageTS = new ChatMessageTypeSupport(); string chatMessageTypeName = chatMessageTS.TypeName; ReturnCode status = chatMessageTS.RegisterType( participant, chatMessageTypeName); ErrorHandler.checkStatus( status, "Chat.ChatMessageTypeSupport.RegisterType"); /* Register the required datatype for NameService. */ NameServiceTypeSupport nameServiceTS = new NameServiceTypeSupport(); ErrorHandler.checkHandle( nameServiceTS, "new NameServiceTypeSupport"); string nameServiceTypeName = nameServiceTS.TypeName; status = nameServiceTS.RegisterType( participant, nameServiceTypeName); ErrorHandler.checkStatus( status, "Chat.NameServiceTypeSupport.RegisterType"); /* Set the ReliabilityQosPolicy to RELIABLE. */ TopicQos reliableTopicQos = new TopicQos(); status = participant.GetDefaultTopicQos(ref reliableTopicQos); ErrorHandler.checkStatus( status, "DDS.DomainParticipant.get_DefaultTopicQos"); reliableTopicQos.Reliability.Kind = ReliabilityQosPolicyKind.ReliableReliabilityQos; /* Make the tailored QoS the new default. */ status = participant.SetDefaultTopicQos(reliableTopicQos); ErrorHandler.checkStatus( status, "DDS.DomainParticipant.SetDefaultTopicQos"); /* Use the changed policy when defining the ChatMessage topic */ ITopic chatMessageTopic = participant.CreateTopic( "Chat_ChatMessage", chatMessageTypeName, reliableTopicQos); ErrorHandler.checkHandle( chatMessageTopic, "DDS.DomainParticipant.CreateTopic (ChatMessage)"); /* Set the DurabilityQosPolicy to TRANSIENT. */ TopicQos settingTopicQos = new TopicQos(); status = participant.GetDefaultTopicQos(ref settingTopicQos); ErrorHandler.checkStatus( status, "DDS.DomainParticipant.GetDefaultTopicQos"); settingTopicQos.Durability.Kind = DurabilityQosPolicyKind.TransientDurabilityQos; /* Create the NameService Topic. */ ITopic nameServiceTopic = participant.CreateTopic( "Chat_NameService", nameServiceTypeName, settingTopicQos); ErrorHandler.checkHandle( nameServiceTopic, "DDS.DomainParticipant.CreateTopic"); /* Adapt the default SubscriberQos to read from the * "ChatRoom" Partition. */ SubscriberQos subQos = new SubscriberQos(); status = participant.GetDefaultSubscriberQos(ref subQos); ErrorHandler.checkStatus( status, "DDS.DomainParticipant.GetDefaultSubscriberQos"); subQos.Partition.Name = new string[1]; subQos.Partition.Name[0] = "ChatRoom"; /* Create a Subscriber for the UserLoad application. */ ISubscriber chatSubscriber = participant.CreateSubscriber(subQos); ErrorHandler.checkHandle( chatSubscriber, "DDS.DomainParticipant.CreateSubscriber"); /* Create a DataReader for the NameService Topic * (using the appropriate QoS). */ DataReaderQos nsQos = null; status = chatSubscriber.GetDefaultDataReaderQos(ref nsQos); ErrorHandler.checkStatus( status, "DDS.Subscriber.GetDefaultDataReaderQos"); status = chatSubscriber.CopyFromTopicQos(ref nsQos, settingTopicQos); ErrorHandler.checkStatus( status, "DDS.Subscriber.CopyFromTopicQos"); IDataReader parentReader = chatSubscriber.CreateDataReader( nameServiceTopic, nsQos, null, StatusKind.Any); ErrorHandler.checkHandle( parentReader, "DDS.Subscriber.CreateDatareader (NameService)"); NameServiceDataReader nameServer = parentReader as NameServiceDataReader; /* Adapt the DataReaderQos for the ChatMessageDataReader to * keep track of all messages. */ DataReaderQos messageQos = new DataReaderQos(); status = chatSubscriber.GetDefaultDataReaderQos(ref messageQos); ErrorHandler.checkStatus( status, "DDS.Subscriber.GetDefaultDataReaderQos"); status = chatSubscriber.CopyFromTopicQos( ref messageQos, reliableTopicQos); ErrorHandler.checkStatus( status, "DDS.Subscriber.CopyFromTopicQos"); messageQos.History.Kind = HistoryQosPolicyKind.KeepAllHistoryQos; /* Create a DataReader for the ChatMessage Topic * (using the appropriate QoS). */ parentReader = chatSubscriber.CreateDataReader( chatMessageTopic, messageQos); ErrorHandler.checkHandle( parentReader, "DDS.Subscriber.CreateDataReader (ChatMessage)"); /* Narrow the abstract parent into its typed representative. */ ChatMessageDataReader loadAdmin = parentReader as ChatMessageDataReader; /* Initialize the Query Arguments. */ string[] parameters = { "0" }; /* Create a QueryCondition that will contain all messages * with userID=ownID */ IQueryCondition singleUser = loadAdmin.CreateQueryCondition("userID=%0", parameters); ErrorHandler.checkHandle(singleUser, "DDS.DataReader.CreateQuerycondition"); /* Create a ReadCondition that will contain new users only */ IReadCondition newUser = nameServer.CreateReadCondition(SampleStateKind.NotRead, ViewStateKind.New, InstanceStateKind.Alive); ErrorHandler.checkHandle(newUser, "DDS.DataReader.create_readcondition"); /* Obtain a StatusCondition that triggers only when a Writer * changes Liveliness */ IStatusCondition leftUser = loadAdmin.StatusCondition; ErrorHandler.checkHandle(leftUser, "DDS.DataReader.GetStatusCondition"); status = leftUser.SetEnabledStatuses(StatusKind.LivelinessChanged); ErrorHandler.checkStatus(status, "DDS.StatusCondition.SetEnabledStatuses"); /* Create a bare guard which will be used to close the room */ escape = new GuardCondition(); /* Create a waitset and add the ReadConditions */ WaitSet userLoadWS = new WaitSet(); status = userLoadWS.AttachCondition(newUser); ErrorHandler.checkStatus(status, "DDS.WaitSet.AttachCondition (newUser)"); status = userLoadWS.AttachCondition(leftUser); ErrorHandler.checkStatus(status, "DDS.WaitSet.AttachCondition (leftUser)"); status = userLoadWS.AttachCondition(escape); ErrorHandler.checkStatus(status, "DDS.WaitSet.AttachCondition (escape)"); /* Initialize and pre-allocate the GuardList used to obtain * the triggered Conditions. */ ICondition[] guardList = new ICondition[3]; /* Remove all known Users that are not currently active. */ NameService[] nsMsgs = null; SampleInfo[] nsInfos = null; status = nameServer.Take(ref nsMsgs, ref nsInfos, Length.Unlimited, SampleStateKind.Any, ViewStateKind.Any, InstanceStateKind.NotAlive); ErrorHandler.checkStatus( status, "Chat.NameServiceDataReader.Take"); status = nameServer.ReturnLoan(ref nsMsgs, ref nsInfos); ErrorHandler.checkStatus( status, "Chat.NameServiceDataReader.ReturnLoan"); /* Start the sleeper thread. */ new Thread(new UserLoad().doWait).Start(); bool closed = false; int prevCount = 0; ChatMessage[] msgs = null; SampleInfo[] msgInfos = null; while (!closed) { /* Wait until at least one of the Conditions in the * waitset triggers. */ status = userLoadWS.Wait(ref guardList, Duration.Infinite); ErrorHandler.checkStatus(status, "DDS.WaitSet.Wait"); /* Walk over all guards to display information */ foreach (ICondition guard in guardList) { if (guard == newUser) { /* The newUser ReadCondition contains data */ status = nameServer.ReadWithCondition(ref nsMsgs, ref nsInfos, newUser); ErrorHandler.checkStatus(status, "Chat.NameServiceDataReader.read_w_condition"); foreach (NameService ns in nsMsgs) { Console.WriteLine("New user: "******"Chat.NameServiceDataReader.ReturnLoan"); } else if (guard == leftUser) { // Some liveliness has changed (either a DataWriter // joined or a DataWriter left) LivelinessChangedStatus livelinessStatus = new LivelinessChangedStatus(); status = loadAdmin.GetLivelinessChangedStatus(ref livelinessStatus); ErrorHandler.checkStatus(status, "DDS.DataReader.getLivelinessChangedStatus"); if (livelinessStatus.AliveCount < prevCount) { /* A user has left the ChatRoom, since a DataWriter * lost its liveliness. Take the effected users * so they will not appear in the list later on. */ status = nameServer.Take( ref nsMsgs, ref nsInfos, Length.Unlimited, SampleStateKind.Any, ViewStateKind.Any, InstanceStateKind.NotAliveNoWriters); ErrorHandler.checkStatus(status, "Chat.NameServiceDataReader.Take"); foreach (NameService nsMsg in nsMsgs) { /* re-apply query arguments */ parameters[0] = nsMsg.userID.ToString(); status = singleUser.SetQueryParameters(parameters); ErrorHandler.checkStatus(status, "DDS.QueryCondition.SetQueryParameters"); /* Read this user's history */ status = loadAdmin.TakeWithCondition( ref msgs, ref msgInfos, singleUser); ErrorHandler.checkStatus( status, "Chat.ChatMessageDataReader.TakeWithCondition"); /* Display the user and his history */ Console.WriteLine("Departed user {0} has sent {1} messages ", nsMsg.name, msgs.Length); status = loadAdmin.ReturnLoan(ref msgs, ref msgInfos); ErrorHandler.checkStatus(status, "Chat.ChatMessageDataReader.ReturnLoan"); } status = nameServer.ReturnLoan(ref nsMsgs, ref nsInfos); ErrorHandler.checkStatus(status, "Chat.NameServiceDataReader.ReturnLoan"); } prevCount = livelinessStatus.AliveCount; } else if (guard == escape) { Console.WriteLine("UserLoad has terminated."); closed = true; } else { //System.Diagnostics.Debug.Fail("Unknown Condition"); } } /* for */ } /* while (!closed) */ /* Remove all Conditions from the WaitSet. */ status = userLoadWS.DetachCondition(escape); ErrorHandler.checkStatus(status, "DDS.WaitSet.DetachCondition (escape)"); status = userLoadWS.DetachCondition(leftUser); ErrorHandler.checkStatus(status, "DDS.WaitSet.DetachCondition (leftUser)"); status = userLoadWS.DetachCondition(newUser); ErrorHandler.checkStatus(status, "DDS.WaitSet.DetachCondition (newUser)"); /* Free all resources */ status = participant.DeleteContainedEntities(); ErrorHandler.checkStatus(status, "DDS.DomainParticipant.DeleteContainedEntities"); status = dpf.DeleteParticipant(participant); ErrorHandler.checkStatus(status, "DDS.DomainParticipantFactory.DeleteParticipant"); }
public IMessageConsumer CreateDurableConsumer(ITopic destination, string name, string selector, bool noLocal) { throw new NotSupportedException("Durable Topic subscribers are not supported by MSMQ"); }
public SocialController(ITopic _topicObj) { this.topicObj = _topicObj; //topicObj.GetTopicsFromRabbitMQ(); }
public abstract void Notify(ITopic <T> topic, IPublisher <T> notifier);
public void TestDurableConsumerSelectorChange(AcknowledgementMode ackMode) { try { using (IConnection connection = CreateConnection(TEST_CLIENT_ID)) { connection.Start(); using (ISession session = connection.CreateSession(ackMode)) { ITopic topic = session.GetTopic(DURABLE_TOPIC); IMessageProducer producer = session.CreateProducer(topic); IMessageConsumer consumer = session.CreateDurableConsumer(topic, CONSUMER_ID, "color='red'", false); producer.DeliveryMode = MsgDeliveryMode.Persistent; // Send the messages ITextMessage sendMessage = session.CreateTextMessage("1st"); sendMessage.Properties["color"] = "red"; producer.Send(sendMessage); if (AcknowledgementMode.Transactional == ackMode) { session.Commit(); } ITextMessage receiveMsg = consumer.Receive(receiveTimeout) as ITextMessage; Assert.IsNotNull(receiveMsg, "Failed to retrieve 1st durable message."); Assert.AreEqual("1st", receiveMsg.Text); Assert.AreEqual(MsgDeliveryMode.Persistent, receiveMsg.NMSDeliveryMode, "NMSDeliveryMode does not match"); receiveMsg.Acknowledge(); if (AcknowledgementMode.Transactional == ackMode) { session.Commit(); } // Change the subscription. consumer.Dispose(); consumer = session.CreateDurableConsumer(topic, CONSUMER_ID, "color='blue'", false); sendMessage = session.CreateTextMessage("2nd"); sendMessage.Properties["color"] = "red"; producer.Send(sendMessage); sendMessage = session.CreateTextMessage("3rd"); sendMessage.Properties["color"] = "blue"; producer.Send(sendMessage); if (AcknowledgementMode.Transactional == ackMode) { session.Commit(); } // Selector should skip the 2nd message. receiveMsg = consumer.Receive(receiveTimeout) as ITextMessage; Assert.IsNotNull(receiveMsg, "Failed to retrieve durable message."); Assert.AreEqual("3rd", receiveMsg.Text, "Retrieved the wrong durable message."); Assert.AreEqual(MsgDeliveryMode.Persistent, receiveMsg.NMSDeliveryMode, "NMSDeliveryMode does not match"); receiveMsg.Acknowledge(); if (AcknowledgementMode.Transactional == ackMode) { session.Commit(); } // Make sure there are no pending messages. Assert.IsNull(consumer.ReceiveNoWait(), "Wrong number of messages in durable subscription."); } } } catch (Exception ex) { Assert.Fail(ex.Message); } finally { UnregisterDurableConsumer(TEST_CLIENT_ID, CONSUMER_ID); } }
private void _processSIF_ZoneStatus(SIF_ZoneStatus zoneStatus, IZone zone) { if (zoneStatus == null) { return; } bool sync = getChameleonProperty(zone, "sync", false); bool events = getChameleonProperty(zone, "logEvents", true); bool logEntry = getChameleonProperty(zone, "sifLogEntrySupport", false); fLogger.UseLogEntry = logEntry; string syncObjects = zone.Properties.GetProperty("chameleon.syncObjects"); ArrayList objectDefs = new ArrayList(); SIF_Providers providers = zoneStatus.SIF_Providers; if (providers != null) { foreach (SIF_Provider p in providers) { if (p.SIF_ObjectList != null) { foreach (SIF_Object obj in p.SIF_ObjectList) { // Lookup the topic for each provided object in the zone IElementDef def = Adk.Dtd.LookupElementDef(obj.ObjectName); if (def != null) { // Pull out just the objects specified according to configuration settings // or all, if the syncObjects setting is not specified if (syncObjects == null || (syncObjects.Length > 0 && syncObjects.IndexOf(def.Name) > -1)) { objectDefs.Add(def); if (events) { ITopic topic = TopicFactory.GetInstance(def); if (topic.GetSubscriber() == null) { topic.SetSubscriber(fLogger, null); } } } } } } } } if (logEntry) { ITopic sifLogEntryTopic = TopicFactory.GetInstance(InfraDTD.SIF_LOGENTRY); sifLogEntryTopic.SetSubscriber(fLogger, null); } // Disconnect the zone before provisioning zone.Disconnect(ProvisioningFlags.None); foreach (ITopic topic in TopicFactory.GetAllTopics(SifContext.DEFAULT)) { try { // Join the topic to each zone ( causes the agent to subscribe to the joined objects ) // TODO: Add an "isJoinedTo()" API to topic so that it doesn't throw an exception if (topic.ObjectType != InfraDTD.SIF_ZONESTATUS.Name) { topic.Join(zone); } } catch (Exception ex) { zone.Log.Error(ex.Message, ex); } } zone.Connect(ProvisioningFlags.Register); if (sync) { if (objectDefs.Count == 0) { zone.ServerLog.Log (LogLevel.WARNING, "No objects are being provided in this zone", null, "1001"); } foreach (IElementDef def in objectDefs) { if (def.IsSupported(Adk.SifVersion)) { Query q = new Query(def); // Query by specific parameters string condition = zone.Properties.GetProperty ("chameleon.syncConditions." + def.Name); if (condition != null && condition.Length > 0) { // The condition should be in the format "path=value" e.g "@RefId=123412341...1234|@Name=asdfasdf" String[] queryConditions = condition.Split('|'); foreach (String cond in queryConditions) { string[] conds = cond.Split('='); if (conds.Length == 2) { q.AddCondition(conds[0], "EQ", conds[1]); } } } if (logEntry) { zone.ServerLog.Log (LogLevel.INFO, "Requesting " + q.ObjectType.Name + " from the zone", q.ToXml(Adk.SifVersion), "1002"); } zone.Query(q); } else { String debug = "Will not request " + def.Name + " because it is not supported in " + Adk.SifVersion.ToString(); Console.WriteLine(debug); zone.ServerLog.Log(LogLevel.WARNING, debug, null, "1001"); } } } }
public IDataWriter CreateDataWriter( ITopic topic, DataWriterQos qos, IDataWriterListener listener, StatusKind mask) { DataWriter dataWriter = null; Topic topicObj = topic as Topic; using (OpenSplice.CustomMarshalers.DataWriterQosMarshaler marshaler = new OpenSplice.CustomMarshalers.DataWriterQosMarshaler()) { if (marshaler.CopyIn(qos) == ReturnCode.Ok) { if (listener != null) { // Note: we use the same gapi lister as the DataWriter since the // publisher doesn't add anything unique OpenSplice.Gapi.gapi_publisherDataWriterListener gapiListener; PublisherDataWriterListenerHelper listenerHelper = new PublisherDataWriterListenerHelper(); listenerHelper.Listener = listener; listenerHelper.CreateListener(out gapiListener); using (PublisherDataWriterListenerMarshaler listenerMarshaler = new PublisherDataWriterListenerMarshaler(ref gapiListener)) { IntPtr gapiPtr = Gapi.Publisher.create_datawriter( GapiPeer, topicObj.GapiPeer, marshaler.GapiPtr, listenerMarshaler.GapiPtr, mask); if (gapiPtr != IntPtr.Zero) { TypeSupport typeSupport = topic.Participant.GetTypeSupport(topic.TypeName) as OpenSplice.TypeSupport; dataWriter = typeSupport.CreateDataWriter(gapiPtr); dataWriter.SetListener(listenerHelper); } } } else { // Invoke the corresponding gapi function. IntPtr gapiPtr = Gapi.Publisher.create_datawriter( GapiPeer, topicObj.GapiPeer, marshaler.GapiPtr, IntPtr.Zero, mask); if (gapiPtr != IntPtr.Zero) { TypeSupport typeSupport = topic.Participant.GetTypeSupport(topic.TypeName) as OpenSplice.TypeSupport; dataWriter = typeSupport.CreateDataWriter(gapiPtr); } } } } if (dataWriter != null) { PublisherQos pubQos = null; ReturnCode result = GetQos(ref pubQos); if (result == ReturnCode.Ok) { if (pubQos.EntityFactory.AutoenableCreatedEntities) { dataWriter.Enable(); } } } return dataWriter; }
public void Notify(ITopic <string> subject, IPublisher <string> publisher) { NormalizeCriteria(); }
public IDataWriter CreateDataWriter(ITopic topic) { return(CreateDataWriter(topic, null, 0)); }
public ITopic CreateTopic( string topicName, string typeName, ITopicListener listener, StatusKind mask) { ITopic topic = null; if (listener != null) { OpenSplice.Gapi.gapi_topicListener gapiListener; TopicListenerHelper listenerHelper = new TopicListenerHelper(); listenerHelper.Listener = listener; listenerHelper.CreateListener(out gapiListener); using (TopicListenerMarshaler listenerMarshaler = new TopicListenerMarshaler(ref gapiListener)) { IntPtr gapiPtr = Gapi.DomainParticipant.create_topic( GapiPeer, topicName, typeName, Gapi.NativeConstants.GapiTopicQosDefault, listenerMarshaler.GapiPtr, mask); if (gapiPtr != IntPtr.Zero) { topic = new Topic(gapiPtr, listenerHelper); } } } else { IntPtr gapiPtr = Gapi.DomainParticipant.create_topic( GapiPeer, topicName, typeName, Gapi.NativeConstants.GapiTopicQosDefault, IntPtr.Zero, mask); if (gapiPtr != IntPtr.Zero) { topic = new Topic(gapiPtr); } } if (topic != null) { DomainParticipantQos dpQos = null; ReturnCode result = GetQos(ref dpQos); if (result == ReturnCode.Ok) { if (dpQos.EntityFactory.AutoenableCreatedEntities) { topic.Enable(); } } } return(topic); }
protected abstract IDisposable CreateClient(ISession session, ITopic topic);
public void CanCreateNamespaceThenCRUDOnTopic() { using (var context = FluentMockContext.Start(this.GetType().FullName)) { var rgName = TestUtilities.GenerateName("fluentnetsbmrg"); try { var resourceManager = TestHelper.CreateResourceManager(); var serviceBusManager = TestHelper.CreateServiceBusManager(); Region region = Region.USEast; var rgCreatable = resourceManager.ResourceGroups .Define(rgName) .WithRegion(region); var namespaceDNSLabel = TestUtilities.GenerateName("netsbns"); var queueName = TestUtilities.GenerateName("queue1-"); // Create NS with Queue // var nspace = serviceBusManager.Namespaces .Define(namespaceDNSLabel) .WithRegion(region) .WithNewResourceGroup(rgCreatable) .WithSku(NamespaceSku.Standard) .Create(); Assert.NotNull(nspace); Assert.NotNull(nspace.Inner); var topicName = TestUtilities.GenerateName("topic14444444444444444444444444444444444444444444555555555555"); var topic = nspace.Topics .Define(topicName) .Create(); Assert.NotNull(topic); Assert.NotNull(topic.Inner); Assert.NotNull(topic.Name); Assert.Equal(topic.Name, topicName, ignoreCase: true); var dupDetectionDuration = topic.DuplicateMessageDetectionHistoryDuration; Assert.Equal(10, dupDetectionDuration.TotalMinutes); // Default message TTL is TimeSpan.Max, assert parsing // Assert.Equal("10675199.02:48:05.4775807", topic.Inner.DefaultMessageTimeToLive); var msgTtlDuration = topic.DefaultMessageTtlDuration; // Assert the default ttl TimeSpan("10675199.02:48:05.4775807") parsing // Assert.Equal(10675199, msgTtlDuration.Days); Assert.Equal(2, msgTtlDuration.Hours); Assert.Equal(48, msgTtlDuration.Minutes); // Assert the default max size In MB // Assert.Equal(1024, topic.MaxSizeInMB); var topicsInNamespace = nspace.Topics.List(); Assert.NotNull(topicsInNamespace); Assert.True(topicsInNamespace.Count() > 0); ITopic foundTopic = topicsInNamespace.FirstOrDefault(t => t.Name.Equals(topic.Name, StringComparison.OrdinalIgnoreCase)); Assert.NotNull(foundTopic); foundTopic = foundTopic.Update() .WithDefaultMessageTTL(new TimeSpan(0, 20, 0)) .WithDuplicateMessageDetectionHistoryDuration(new TimeSpan(0, 15, 0)) .WithDeleteOnIdleDurationInMinutes(25) .Apply(); var ttlDuration = foundTopic.DefaultMessageTtlDuration; Assert.Equal(20, ttlDuration.Minutes); var duplicateDetectDuration = foundTopic.DuplicateMessageDetectionHistoryDuration; Assert.Equal(15, duplicateDetectDuration.Minutes); Assert.Equal(25, foundTopic.DeleteOnIdleDurationInMinutes); // Delete nspace.Topics.DeleteByName(foundTopic.Name); } finally { try { TestHelper.CreateResourceManager().ResourceGroups.DeleteByName(rgName); } catch { } } } }
public void Publish(ITopic topic, Message message, object source = null) { m_messageBus.Publish(topic, message, source); }
/// <summary> /// Initializes listening to a specific path on the Active MQ server. /// Please note, that, if not otherwise specified, it will be assumed that the path should be a queue. /// As such, if you want to specifically listen to a queue, prepend the path parameter with "queue://" otherwise with "topic://" /// </summary> /// <param name="path">The path to the message exchange</param> /// <param name="subscription">Not used by Active MQ. The subscription will be named automatically by the active mq server</param> /// <param name="filter">An SQL-like string to filter for values set on the meta properties of a message. This maps directly to the "properties" parameter (including "ContentType") of SendAsync</param> /// <returns></returns> public async Task <bool> ListenAsync(string path, string subscription = null, string filter = null) { _logger.Trace(ConnectorLogging.Process((nameof(path), path), (nameof(subscription), subscription), (nameof(filter), filter))); if (_isInternalListeningHooked) { _logger.Error($"Currently already listening to some path. Please call {nameof(StopListening)} before calling {nameof(ListenAsync)} again"); return(false); } if (!_isConnectionGood) { _logger.Error($"Currently not connected. Please wait for connection to be established before listening"); return(false); } if (_session == null) { _logger.Error($"Cannot listen to path if session has not been established"); return(false); } if (string.IsNullOrEmpty(path)) { _logger.Error($"Bad Argument: {nameof(path)} was null"); return(false); } PrependWithPathDefault(ref path); try { _listenToPath = path; _listenToSubscription = subscription; _listenToFilter = filter; IDestination destination; //todo: add code to verify, path is not for queue when subscription is not null and vice versa destination = SessionUtil.GetDestination(_session, path); ITopic topicDestination = SessionUtil.GetTopic(_session, path); if (string.IsNullOrEmpty(filter)) { if (path.StartsWith("topic://")) { _logger.Trace($"Creating durable consumer for {topicDestination.ToString()}"); _consumer = _session.CreateDurableConsumer(topicDestination, subscription, filter, false); } else if (path.StartsWith("queue://")) { _logger.Trace($"Creating consumer for {destination.ToString()}"); _consumer = _session.CreateConsumer(destination); } else { _logger.Error($"Could not start listening because a path of {path} cannot be handled"); return(false); } } else { if (path.StartsWith("topic://")) { _logger.Trace($"Creating durable consumer for {topicDestination.ToString()}"); _consumer = _session.CreateDurableConsumer(topicDestination, subscription, filter, false); } else if (path.StartsWith("queue://")) { _logger.Trace($"Creating consumer for {destination.ToString()}"); _consumer = _session.CreateConsumer(destination, filter); } else { _logger.Error($"Could not start listening because a path of {path} cannot be handled"); return(false); } } _consumer.Listener += OnMessageReceived; _isInternalListeningHooked = true; _logger.Info($"Initialization for listening to {path} successful."); return(true); } catch (Exception e) { _logger.Error($"Exception while starting listener: {e.ToString()}"); } return(false); }
public IContentFilteredTopic CreateContentFilteredTopic( string name, ITopic related_topic, string filter_expression, string[] filter_parameters) { return realParticipant.CreateContentFilteredTopic( name, related_topic, filter_expression, filter_parameters); }
public SequentialMerger(ITopic topic, string name) : base(topic, name) { }
public ReturnCode DeleteTopic(ITopic a_topic) { return realParticipant.DeleteTopic(a_topic); }
public DownloadFile(ITopic topic, string name) : base(topic, name) { }
public IMessageConsumer CreateDurableConsumer(ITopic destination, string name, string selector, bool noLocal) { return null; }
public ForceEvaluation(ITopic topic, IForce force, IConcern concern, string result) { Concern = concern; Result = result; Force = Force; }
public IDataWriter CreateDataWriter(ITopic topic, DataWriterQos qos) { return CreateDataWriter(topic, qos, null, 0); }
public ReturnCode DeleteTopic(ITopic a_topic) { return(realParticipant.DeleteTopic(a_topic)); }
public IDataWriter CreateDataWriter( ITopic topic, IDataWriterListener listener, StatusKind mask) { DataWriter dataWriter = null; Topic topicObj = topic as Topic; if (listener != null) { // Note: we use the same gapi lister as the DataWriter since the // publisher doesn't add anything unique OpenSplice.Gapi.gapi_publisherDataWriterListener gapiListener; PublisherDataWriterListenerHelper listenerHelper = new PublisherDataWriterListenerHelper(); listenerHelper.Listener = listener; listenerHelper.CreateListener(out gapiListener); using (PublisherDataWriterListenerMarshaler listenerMarshaler = new PublisherDataWriterListenerMarshaler(ref gapiListener)) { IntPtr gapiPtr = Gapi.Publisher.create_datawriter( GapiPeer, topicObj.GapiPeer, Gapi.NativeConstants.GapiDataWriterQosDefault, listenerMarshaler.GapiPtr, mask); if (gapiPtr != IntPtr.Zero) { TypeSupport typeSupport = topic.Participant.GetTypeSupport(topic.TypeName) as OpenSplice.TypeSupport; dataWriter = typeSupport.CreateDataWriter(gapiPtr); dataWriter.SetListener(listenerHelper); } } } else { IntPtr gapiPtr = Gapi.Publisher.create_datawriter( GapiPeer, topicObj.GapiPeer, Gapi.NativeConstants.GapiDataWriterQosDefault, IntPtr.Zero, mask); if (gapiPtr != IntPtr.Zero) { TypeSupport typeSupport = topic.Participant.GetTypeSupport(topic.TypeName) as OpenSplice.TypeSupport; dataWriter = typeSupport.CreateDataWriter(gapiPtr); } } if (dataWriter != null) { PublisherQos pubQos = null; ReturnCode result = GetQos(ref pubQos); if (result == ReturnCode.Ok) { if (pubQos.EntityFactory.AutoenableCreatedEntities) { dataWriter.Enable(); } } } return(dataWriter); }
static void Main(string[] args) { string partitionName = "ChatRoom"; string domain = null; /* Options: MessageBoard [ownID] */ /* Messages having owner ownID will be ignored */ string[] parameterList = new string[1]; if (args.Length > 0) { parameterList[0] = args[0]; } else { parameterList[0] = "0"; } /* Create a DomainParticipantFactory and a DomainParticipant * (using Default QoS settings. */ DomainParticipantFactory dpf = DomainParticipantFactory.Instance; ErrorHandler.checkHandle( dpf, "DDS.DomainParticipantFactory.Instance"); IDomainParticipant parentDP = dpf.CreateParticipant( domain, null, StatusKind.Any); ErrorHandler.checkHandle( parentDP, "DDS.DomainParticipantFactory.CreateParticipant"); /* Register the required datatype for ChatMessage. */ ChatMessageTypeSupport chatMessageTS = new ChatMessageTypeSupport(); string chatMessageTypeName = chatMessageTS.TypeName; ReturnCode status = chatMessageTS.RegisterType(parentDP, chatMessageTypeName); ErrorHandler.checkStatus( status, "Chat.ChatMessageTypeSupport.RegisterType"); /* Register the required datatype for NameService. */ NameServiceTypeSupport nameServiceTS = new NameServiceTypeSupport(); ErrorHandler.checkHandle( nameServiceTS, "new NameServiceTypeSupport"); string nameServiceTypeName = nameServiceTS.TypeName; status = nameServiceTS.RegisterType(parentDP, nameServiceTypeName); ErrorHandler.checkStatus( status, "Chat.NameServiceTypeSupport.RegisterType"); /* Register the required datatype for NamedMessage. */ NamedMessageTypeSupport namedMessageTS = new NamedMessageTypeSupport(); ErrorHandler.checkHandle( namedMessageTS, "new NamedMessageTypeSupport"); string namedMessageTypeName = namedMessageTS.TypeName; status = namedMessageTS.RegisterType(parentDP, namedMessageTypeName); ErrorHandler.checkStatus( status, "Chat.NamedMessageTypeSupport.RegisterType"); /* Narrow the normal participant to its extended representative */ ExtDomainParticipant participant = new ExtDomainParticipant(parentDP); /* Initialise QoS variables */ TopicQos reliableTopicQos = new TopicQos(); TopicQos settingTopicQos = new TopicQos(); SubscriberQos subQos = new SubscriberQos(); /* Set the ReliabilityQosPolicy to RELIABLE. */ status = participant.GetDefaultTopicQos(ref reliableTopicQos); ErrorHandler.checkStatus( status, "DDS.DomainParticipant.GetDefaultTopicQos"); reliableTopicQos.Reliability.Kind = ReliabilityQosPolicyKind.ReliableReliabilityQos; /* Make the tailored QoS the new default. */ status = participant.SetDefaultTopicQos(reliableTopicQos); ErrorHandler.checkStatus( status, "DDS.DomainParticipant.SetDefaultTopicQos"); /* Use the changed policy when defining the ChatMessage topic */ ITopic chatMessageTopic = participant.CreateTopic( "Chat_ChatMessage", chatMessageTypeName, reliableTopicQos); ErrorHandler.checkHandle( chatMessageTopic, "DDS.DomainParticipant.CreateTopic (ChatMessage)"); /* Set the DurabilityQosPolicy to TRANSIENT. */ status = participant.GetDefaultTopicQos(ref settingTopicQos); ErrorHandler.checkStatus( status, "DDS.DomainParticipant.GetDefaultTopicQos"); settingTopicQos.Durability.Kind = DurabilityQosPolicyKind.TransientDurabilityQos; /* Create the NameService Topic. */ ITopic nameServiceTopic = participant.CreateTopic( "Chat_NameService", nameServiceTypeName, settingTopicQos); ErrorHandler.checkHandle( nameServiceTopic, "DDS.DomainParticipant.CreateTopic (NameService)"); /* Create a multitopic that substitutes the userID * with its corresponding userName. */ ITopic namedMessageTopic = participant.CreateSimulatedMultitopic( "Chat_NamedMessage", namedMessageTypeName, "SELECT userID, name AS userName, index, content " + "FROM Chat_NameService NATURAL JOIN Chat_ChatMessage " + "WHERE userID <> %0", parameterList); ErrorHandler.checkHandle( namedMessageTopic, "ExtDomainParticipant.create_simulated_multitopic"); /* Adapt the default SubscriberQos to read from the "ChatRoom" Partition. */ status = participant.GetDefaultSubscriberQos(ref subQos); ErrorHandler.checkStatus( status, "DDS.DomainParticipant.GetDefaultSubscriberQos"); subQos.Partition.Name = new string[1]; subQos.Partition.Name[0] = partitionName; /* Create a Subscriber for the MessageBoard application. */ ISubscriber chatSubscriber = participant.CreateSubscriber(subQos); ErrorHandler.checkHandle( chatSubscriber, "DDS.DomainParticipant.CreateSubscriber"); /* Create a DataReader for the NamedMessage Topic * (using the appropriate QoS). */ IDataReader parentReader = chatSubscriber.CreateDataReader( namedMessageTopic); ErrorHandler.checkHandle( parentReader, "DDS.Subscriber.CreateDatareader"); NamedMessageDataReader chatAdmin = parentReader as NamedMessageDataReader; /* Print a message that the MessageBoard has opened. */ System.Console.WriteLine( "MessageBoard has opened: send a ChatMessage " + "with userID = -1 to close it....\n"); bool terminated = false; NamedMessage[] messages = null;; SampleInfo[] infos = null; while (!terminated) { /* Note: using read does not remove the samples from * unregistered instances from the DataReader. This means * that the DataRase would use more and more resources. * That's why we use take here instead. */ status = chatAdmin.Take( ref messages, ref infos, SampleStateKind.Any, ViewStateKind.Any, InstanceStateKind.Alive); ErrorHandler.checkStatus( status, "Chat.NamedMessageDataReader.take"); foreach (NamedMessage msg in messages) { if (msg.userID == TERMINATION_MESSAGE) { System.Console.WriteLine("Termination message received: exiting..."); terminated = true; } else { System.Console.WriteLine("{0}: {1}", msg.userName, msg.content); } } status = chatAdmin.ReturnLoan(ref messages, ref infos); ErrorHandler.checkStatus(status, "Chat.ChatMessageDataReader.ReturnLoan"); System.Threading.Thread.Sleep(100); } /* Remove the DataReader */ status = chatSubscriber.DeleteDataReader(chatAdmin); ErrorHandler.checkStatus( status, "DDS.Subscriber.DeleteDatareader"); /* Remove the Subscriber. */ status = participant.DeleteSubscriber(chatSubscriber); ErrorHandler.checkStatus( status, "DDS.DomainParticipant.DeleteSubscriber"); /* Remove the Topics. */ status = participant.DeleteSimulatedMultitopic(namedMessageTopic); ErrorHandler.checkStatus( status, "DDS.ExtDomainParticipant.DeleteSimulatedMultitopic"); status = participant.DeleteTopic(nameServiceTopic); ErrorHandler.checkStatus( status, "DDS.DomainParticipant.DeleteTopic (nameServiceTopic)"); status = participant.DeleteTopic(chatMessageTopic); ErrorHandler.checkStatus( status, "DDS.DomainParticipant.DeleteTopic (chatMessageTopic)"); /* Remove the DomainParticipant. */ status = dpf.DeleteParticipant(parentDP); ErrorHandler.checkStatus( status, "DDS.DomainParticipantFactory.DeleteParticipant"); }
/// <summary> /// Utility method to create a DDS Topic. /// </summary> /// <param name="topicName">The Topic name to create the topic with.</param> /// <param name="exampleNameToCreateTopicFor">The name of the example we are /// creating the topic for. This is used to define any specific Qos that the example /// requires.</param> /// <returns>The newly created Topic</returns> public ITopic createTopic(String topicName) { status = participant.GetDefaultTopicQos(ref topicQos); ErrorHandler.checkStatus(status, "DomainParticipant.GetDefaultTopicQos"); switch (exampleName) { case "ContentFilteredTopic": case "Durability": case "HelloWorld": case "WaitSet": case "Lifecycle": topicQos.Reliability.Kind = ReliabilityQosPolicyKind.ReliableReliabilityQos; if (durabilityKind.Equals("transient")) topicQos.Durability.Kind = DurabilityQosPolicyKind.TransientDurabilityQos; else topicQos.Durability.Kind = DurabilityQosPolicyKind.PersistentDurabilityQos; break; case "Ownership": topicQos.Reliability.Kind = ReliabilityQosPolicyKind.ReliableReliabilityQos; topicQos.Ownership.Kind = OwnershipQosPolicyKind.ExclusiveOwnershipQos; break; case "QueryCondition": topicQos.Reliability.Kind = ReliabilityQosPolicyKind.ReliableReliabilityQos; break; case "Listener": topicQos.Reliability.Kind = ReliabilityQosPolicyKind.ReliableReliabilityQos; topicQos.Durability.Kind = DurabilityQosPolicyKind.TransientDurabilityQos; // DeadlineQoSPolicy : period used to trigger the listener // (on_requested_deadline_missed) topicQos.Deadline.Period.NanoSec = 0; topicQos.Deadline.Period.Sec = 1; break; default: Console.WriteLine("Unidentified example to create topic for."); break; } status = participant.SetDefaultTopicQos(topicQos); ErrorHandler.checkStatus(status, "DomainParticipant.SetDefaultTopicQos"); topic = participant.CreateTopic( topicName, typeName, topicQos, null, StatusKind.Any ); ErrorHandler.checkHandle(topic, "DomainParticipant.CreateTopic"); return topic; }
public void Notify(ITopic <string> subject, IPublisher <string> publisher) { MyBroker.Instance.Publish(this, subject); }
public void Unsubscribe(ITopic topic, ISubscriber subscriber) { m_messageBus.Unsubscribe(topic, subscriber); }
public void Run() { #if DBCallTests DDS.Test.DatabaseTests(); #endif Console.WriteLine("Press enter to enter..."); Console.ReadLine(); Data.DataTest detectionData = new Data.DataTest(); detectionData.TestId = 3214; detectionData.Emergency = true; detectionData.TestStr = "not really"; //detectionData.SeqInt[3] = 23; #if TestMarshaling //Tactical.DetectionTypeSupport support = new Tactical.DetectionTypeSupport(); //Tactical.Detection cachedObj = new Tactical.Detection(); //support.Copy(cachedObj, detectionData); //SampleMarshaler marshaler = SampleMarshalerFactory.CreateMarshaler(detectionData); //using (SampleMarshalHelper helper = new SampleMarshalHelper(marshaler)) //{ // DDS.OpenSplice.Gapi.Test.test_detection(helper.GapiPtr); // Tactical.Detection detectionData2 = new Tactical.Detection(); // SampleMarshaler marshaler2 = SampleMarshalerFactory.CreateMarshaler(detectionData2); // marshaler2.CopyOut(helper.GapiPtr, 0); //} //Duration d = new Duration(234, 2343); //int sec; //uint nanosec; //DDS.OpenSplice.Gapi.Test.test_duration(d, out sec, out nanosec); //LivelinessChangedStatus status; //DDS.OpenSplice.Gapi.Test.get_liveliness_changed_status(out status); //Time t = new Time(1, 2); //int size = Marshal.SizeOf(t); //IntPtr ptr = Marshal.AllocHGlobal(size); //Marshal.StructureToPtr(t, ptr, true); #endif //DDS.Test.TestDataReaderQos(); //DDS.Test.TestTopicQos(); // Create a DomainParticipantFactory DomainParticipantFactory dpf = DomainParticipantFactory.Instance; Console.WriteLine("DomainParticipantFactory: " + dpf); // Tailor the DomainPartipantFactoryQos; DomainParticipantFactoryQos dpfQos = null; ReturnCode result = dpf.GetQos(ref dpfQos); Console.WriteLine("DomainParticipantFactory.get_qos: {0}", result); Console.WriteLine("DomainParticipantFactoryQos.entity_factory.autoenable_created_entities: " + dpfQos.EntityFactory.AutoenableCreatedEntities); dpfQos.EntityFactory.AutoenableCreatedEntities = true; result = dpf.SetQos(dpfQos); Console.WriteLine("DomainParticipantFactory.set_qos: {0}", result); // Get the QOS settings for the Factory... Check values without additional changes DomainParticipantFactoryQos dpf2Qos = null; result = dpf.GetQos(ref dpf2Qos); Console.WriteLine("DomainParticipantFactory.get_qos: {0}", result); Console.WriteLine("DomainParticipantFactoryQos.entity_factory.autoenable_created_entities: " + dpf2Qos.EntityFactory.AutoenableCreatedEntities); // Create the domainParticipant itself. DomainParticipantQos dpQos = new DomainParticipantQos(); dpQos.UserData.Value = new byte[] { (byte)1, (byte)2, (byte)3 }; dpQos.EntityFactory.AutoenableCreatedEntities = true; dpQos.ListenerScheduling.SchedulingClass.Kind = SchedulingClassQosPolicyKind.ScheduleDefault; dpQos.ListenerScheduling.SchedulingPriorityKind.Kind = SchedulingPriorityQosPolicyKind.PriorityRelative; dpQos.ListenerScheduling.SchedulingPriority = 0; dpQos.WatchdogScheduling.SchedulingClass.Kind = SchedulingClassQosPolicyKind.ScheduleDefault; dpQos.WatchdogScheduling.SchedulingPriorityKind.Kind = SchedulingPriorityQosPolicyKind.PriorityRelative; dpQos.WatchdogScheduling.SchedulingPriority = 4; IDomainParticipant dp = dpf.CreateParticipant(DDS.DomainId.Default, dpQos); Console.Write("DomainParticipant: "); Console.WriteLine(dp != null ? "yes" : "no"); if (dp.ContainsEntity(0)) { Console.WriteLine("contains_entity with nil handle incorrect"); } if (dp.ContainsEntity(100)) { Console.WriteLine("contains_entity with incorrect handle incorrect"); } Time currentTime; dp.GetCurrentTime(out currentTime); Console.WriteLine("Current Local Time: {0}", currentTime.ToDatetime().ToLocalTime()); // And look up this DomainParticipant. IDomainParticipant dp2 = dpf.LookupParticipant(DDS.DomainId.Default); DomainParticipantQos dp2Qos = null; Console.Write("lookup DomainParticipant: "); Console.WriteLine(dp2 != null ? "Success" : "Fail"); result = dp2.GetQos(ref dp2Qos); Console.WriteLine("DomainParticipant.get_qos: {0}", result); Console.WriteLine("DomainParticipantQos.entity_factory.autoenable_created_entities: " + dp2Qos.EntityFactory.AutoenableCreatedEntities); // Create a new PublisherQos and set some values... PublisherQos publisherQos = new PublisherQos(); publisherQos.EntityFactory.AutoenableCreatedEntities = true; publisherQos.Partition.Name = new string[] { "howdy" }; //, "neighbor", "partition" }; // true not supported in 4.1 ?? publisherQos.Presentation.OrderedAccess = false; // Create the Publisher dp.Enable(); IPublisher publisher = dp.CreatePublisher(publisherQos); Console.WriteLine("Create Publisher: {0}", publisher); DataWriterQos dwQos = null; publisher.GetDefaultDataWriterQos(ref dwQos); // Create a Detection Type Support and register it's type Data.DataTestTypeSupport support = new Data.DataTestTypeSupport(); string test2 = support.TypeName; Console.WriteLine("Register Typesupport"); result = support.RegisterType(dp, support.TypeName); Console.WriteLine("Register Typesupport Result: {0}", result); // Create a topic for the Detection type TopicQos topicQos = null; result = dp.GetDefaultTopicQos(ref topicQos); //topicQos.Ownership.Kind = OwnershipQosPolicyKind.ExclusiveOwnershipQos; //DDS.Test.TestTopicQos2(ref topicQos); // Add a listener to the topic ITopic topic = dp.CreateTopic("Data_DataTest", support.TypeName, topicQos, this, StatusKind.InconsistentTopic); topicQos.History.Depth = 5; ITopic topic2 = dp.CreateTopic("Data_DataTest", support.TypeName, topicQos); // ErrorCode errorCode; // string msg; // result = ErrorInfo.Update(); // result = ErrorInfo.GetCode(out errorCode); // result = ErrorInfo.GetMessage(out msg); // Create a DataWriter for the topic Data.IDataTestDataWriter dataWriter = publisher.CreateDataWriter(topic, dwQos) as Data.IDataTestDataWriter; // Create a SubscriberQos object and set the partition name SubscriberQos subscriberQos = null; result = dp.GetDefaultSubscriberQos(ref subscriberQos); subscriberQos.Partition.Name = new string[] { "howdy" }; // Create the subscriber ISubscriber sub = dp.CreateSubscriber(subscriberQos); // Verify that the subsciber was created... if (sub == null) { Console.WriteLine("Subscriber not created"); return; } DDS.DataReaderQos readerQos = null; sub.GetDefaultDataReaderQos(ref readerQos); //readerQos.SubscriptionKeys.KeyList = new string[] { "test" }; //readerQos.Durability.Kind = DurabilityQosPolicyKind.TransientDurabilityQos; //readerQos.Reliability.Kind = ReliabilityQosPolicyKind.ReliableReliabilityQos; // Create a DataReader for the Detection topic Data.IDataTestDataReader dataReader = sub.CreateDataReader(topic, readerQos, this, StatusKind.DataAvailable) as Data.IDataTestDataReader; // Create a filtered detection topic (only read detections that have an id != 4) IContentFilteredTopic filteredTopic = dp.CreateContentFilteredTopic("Another", topic, "TestId <> %0", "234"); //IContentFilteredTopic filteredTopic = dp.CreateContentFilteredTopic("Another", topic, "TestStr = %0", "not really"); string[] testParams = null; result = filteredTopic.GetExpressionParameters(ref testParams); if (result != DDS.ReturnCode.Ok || testParams == null || testParams.Length != 1 || !testParams[0].Equals("234")) { Console.WriteLine("filteredTopic.GetExpressionParameters does not return the expected parameter....."); } else { Console.WriteLine("filteredTopic.GetExpressionParameters returns the expected parameter....."); } result = filteredTopic.SetExpressionParameters("hello", "test"); if (result != DDS.ReturnCode.Ok) { Console.WriteLine("filteredTopic.SetExpressionParameters returns not OK: result = " + result); } // result = filteredTopic.GetExpressionParameters(ref testParams); // Create a DataReader to read the filtered topic Data.IDataTestDataReader reader2 = sub.CreateDataReader(filteredTopic) as Data.IDataTestDataReader; IQueryCondition queryCondition = dataReader.CreateQueryCondition( "TestId = %0", "234"); // just for testing... GC.Collect(); // WaitSet WaitSet waitSet = new WaitSet(); // either use status conditions...or IStatusCondition sc = reader2.StatusCondition; sc.SetEnabledStatuses(StatusKind.DataAvailable); waitSet.AttachCondition(sc); IStatusCondition sc2 = reader2.StatusCondition; // read conditions... IReadCondition readCond = reader2.CreateReadCondition(); waitSet.AttachCondition(readCond); Console.WriteLine("Press enter to write data"); Console.ReadLine(); detectionData.SequenceTest = new int[1];// new System.Collections.Generic.List<int>(); //detectionData.SequenceTest.Add(4); detectionData.SequenceTest[0] = 4; // Write detection data result = dataWriter.Write(detectionData); detectionData = new Data.DataTest(); detectionData.TestId = 234; dataWriter.Write(detectionData, InstanceHandle.Nil); detectionData = new Data.DataTest(); detectionData.TestId = 235; dataWriter.Write(detectionData); detectionData = new Data.DataTest(); detectionData.TestId = 236; dataWriter.Write(detectionData); detectionData = new Data.DataTest(); detectionData.TestId = 237; dataWriter.Write(detectionData); Console.WriteLine("Press enter to read data"); Console.ReadLine(); // Read the data ICondition[] cond = null; waitSet.Wait(ref cond, Duration.Infinite); SampleInfo[] infos = null; Data.DataTest[] dataValues = null; result = dataReader.Read(ref dataValues, ref infos); Console.WriteLine("dataReader: {0}", dataReader); if (dataValues != null) { Console.WriteLine("Number of samples received: {0}", dataValues.Length); for (int index = 0; index < dataValues.Length; index++) { Console.WriteLine("TestId: {0}, ProviderId: {1}, Emergency: {2}, TestStr: {3}", dataValues[index].TestId, dataValues[index].ProviderId, dataValues[index].Emergency, dataValues[index].TestStr); Console.WriteLine("info: ValidData: {0}, InstHandle: {1}, PubHandle:{2}, SourceTS: {3}, ArrivalTS: {4}, sample: {5}, view: {6}, instance: {7}", infos[index].ValidData, infos[index].InstanceHandle, infos[index].PublicationHandle, infos[index].SourceTimestamp, infos[index].ReceptionTimestamp, infos[index].SampleState, infos[index].ViewState, infos[index].InstanceState); } } Console.WriteLine("Press enter to read data from contentfiltered topic"); Console.ReadLine(); result = reader2.Read(ref dataValues, ref infos, DDS.Length.Unlimited); if (dataValues != null) { Console.WriteLine("Number of samples received: {0}", dataValues.Length); for (int index = 0; index < dataValues.Length; index++) { Console.WriteLine("TestId: {0}, ProviderId: {1}, Emergency: {2}, TestStr: {3}", dataValues[index].TestId, dataValues[index].ProviderId, dataValues[index].Emergency, dataValues[index].TestStr); Console.WriteLine("info: ValidData: {0}, InstHandle: {1}, PubHandle:{2}, SourceTS: {3}, ArrivalTS: {4}, sample: {5}, view: {6}, instance: {7}", infos[index].ValidData, infos[index].InstanceHandle, infos[index].PublicationHandle, infos[index].SourceTimestamp, infos[index].ReceptionTimestamp, infos[index].SampleState, infos[index].ViewState, infos[index].InstanceState); } } Console.WriteLine("Press enter to read data from query"); Console.ReadLine(); result = dataReader.ReadWithCondition(ref dataValues, ref infos, DDS.Length.Unlimited, queryCondition); if (dataValues != null) { Console.WriteLine("Number of samples received: {0}", dataValues.Length); for (int index = 0; index < dataValues.Length; index++) { Console.WriteLine("TestId: {0}, ProviderId: {1}, Emergency: {2}, TestStr: {3}", dataValues[index].TestId, dataValues[index].ProviderId, dataValues[index].Emergency, dataValues[index].TestStr); Console.WriteLine("info: ValidData: {0}, InstHandle: {1}, PubHandle:{2}, SourceTS: {3}, ArrivalTS: {4}, sample: {5}, view: {6}, instance: {7}", infos[index].ValidData, infos[index].InstanceHandle, infos[index].PublicationHandle, infos[index].SourceTimestamp, infos[index].ReceptionTimestamp, infos[index].SampleState, infos[index].ViewState, infos[index].InstanceState); } } Console.WriteLine("Press enter to cleanup"); Console.ReadLine(); Console.WriteLine("DeleteContainedEntities"); result = dp.DeleteContainedEntities(); // If you don't use DeleteContainedEntities then you must delete everything that was created //result = sub.DeleteDataReader(dataReader); //result = publisher.DeleteDataWriter(dataWriter); //result = dp.DeleteTopic(topic); //result = dp.DeletePublisher(publisher); //result = dp.DeleteSubscriber(sub); Console.WriteLine("DeleteParticipant"); result = dpf.DeleteParticipant(dp); Console.WriteLine("Press enter to exit"); Console.ReadLine(); }
/*** * Operations ***/ public ITopic CreateSimulatedMultitopic( string name, string type_name, string subscription_expression, string[] expression_parameters) { /* Type-specific DDS entities */ ChatMessageDataReader chatMessageDR; NameServiceDataReader nameServiceDR; NamedMessageDataWriter namedMessageDW; /* Query related stuff */ IQueryCondition nameFinder; string[] nameFinderParams; /* QosPolicy holders */ TopicQos namedMessageQos = new TopicQos(); SubscriberQos subQos = new SubscriberQos(); PublisherQos pubQos = new PublisherQos(); /* Others */ IDataReader parentReader; IDataWriter parentWriter; string partitionName = "ChatRoom"; string nameFinderExpr; ReturnCode status; /* Lookup both components that constitute the multi-topic. */ chatMessageTopic = realParticipant.FindTopic( "Chat_ChatMessage", Duration.Infinite); ErrorHandler.checkHandle( chatMessageTopic, "DDS.DomainParticipant.FindTopic (Chat_ChatMessage)"); nameServiceTopic = realParticipant.FindTopic( "Chat_NameService", Duration.Infinite); ErrorHandler.checkHandle( nameServiceTopic, "DDS.DomainParticipant.FindTopic (Chat_NameService)"); /* Create a ContentFilteredTopic to filter out our own ChatMessages. */ filteredMessageTopic = realParticipant.CreateContentFilteredTopic( "Chat_FilteredMessage", chatMessageTopic, "userID <> %0", expression_parameters); ErrorHandler.checkHandle( filteredMessageTopic, "DDS.DomainParticipant.CreateContentFilteredTopic"); /* Adapt the default SubscriberQos to read from the "ChatRoom" Partition. */ status = realParticipant.GetDefaultSubscriberQos (ref subQos); ErrorHandler.checkStatus( status, "DDS.DomainParticipant.GetDefaultSubscriberQos"); subQos.Partition.Name = new string[1]; subQos.Partition.Name[0] = partitionName; /* Create a private Subscriber for the multitopic simulator. */ multiSub = realParticipant.CreateSubscriber(subQos); ErrorHandler.checkHandle( multiSub, "DDS.DomainParticipant.CreateSubscriber (for multitopic)"); /* Create a DataReader for the FilteredMessage Topic (using the appropriate QoS). */ DataReaderQos drQos = new DataReaderQos(); TopicQos topicQos = new TopicQos(); multiSub.GetDefaultDataReaderQos(ref drQos); filteredMessageTopic.RelatedTopic.GetQos(ref topicQos); multiSub.CopyFromTopicQos(ref drQos, topicQos); parentReader = multiSub.CreateDataReader(filteredMessageTopic, drQos); ErrorHandler.checkHandle( parentReader, "DDS.Subscriber.create_datareader (ChatMessage)"); /* Narrow the abstract parent into its typed representative. */ chatMessageDR = parentReader as ChatMessageDataReader; /* Allocate the DataReaderListener Implementation. */ msgListener = new DataReaderListenerImpl(); /* Attach the DataReaderListener to the DataReader, only enabling the data_available event. */ status = chatMessageDR.SetListener(msgListener, StatusKind.DataAvailable); ErrorHandler.checkStatus(status, "DDS.DataReader_set_listener"); /* Create a DataReader for the nameService Topic (using the appropriate QoS). */ DataReaderQos nsDrQos = new DataReaderQos(); TopicQos nsQos = new TopicQos(); nameServiceTopic.GetQos(ref nsQos); multiSub.CopyFromTopicQos(ref nsDrQos, nsQos); parentReader = multiSub.CreateDataReader(nameServiceTopic, nsDrQos); ErrorHandler.checkHandle(parentReader, "DDS.Subscriber.CreateDatareader (NameService)"); /* Narrow the abstract parent into its typed representative. */ nameServiceDR = parentReader as NameServiceDataReader; /* Define the SQL expression (using a parameterized value). */ nameFinderExpr = "userID = %0"; /* Allocate and assign the query parameters. */ nameFinderParams = new string[1]; nameFinderParams[0] = expression_parameters[0]; /* Create a QueryCondition to only read corresponding nameService information by key-value. */ nameFinder = nameServiceDR.CreateQueryCondition( SampleStateKind.Any, ViewStateKind.Any, InstanceStateKind.Any, nameFinderExpr, nameFinderParams); ErrorHandler.checkHandle( nameFinder, "DDS.DataReader.create_querycondition (nameFinder)"); /* Create the Topic that simulates the multi-topic (use Qos from chatMessage).*/ status = chatMessageTopic.GetQos(ref namedMessageQos); ErrorHandler.checkStatus(status, "DDS.Topic.GetQos"); /* Create the NamedMessage Topic whose samples simulate the MultiTopic */ namedMessageTopic = realParticipant.CreateTopic( "Chat_NamedMessage", type_name, namedMessageQos); ErrorHandler.checkHandle( namedMessageTopic, "DDS.DomainParticipant.CreateTopic (NamedMessage)"); /* Adapt the default PublisherQos to write into the "ChatRoom" Partition. */ status = realParticipant.GetDefaultPublisherQos(ref pubQos); ErrorHandler.checkStatus( status, "DDS.DomainParticipant.get_default_publisher_qos"); pubQos.Partition.Name = new string[1]; pubQos.Partition.Name[0] = partitionName; /* Create a private Publisher for the multitopic simulator. */ multiPub = realParticipant.CreatePublisher(pubQos); ErrorHandler.checkHandle( multiPub, "DDS.DomainParticipant.create_publisher (for multitopic)"); DataWriterQos nmDwQos = new DataWriterQos(); TopicQos nmQos = new TopicQos(); multiPub.GetDefaultDataWriterQos(ref nmDwQos); namedMessageTopic.GetQos(ref nmQos); multiPub.CopyFromTopicQos(ref nmDwQos, nmQos); /* Create a DataWriter for the multitopic. */ parentWriter = multiPub.CreateDataWriter(namedMessageTopic, nmDwQos); ErrorHandler.checkHandle( parentWriter, "DDS.Publisher.CreateDatawriter (NamedMessage)"); /* Narrow the abstract parent into its typed representative. */ namedMessageDW = parentWriter as NamedMessageDataWriter; /* Store the relevant Entities in our Listener. */ msgListener.ChatMessageDR = chatMessageDR; msgListener.NameServiceDR = nameServiceDR; msgListener.NamedMessageDW = namedMessageDW; msgListener.NameFinder = nameFinder; msgListener.NameFinderParams = nameFinderParams; /* Return the simulated Multitopic. */ return namedMessageTopic; }
public override void OnInconsistentTopic(ITopic entityInterface, InconsistentTopicStatus status) { // Test the listener... This class is an TopicListener -- we can listen for an InconsistenTopic // by overriding the OnInconsistentTopic method of the TopicListener. Console.WriteLine("Received Inconsistent Topic"); }
public GuessSetBased(ITopic topic) { Topic = topic; CreatedDate = DateTime.Now; SongList = new SetBasedSongList(); }
public CommentController(UserManager <User> userManager, IUser iUser, IPublication iPublication, ITopic iTopic, IComment iComment) { _user = iUser; _publication = iPublication; _topic = iTopic; _userManager = userManager; _comment = iComment; }
/// <summary> /// Creates the durable consumer, potentially returning a cached instance. /// </summary> /// <param name="destination">The destination.</param> /// <param name="subscription">The name of the durable subscription.</param> /// <param name="selector">The selector.</param> /// <param name="noLocal">if set to <c>true</c> [no local].</param> /// <returns>A message consumer</returns> public IMessageConsumer CreateDurableConsumer(ITopic destination, string subscription, string selector, bool noLocal) { this.transactionOpen = true; if (shouldCacheConsumers) { return GetCachedConsumer(destination, selector, noLocal, subscription); } else { return target.CreateDurableConsumer(destination, subscription, selector, noLocal); } }
public ThrowExceptionOnRowErrorMutator(ITopic topic) : base(topic, null) { }
public C (ITopic it) { string i = it.get_Title (2, 3); it.set_Title (1, 2, false, "bb"); }
/// <summary> /// Creates a specific subscription to a topic if it doesn't exist yet. /// </summary> /// <param name="topic">The <see cref="ITopic"/> that we are subscribing to.</param> /// <param name="name">The name of the subscription we are doing on the <see cref="ITopic"/>.</param> /// <returns>The <see cref="Microsoft.Azure.Management.ServiceBus.Fluent.ISubscription"/> entity object that references the subscription.</returns> public static async Task <Microsoft.Azure.Management.ServiceBus.Fluent.ISubscription> CreateSubscriptionIfNotExists(this ITopic topic, string name) { await topic.RefreshAsync(); var subscription = (await topic.Subscriptions.ListAsync()).SingleOrDefault(s => s.Name == name.ToLowerInvariant()); if (subscription != null) { return(subscription); } await topic.Subscriptions .Define(name.ToLowerInvariant()) .WithMessageLockDurationInSeconds(60) .WithExpiredMessageMovedToDeadLetterSubscription() .WithMessageMovedToDeadLetterSubscriptionOnMaxDeliveryCount(10) .CreateAsync(); await topic.RefreshAsync(); return((await topic.Subscriptions.ListAsync()).Single(t => t.Name == name.ToLowerInvariant())); }