public Twitter() { AdapterModes = new AdapterMode[] { new AdapterMode("Subscribe", MessageDirection.DatagramSender) }; Capabilities = new ESBAdapterCapabilities() { AdapterName = "TweetAdapter" }; }
/// <summary> /// This routine is fired by the ESB framework when the adapter is started up /// </summary> /// <param name="adapterMode">Contains the adapter mode being requested</param> /// <remarks> /// ESB framework will have already set the properties. The requested /// adapter mode is checked against supported modes for validity. public override void Connect(string adapterMode) { this._adapterMode = null; foreach (AdapterMode mode in AdapterModes) { // don't worry about capitalization if (adapterMode.Equals(mode.ModeName, StringComparison.InvariantCultureIgnoreCase)) { this._adapterMode = mode; break; } } // IncludeMetadata is a option located in the General Tab of the Adapter endpoint. Its meant to control whether or not // custom message properties should be collected and persisted and/or retreived from the message if (IncludeMetadata) { MessageProperties.Add(new NameValuePair("Mode", this._adapterMode.ModeName)); } // get a copy of the esb configuration. Used primarily for custom error handling and for instantiating the Neuron Message // Audit service used for publish mode exceptions. Configuration = this.Configuration; RaiseAdapterInfo(ErrorLevel.Verbose, Configuration == null ? "ESB Configuration Is NULL" : "ESB Configuration returned"); // connect to Neuron audit service ConnectAuditService(); // call user defined method ConnectAdapter(); // start up the receive thread for publish/polling mode if supported if (this._adapterMode.ModeName.Equals(AdapterModeStringConstants.Publish)) { this._receiveThread = new Thread(new ThreadStart(ReceiveThreadRoutine)); // always use a background thread so we don't need to clean them up this._receiveThread.IsBackground = true; this._receiveThread.Start(); } }
/// <summary> /// Create an initialized instance of the adapter /// </summary> /// <remarks> /// AdapterModes and ESBAdapterCapabilities must always be initialized so that the ESB /// framework and Neuron ESB Explorer UI can correctly interact with the adapter. Modes that are supported in the UI must listed. /// meta data i.e. esb message custom propeties that will be supported must be added, each one preceeded by a period (.), followed by the /// name of the property (no spaces), a semicolon, followed by the description of the property i.e. /// .[NameOfProperty].[Description of property] /// These properties will be displayed in the Set Properties Process Step as well. /// </remarks> public SerialAdapter() { AdapterModes = new AdapterMode[] { /// To control what is displayed and supporte in the neuron explorer UI, comment out the modes /// that you do not wish to support // new AdapterMode(AdapterModeStringsEnum.Subscriber.Description(), MessageDirection.DatagramSender), // subscribe mode - send messages to an SerialPort new AdapterMode(AdapterModeStringsEnum.Publish.Description(), MessageDirection.DatagramReceiver), // Receive mode - new files are obtained from SerialPort and published to the bus }; ESBAdapterCapabilities caps = new ESBAdapterCapabilities(); caps.AdapterName = AdapterName; caps.Prefix = MetadataPrefix; // SAMPLE: Sample context properties that will be exposed within Neuron. These can be viewed within the Set Properties Process Step // ************************************************************** caps.MetadataFieldInfo = MetadataPrefix + ".SerialPort:Name of SerialPort data is sent to or retreived from," + MetadataPrefix + ".BaudRate:bits per second,"; // ************************************************************** Capabilities = caps; }