public Producer() { string serverUrl = ConfigurationManager.AppSettings["serverUrl"]; string userName = ConfigurationManager.AppSettings["userName"]; string password = ConfigurationManager.AppSettings["password"]; string topicName = ConfigurationManager.AppSettings["avnTopicName"]; string inputQueueName = ConfigurationManager.AppSettings["inputQueueName"]; try { ConnectionFactory factory = new TIBCO.EMS.ConnectionFactory(serverUrl); connection = factory.CreateConnection(userName, password); // create the session session = connection.CreateSession(false, Session.NO_ACKNOWLEDGE); // create the destination destination = session.CreateQueue(inputQueueName); //destination = session.CreateTopic(topicName); // create the producer msgProducer = session.CreateProducer(null); msg = session.CreateTextMessage(); } catch (Exception ex) { Console.WriteLine("EMS Error: {0} {1}", ex.Message, ex.InnerException.Message); } }
private Session GetSession() { _connection = _connection ?? CreateConnection(); _session = _session ?? _connection.CreateSession(false, Session.CLIENT_ACKNOWLEDGE); return _session; }
public void Connect() { if (Connected) return; Disconnect(); try { Connection = _connectionFactory.CreateConnection(_cs.User, _cs.Password); Connection.ExceptionListener = _exeptionListenerer; } catch (Exception) { Disconnect(); throw; } }
/// <summary> /// Initializes a new instance of the <see cref="EmsConnection"/> class. /// </summary> /// <param name="connection">The underlying TIBCO EMS connection.</param> public EmsConnection(Connection connection) { this.nativeConnection = connection; this.nativeConnection.ExceptionHandler += HandleEmsException; }
/// <summary> /// Opens if is not initialized yet, otherwise just returns with no action. /// </summary> public void Open() { if (!initialized) { ValidateQueueConfiguration(); try { factory = new ConnectionFactory(ServerConfig.Url, ServerConfig.ClientId); } catch (EMSException e) { Log.TraceData(Log.Source, TraceEventType.Error, 15000, "URL/Client ID is wrong. " + e.ToString()); throw; } IConfigurationValueProvider configProvider = new SingleTagSectionConfigurationProvider(this.ServerConfig.AuthenticationSectionName); try { connection = factory.CreateConnection(configProvider["userName"], configProvider["password"]); } catch (EMSException e) { Log.TraceData(Log.Source, TraceEventType.Error, 15001, "Connection to ems server failed! " + e.ToString()); throw; } try { session = connection.CreateSession(this.sessionConfig.IsTransactional, sessionConfig.Mode); } catch (EMSException e) { Log.TraceData(Log.Source, TraceEventType.Error, 15002, "Error during session creation. " + e.ToString()); throw; } try { destination = CreateDestination(session, queueConfig.Name, queueConfig.Type); consumer = session.CreateConsumer(destination, queueConfig.MessageSelector, queueConfig.NoLocal); connection.Start(); } catch (EMSException e) { Log.TraceData(Log.Source, TraceEventType.Error, 15003, "Queue initialization error. " + e); throw; } initialized = true; } }