public override void CreateRole(string roleName)
        {
            Util.CheckParameter(ref roleName, true, true, true, 256, "roleName");
            OracleConnectionHolder connection    = null;
            OracleCommand          oracleCommand = null;

            try
            {
                try
                {
                    connection    = OracleConnectionHelper.GetConnection(this.m_OracleConnectionString);
                    oracleCommand = new OracleCommand("ora_aspnet_Roles_CreateRole", connection.Connection)
                    {
                        CommandTimeout = this.m_CommandTimeout,
                        CommandType    = CommandType.StoredProcedure
                    };
                    oracleCommand.Parameters.Add(new OracleParameter("OutResult", OracleDbType.Int32, ParameterDirection.ReturnValue));
                    oracleCommand.Parameters[0].DbType = DbType.Int32;
                    oracleCommand.Parameters.Add(new OracleParameter("ApplicationName_", OracleDbType.NVarchar2));
                    oracleCommand.Parameters[1].Value = this.m_ApplicationName;
                    oracleCommand.Parameters.Add(new OracleParameter("RoleName_", OracleDbType.NVarchar2));
                    oracleCommand.Parameters[2].Value = roleName;
                    oracleCommand.ExecuteNonQuery();
                    int value = (int)oracleCommand.Parameters[0].Value;
                    if (value == -3000)
                    {
                        int      pROVIDERROLEALREADYEXISTS = ErrRes.PROVIDER_ROLE_ALREADY_EXISTS;
                        string[] strArrays = new string[] { roleName };
                        throw new ProviderException(MsgManager.GetMsg(pROVIDERROLEALREADYEXISTS, strArrays));
                    }
                    if (value == 0)
                    {
                        return;
                    }
                }
                catch
                {
                    throw;
                }
            }
            finally
            {
                if (oracleCommand != null)
                {
                    oracleCommand.Dispose();
                }
                if (connection != null)
                {
                    connection.Close();
                    connection = null;
                }
            }
        }
Example #2
0
        async Task PerformExpiredMessagesCleanupCycle()
        {
            var results   = 0;
            var stopwatch = Stopwatch.StartNew();

            while (true)
            {
                using (var connection = await _connectionHelper.GetConnection())
                {
                    int affectedRows;

                    using (var command = connection.CreateCommand())
                    {
                        command.CommandText =
                            $@"
                            delete from {_tableName} 
                            where recipient = :recipient 
                            and expiration < systimestamp(6)
                            ";
                        command.Parameters.Add(new OracleParameter("recipient", OracleDbType.VarChar, _inputQueueName, ParameterDirection.Input));
                        affectedRows = await command.ExecuteNonQueryAsync();
                    }

                    results += affectedRows;
                    connection.Complete();

                    if (affectedRows == 0)
                    {
                        break;
                    }
                }
            }

            if (results > 0)
            {
                _log.Info(
                    "Performed expired messages cleanup in {0} - {1} expired messages with recipient {2} were deleted",
                    stopwatch.Elapsed, results, _inputQueueName);
            }
        }
Example #3
0
            public override void Initialize(string name, NameValueCollection config)
            {
                if (config == null)
                {
                    throw new ArgumentNullException(nameof(config));
                }
                if (string.IsNullOrEmpty(name))
                {
                    name = "Oracle.Web.SessionState.OracleSessionStateStoreProvider";
                }
                Util.HandleDescriptionAttribute(config, ErrRes.SESSIONSTATE_PROVIDER_DESCRIPTION);
                base.Initialize(name, config);
                this.m_CommandTimeout = Convert.ToInt32(Util.GetConfigValue(config["commandTimeout"], "30"));
                if (this.m_CommandTimeout < 0 || this.m_CommandTimeout > int.MaxValue)
                {
                    throw new ProviderException(MsgManager.GetMsg(ErrRes.PROVIDER_INVALID_COMMANDTIMEOUT_VALUE));
                }
                this.m_OracleConnectionString = Util.ReadConnectionString(config).Trim();
                config.Remove("connectionStringName");
                config.Remove("commandTimeout");
                Util.CheckForUnrecognizedAttribute(config);
                this.pApplicationName = HttpRuntime.AppDomainAppId;
                OracleConnectionHolder connectionHolder = (OracleConnectionHolder)null;
                OracleCommand          oracleCommand    = (OracleCommand)null;

                try
                {
                    connectionHolder = OracleConnectionHelper.GetConnection(this.m_OracleConnectionString);
                    oracleCommand    = new OracleCommand("ora_aspnet_SessnApp_GetAppID", connectionHolder.Connection);
                    ((DbCommand)oracleCommand).CommandTimeout = this.m_CommandTimeout;
                    ((DbCommand)oracleCommand).CommandType    = CommandType.StoredProcedure;
                    oracleCommand.Parameters.Add(new OracleParameter("OutResult", (OracleDbType)112, ParameterDirection.ReturnValue));
                    ((DbParameter)oracleCommand.Parameters[0]).DbType = DbType.Int32;
                    oracleCommand.Parameters.Add(new OracleParameter("appName_", (OracleDbType)119, 280));
                    ((DbParameter)oracleCommand.Parameters[1]).Value = (object)this.pApplicationName;
                    oracleCommand.Parameters.Add(new OracleParameter("appId_", (OracleDbType)120, ParameterDirection.Output));
                    ((DbParameter)oracleCommand.Parameters[2]).Size   = 16;
                    ((DbParameter)oracleCommand.Parameters[2]).DbType = DbType.Binary;
                    ((DbCommand)oracleCommand).ExecuteNonQuery();
                    this.m_appID = new Guid((byte[])((DbParameter)oracleCommand.Parameters[2]).Value).ToString();
                }
                catch
                {
                    throw;
                }
                finally
                {
                    ((Component)oracleCommand)?.Dispose();
                    connectionHolder?.Close();
                }
            }
Example #4
0
        /// <summary>
        /// Saves the <paramref name="sagaData"/> snapshot and the accompanying <paramref name="sagaAuditMetadata"/>
        /// </summary>
        public async Task Save(ISagaData sagaData, Dictionary <string, string> sagaAuditMetadata)
        {
            using (var connection = _connectionHelper.GetConnection())
            {
                using (var command = connection.CreateCommand())
                {
                    command.CommandText =
                        $@"
                        INSERT
                            INTO {_tableName} (id, revision, data, metadata)
                            VALUES (:id, :revision, :data, :metadata)
                        ";
                    command.Parameters.Add("id", OracleDbType.Raw).Value         = sagaData.Id;
                    command.Parameters.Add("revision", OracleDbType.Int64).Value = sagaData.Revision;
                    command.Parameters.Add("data", OracleDbType.Blob).Value      = _objectSerializer.Serialize(sagaData);
                    command.Parameters.Add("metadata", OracleDbType.Clob).Value  =
                        _dictionarySerializer.SerializeToString(sagaAuditMetadata);

                    await command.ExecuteNonQueryAsync();
                }

                connection.Complete();
            }
        }
        public override bool RoleExists(string roleName)
        {
            bool flag;

            Util.CheckParameter(ref roleName, true, true, true, 256, "roleName");
            OracleConnectionHolder connection    = null;
            OracleCommand          oracleCommand = null;

            try
            {
                try
                {
                    connection    = OracleConnectionHelper.GetConnection(this.m_OracleConnectionString);
                    oracleCommand = new OracleCommand("ora_aspnet_Roles_RoleExists", connection.Connection)
                    {
                        CommandTimeout = this.m_CommandTimeout,
                        CommandType    = CommandType.StoredProcedure
                    };
                    oracleCommand.Parameters.Add(new OracleParameter("OutResult", OracleDbType.Int32, ParameterDirection.ReturnValue));
                    oracleCommand.Parameters[0].DbType = DbType.Int32;
                    oracleCommand.Parameters.Add(new OracleParameter("ApplicationName_", OracleDbType.NVarchar2));
                    oracleCommand.Parameters[1].Value = this.m_ApplicationName;
                    oracleCommand.Parameters.Add(new OracleParameter("RoleName_", OracleDbType.NVarchar2));
                    oracleCommand.Parameters[2].Value = roleName;
                    oracleCommand.ExecuteNonQuery();
                    flag = ((int)oracleCommand.Parameters[0].Value != 0 ? false : true);
                }
                catch
                {
                    throw;
                }
            }
            finally
            {
                if (oracleCommand != null)
                {
                    oracleCommand.Dispose();
                }
                if (connection != null)
                {
                    connection.Close();
                    connection = null;
                }
            }
            return(flag);
        }
Example #6
0
 Task <ConnectionWrapper> GetConnection(ITransactionContext context)
 {
     return(context
            .GetOrAdd(CurrentConnectionKey,
                      async() =>
     {
         await Task.CompletedTask;
         var dbConnection = _connectionHelper.GetConnection();
         var connectionWrapper = new ConnectionWrapper(dbConnection);
         context.OnCommitted(() =>
         {
             dbConnection.Complete();
             return Task.FromResult(0);
         });
         context.OnDisposed(() => connectionWrapper.Dispose());
         return connectionWrapper;
     }));
 }
Example #7
0
        public static void DropTableAndSequence(string tableName)
        {
            using (var connection = OracleConnectionHelper.GetConnection().Result)
            {
                using (var comand = connection.CreateCommand())
                {
                    comand.CommandText = $@"drop table {tableName}";

                    try
                    {
                        comand.ExecuteNonQuery();

                        Console.WriteLine("Dropped oracle table '{0}'", tableName);
                    }
                    catch (OracleException exception) when(exception.Number == TableDoesNotExist)
                    {
                    }
                }

                using (var comand = connection.CreateCommand())
                {
                    comand.CommandText = $@"drop sequence {tableName}_SEQ";

                    try
                    {
                        comand.ExecuteNonQuery();

                        Console.WriteLine("Dropped oracle sequence '{0}_SEQ'", tableName);
                    }
                    catch (OracleException exception) when(exception.Number == SequenceDoesNotExist)
                    {
                    }
                }


                connection.Complete();
            }
        }
        /// <summary>
        /// Checks to see if the configured saga data and saga index table exists. If they both exist, we'll continue, if
        /// neigther of them exists, we'll try to create them. If one of them exists, we'll throw an error.
        /// </summary>
        public void EnsureTablesAreCreated()
        {
            using (var connection = _connectionHelper.GetConnection())
            {
                var tableNames = connection.GetTableNames().ToHashSet();

                var hasDataTable  = tableNames.Any(tableName => _dataTableName.Equals(tableName, StringComparison.InvariantCultureIgnoreCase));
                var hasIndexTable = tableNames.Any(tableName => _indexTableName.Equals(tableName, StringComparison.InvariantCultureIgnoreCase));

                if (hasDataTable && hasIndexTable)
                {
                    return;
                }

                if (hasDataTable)
                {
                    throw new RebusApplicationException(
                              $"The saga index table '{_indexTableName}' does not exist, so the automatic saga schema generation tried to run - but there was already a table named '{_dataTableName}', which was supposed to be created as the data table");
                }

                if (hasIndexTable)
                {
                    throw new RebusApplicationException(
                              $"The saga data table '{_dataTableName}' does not exist, so the automatic saga schema generation tried to run - but there was already a table named '{_indexTableName}', which was supposed to be created as the index table");
                }

                _log.Info(
                    "Saga tables {tableName} (data) and {tableName} (index) do not exist - they will be created now",
                    _dataTableName, _indexTableName);

                using (var command = connection.CreateCommand())
                {
                    command.CommandText =
                        $@"
                        CREATE TABLE {_dataTableName} (
                            id RAW(16) NOT NULL,
                            revision NUMBER(10) NOT NULL,
                            data BLOB NOT NULL,
                            CONSTRAINT {_dataTableName}_pk PRIMARY KEY(id)
                        )";

                    command.ExecuteNonQuery();
                }

                using (var command = connection.CreateCommand())
                {
                    command.CommandText = $@"
                        CREATE TABLE {_indexTableName} (
                            saga_type NVARCHAR2(500) NOT NULL,
                            key NVARCHAR2(500) NOT NULL,
                            value NVARCHAR2(2000) NOT NULL,
                            saga_id RAW(16) NOT NULL,
                            CONSTRAINT {_indexTableName}_pk PRIMARY KEY(key, value, saga_type)
                        )";
                    command.ExecuteNonQuery();
                }
                using (var command = connection.CreateCommand())
                {
                    command.CommandText = $@"CREATE INDEX {_indexTableName}_IDX ON {_indexTableName} (saga_id)";
                    command.ExecuteNonQuery();
                }

                connection.Complete();
            }
        }
        public override void RemoveUsersFromRoles(string[] userNames, string[] roleNames)
        {
            Util.CheckArrayParameter(ref roleNames, true, true, true, 256, "roleNames");
            Util.CheckArrayParameter(ref userNames, true, true, true, 256, "userNames");
            string empty = string.Empty;
            string str   = string.Empty;
            OracleConnectionHolder connection    = null;
            OracleCommand          oracleCommand = null;

            try
            {
                try
                {
                    connection    = OracleConnectionHelper.GetConnection(this.m_OracleConnectionString);
                    oracleCommand = new OracleCommand("ora_aspnet_UIR_RemUsersFmRoles", connection.Connection)
                    {
                        CommandTimeout = this.m_CommandTimeout,
                        CommandType    = CommandType.StoredProcedure
                    };
                    OracleParameter oracleParameter = oracleCommand.Parameters.Add("OutResult", OracleDbType.Int32, ParameterDirection.ReturnValue);
                    oracleParameter.DbType = DbType.Int32;
                    OracleParameter mApplicationName = oracleCommand.Parameters.Add("ApplicationName_", OracleDbType.NVarchar2);
                    mApplicationName.Value = this.m_ApplicationName;
                    OracleParameter length = oracleCommand.Parameters.Add("UserNames_", OracleDbType.NVarchar2);
                    length.CollectionType = OracleCollectionType.PLSQLAssociativeArray;
                    length.Size           = (int)userNames.Length;
                    length.Value          = userNames;
                    OracleParameter length1 = oracleCommand.Parameters.Add("UserNames_Arr_Size", OracleDbType.Int32);
                    length1.Value = (int)userNames.Length;
                    OracleParameter oracleParameter1 = oracleCommand.Parameters.Add("RoleNames_", OracleDbType.NVarchar2);
                    oracleParameter1.CollectionType = OracleCollectionType.PLSQLAssociativeArray;
                    oracleParameter1.Size           = (int)roleNames.Length;
                    oracleParameter1.Value          = roleNames;
                    OracleParameter length2 = oracleCommand.Parameters.Add("RoleNames_Arr_Size", OracleDbType.Int32);
                    length2.Value = (int)roleNames.Length;
                    OracleParameter oracleParameter2 = oracleCommand.Parameters.Add("UserName", OracleDbType.NVarchar2, OracleRoleProvider.MAX_NAME_SIZE);
                    oracleParameter2.Direction = ParameterDirection.Output;
                    OracleParameter oracleParameter3 = oracleCommand.Parameters.Add("RoleName", OracleDbType.NVarchar2, OracleRoleProvider.MAX_NAME_SIZE);
                    oracleParameter3.Direction = ParameterDirection.Output;
                    oracleCommand.ExecuteNonQuery();
                    int value = (int)oracleCommand.Parameters[0].Value;
                    if (oracleCommand.Parameters[6].Value.ToString() != "null")
                    {
                        str = oracleCommand.Parameters[6].Value.ToString();
                    }
                    if (oracleCommand.Parameters[7].Value.ToString() != "null")
                    {
                        empty = oracleCommand.Parameters[7].Value.ToString();
                    }
                    int num = value;
                    switch (num)
                    {
                    case -3004:
                    {
                        int      pROVIDERTHISUSERNOTFOUND = ErrRes.PROVIDER_THIS_USER_NOT_FOUND;
                        string[] strArrays = new string[] { str };
                        throw new ProviderException(MsgManager.GetMsg(pROVIDERTHISUSERNOTFOUND, strArrays));
                    }

                    case -3003:
                    {
                        int      pROVIDERTHISUSERALREADYNOTINROLE = ErrRes.PROVIDER_THIS_USER_ALREADY_NOT_IN_ROLE;
                        string[] strArrays1 = new string[] { str, empty };
                        throw new ProviderException(MsgManager.GetMsg(pROVIDERTHISUSERALREADYNOTINROLE, strArrays1));
                    }

                    case -3002:
                    {
                        break;
                    }

                    case -3001:
                    {
                        int      pROVIDERROLENOTFOUND = ErrRes.PROVIDER_ROLE_NOT_FOUND;
                        string[] strArrays2           = new string[] { empty };
                        throw new ProviderException(MsgManager.GetMsg(pROVIDERROLENOTFOUND, strArrays2));
                    }

                    default:
                    {
                        if (num != 0)
                        {
                            goto case -3002;
                        }
                        return;
                    }
                    }
                }
                catch
                {
                    throw;
                }
            }
            finally
            {
                if (oracleCommand != null)
                {
                    oracleCommand.Dispose();
                }
                if (connection != null)
                {
                    connection.Close();
                    connection = null;
                }
            }
        }
        public override bool IsUserInRole(string userName, string roleName)
        {
            bool flag;

            Util.CheckParameter(ref roleName, true, true, true, 256, "roleName");
            Util.CheckParameter(ref userName, true, false, true, 256, "userName");
            if (userName.Length < 1)
            {
                return(false);
            }
            OracleConnectionHolder connection    = null;
            OracleCommand          oracleCommand = null;

            try
            {
                try
                {
                    connection    = OracleConnectionHelper.GetConnection(this.m_OracleConnectionString);
                    oracleCommand = new OracleCommand("ora_aspnet_UIR_IsUserInRole", connection.Connection)
                    {
                        CommandTimeout = this.m_CommandTimeout,
                        CommandType    = CommandType.StoredProcedure
                    };
                    oracleCommand.Parameters.Add(new OracleParameter("OutResult", OracleDbType.Int32, ParameterDirection.ReturnValue));
                    oracleCommand.Parameters[0].DbType = DbType.Int32;
                    oracleCommand.Parameters.Add(new OracleParameter("ApplicationName_", OracleDbType.NVarchar2));
                    oracleCommand.Parameters[1].Value = this.m_ApplicationName;
                    oracleCommand.Parameters.Add(new OracleParameter("UserName_", OracleDbType.NVarchar2));
                    oracleCommand.Parameters[2].Value = userName;
                    oracleCommand.Parameters.Add(new OracleParameter("RoleName_", OracleDbType.NVarchar2));
                    oracleCommand.Parameters[3].Value = roleName;
                    oracleCommand.ExecuteNonQuery();
                    switch ((int)oracleCommand.Parameters[0].Value)
                    {
                    case 0:
                    {
                        flag = true;
                        return(flag);
                    }

                    case 1:
                    {
                        flag = false;
                        return(flag);
                    }

                    case 2:
                    {
                        flag = false;
                        return(flag);
                    }

                    case 3:
                    {
                        flag = false;
                        return(flag);
                    }
                    }
                    flag = false;
                }
                catch
                {
                    throw;
                }
            }
            finally
            {
                if (oracleCommand != null)
                {
                    oracleCommand.Dispose();
                }
                if (connection != null)
                {
                    connection.Close();
                    connection = null;
                }
            }
            return(flag);
        }
        public override string[] GetUsersInRole(string roleName)
        {
            string[] strArrays;
            Util.CheckParameter(ref roleName, true, true, true, 256, "roleName");
            OracleConnectionHolder connection       = null;
            OracleCommand          oracleCommand    = null;
            OracleDataReader       oracleDataReader = null;

            try
            {
                try
                {
                    StringCollection stringCollections = new StringCollection();
                    connection    = OracleConnectionHelper.GetConnection(this.m_OracleConnectionString);
                    oracleCommand = new OracleCommand("ora_aspnet_UIR_GetUsersInRoles", connection.Connection)
                    {
                        CommandTimeout = this.m_CommandTimeout,
                        CommandType    = CommandType.StoredProcedure
                    };
                    OracleParameter oracleParameter = oracleCommand.Parameters.Add("OutResult", OracleDbType.Int32, ParameterDirection.ReturnValue);
                    oracleParameter.DbType = DbType.Int32;
                    OracleParameter mApplicationName = oracleCommand.Parameters.Add("ApplicationName_", OracleDbType.NVarchar2);
                    mApplicationName.Value = this.m_ApplicationName;
                    oracleCommand.Parameters.Add("RoleName_", OracleDbType.NVarchar2).Value      = roleName;
                    oracleCommand.Parameters.Add("UserCursor", OracleDbType.RefCursor).Direction = ParameterDirection.Output;
                    oracleDataReader = oracleCommand.ExecuteReader();
                    int value = (int)oracleCommand.Parameters[0].Value;
                    while (oracleDataReader.Read())
                    {
                        stringCollections.Add(oracleDataReader.GetString(0));
                    }
                    if (stringCollections.Count >= 1)
                    {
                        string[] strArrays1 = new string[stringCollections.Count];
                        stringCollections.CopyTo(strArrays1, 0);
                        strArrays = strArrays1;
                    }
                    else
                    {
                        int num = value;
                        if (num == -3001)
                        {
                            int      pROVIDERROLENOTFOUND = ErrRes.PROVIDER_ROLE_NOT_FOUND;
                            string[] strArrays2           = new string[] { roleName };
                            throw new ProviderException(MsgManager.GetMsg(pROVIDERROLENOTFOUND, strArrays2));
                        }
                        strArrays = (num != 0 ? new string[0] : new string[0]);
                    }
                }
                catch
                {
                    throw;
                }
            }
            finally
            {
                if (oracleDataReader != null)
                {
                    oracleDataReader.Dispose();
                }
                if (oracleCommand != null)
                {
                    oracleCommand.Dispose();
                }
                if (connection != null)
                {
                    connection.Close();
                    connection = null;
                }
            }
            return(strArrays);
        }
        public override string[] GetRolesForUser(string userName)
        {
            string[] strArrays;
            Util.CheckParameter(ref userName, true, false, true, 256, "userName");
            if (userName.Length < 1)
            {
                return(new string[0]);
            }
            OracleConnectionHolder connection       = null;
            OracleCommand          oracleCommand    = null;
            OracleDataReader       oracleDataReader = null;

            try
            {
                try
                {
                    StringCollection stringCollections = new StringCollection();
                    connection    = OracleConnectionHelper.GetConnection(this.m_OracleConnectionString);
                    oracleCommand = new OracleCommand("ora_aspnet_UIR_GetRolesForUser", connection.Connection)
                    {
                        CommandTimeout = this.m_CommandTimeout,
                        CommandType    = CommandType.StoredProcedure
                    };
                    OracleParameter oracleParameter = oracleCommand.Parameters.Add("OutResult", OracleDbType.Int32, ParameterDirection.ReturnValue);
                    oracleParameter.DbType = DbType.Int32;
                    OracleParameter mApplicationName = oracleCommand.Parameters.Add("ApplicationName_", OracleDbType.NVarchar2);
                    mApplicationName.Value = this.m_ApplicationName;
                    oracleCommand.Parameters.Add("UserName_", OracleDbType.NVarchar2).Value      = userName;
                    oracleCommand.Parameters.Add("RoleCursor", OracleDbType.RefCursor).Direction = ParameterDirection.Output;
                    oracleDataReader = oracleCommand.ExecuteReader();
                    int value = (int)oracleCommand.Parameters[0].Value;
                    while (oracleDataReader.Read())
                    {
                        stringCollections.Add(oracleDataReader.GetString(0));
                    }
                    if (stringCollections.Count >= 1)
                    {
                        string[] strArrays1 = new string[stringCollections.Count];
                        stringCollections.CopyTo(strArrays1, 0);
                        strArrays = strArrays1;
                    }
                    else
                    {
                        strArrays = new string[0];
                    }
                }
                catch
                {
                    throw;
                }
            }
            finally
            {
                if (oracleDataReader != null)
                {
                    oracleDataReader.Dispose();
                }
                if (oracleCommand != null)
                {
                    oracleCommand.Dispose();
                }
                if (connection != null)
                {
                    connection.Close();
                    connection = null;
                }
            }
            return(strArrays);
        }
Example #13
0
            private SessionStateStoreData GetSessionStoreItem(
                HttpContext context,
                string id,
                bool getExclusive,
                out bool locked,
                out TimeSpan lockAge,
                out object lockId,
                out SessionStateActions actionFlags)
            {
                MemoryStream           memoryStream     = (MemoryStream)null;
                OracleConnectionHolder connectionHolder = (OracleConnectionHolder)null;
                OracleCommand          oracleCommand    = (OracleCommand)null;

                locked      = false;
                lockId      = (object)null;
                lockAge     = TimeSpan.Zero;
                actionFlags = SessionStateActions.None;
                try
                {
                    connectionHolder = OracleConnectionHelper.GetConnection(this.m_OracleConnectionString);
                    oracleCommand    = !getExclusive ? new OracleCommand("ora_aspnet_Sessn_GetStateItem", connectionHolder.Connection) : new OracleCommand("ora_aspnet_Sessn_GetStateItmEx", connectionHolder.Connection);
                    ((DbCommand)oracleCommand).CommandTimeout = this.m_CommandTimeout;
                    ((DbCommand)oracleCommand).CommandType    = CommandType.StoredProcedure;
                    ((DbParameter)oracleCommand.Parameters.Add("OutResult", (OracleDbType)112, ParameterDirection.ReturnValue)).DbType  = DbType.Int32;
                    ((DbParameter)oracleCommand.Parameters.Add(nameof(id), (OracleDbType)119, OracleSessionStateStore.ID_LENGTH)).Value = (object)(id + this.m_appID);
                    OracleParameter oracleParameter = oracleCommand.Parameters.Add("itemShort", (OracleDbType)120, ParameterDirection.Output);
                    ((DbParameter)oracleParameter).Size   = 2000;
                    ((DbParameter)oracleParameter).DbType = DbType.Binary;
                    ((DbParameter)oracleCommand.Parameters.Add(nameof(locked), (OracleDbType)112, ParameterDirection.Output)).DbType      = DbType.Int32;
                    ((DbParameter)oracleCommand.Parameters.Add(nameof(lockAge), (OracleDbType)112, ParameterDirection.Output)).DbType     = DbType.Int32;
                    ((DbParameter)oracleCommand.Parameters.Add("lockCookie", (OracleDbType)112, ParameterDirection.Output)).DbType        = DbType.Int32;
                    ((DbParameter)oracleCommand.Parameters.Add(nameof(actionFlags), (OracleDbType)112, ParameterDirection.Output)).DbType = DbType.Int32;
                    oracleCommand.Parameters.Add("itemLong", (OracleDbType)102, ParameterDirection.Output);
                    ((DbCommand)oracleCommand).ExecuteNonQuery();
                    if (Convert.IsDBNull(((DbParameter)oracleCommand.Parameters[3]).Value))
                    {
                        return((SessionStateStoreData)null);
                    }
                    locked      = (int)((DbParameter)oracleCommand.Parameters[3]).Value != 0;
                    lockId      = (object)(int)((DbParameter)oracleCommand.Parameters[5]).Value;
                    actionFlags = (SessionStateActions)((DbParameter)oracleCommand.Parameters[6]).Value;
                    if (locked)
                    {
                        lockAge = new TimeSpan(0, 0, (int)((DbParameter)oracleCommand.Parameters[4]).Value);
                        if (lockAge > new TimeSpan(0, 0, 30758400))
                        {
                            lockAge = TimeSpan.Zero;
                        }
                        return((SessionStateStoreData)null);
                    }
                    byte[] buffer = !Convert.IsDBNull(((DbParameter)oracleCommand.Parameters[2]).Value) ? (byte[])((DbParameter)oracleCommand.Parameters[2]).Value : ((OracleBlob)((DbParameter)oracleCommand.Parameters[7]).Value).Value;
                    SessionStateStoreData sessionStateStoreData;
                    try
                    {
                        memoryStream          = new MemoryStream(buffer);
                        sessionStateStoreData = OracleSessionStateStore.Deserialize(context, (Stream)memoryStream);
                    }
                    finally
                    {
                        memoryStream?.Close();
                    }
                    return(sessionStateStoreData);
                }
                catch
                {
                    throw;
                }
                finally
                {
                    ((Component)oracleCommand)?.Dispose();
                    connectionHolder?.Close();
                }
            }
Example #14
0
            public override void SetAndReleaseItemExclusive(
                HttpContext context,
                string id,
                SessionStateStoreData item,
                object lockId,
                bool newItem)
            {
                OracleConnectionHolder connectionHolder = (OracleConnectionHolder)null;
                OracleCommand          oracleCommand    = (OracleCommand)null;

                try
                {
                    connectionHolder = OracleConnectionHelper.GetConnection(this.m_OracleConnectionString);
                    byte[] buffer;
                    int    length;
                    try
                    {
                        OracleSessionStateStore.SerializeSessionStateStoreData(item, 2000, out buffer, out length);
                    }
                    catch
                    {
                        if (!newItem)
                        {
                            this.ReleaseItemExclusive(context, id, lockId);
                        }
                        throw;
                    }
                    int num = lockId != null ? (int)lockId : 0;
                    if (!newItem)
                    {
                        if (length <= 2000)
                        {
                            oracleCommand = new OracleCommand(OracleSessionStateStore.ora_aspnet_Sessn_UpdStateItem_CommandText, connectionHolder.Connection);
                            ((DbCommand)oracleCommand).CommandTimeout = this.m_CommandTimeout;
                            ((DbCommand)oracleCommand).CommandType    = CommandType.Text;
                            oracleCommand.BindByName = true;
                            oracleCommand.Parameters.Add(new OracleParameter("itemShort", (OracleDbType)120, 2000));
                            ((DbParameter)oracleCommand.Parameters[0]).Size  = length;
                            ((DbParameter)oracleCommand.Parameters[0]).Value = (object)buffer;
                            oracleCommand.Parameters.Add(new OracleParameter("itemLong", (OracleDbType)110));
                            ((DbParameter)oracleCommand.Parameters[1]).Value = (object)DBNull.Value;
                            oracleCommand.Parameters.Add(new OracleParameter("timeout", (OracleDbType)112));
                            ((DbParameter)oracleCommand.Parameters[2]).Value = (object)item.Timeout;
                            oracleCommand.Parameters.Add(new OracleParameter(nameof(id), (OracleDbType)119, OracleSessionStateStore.ID_LENGTH));
                            ((DbParameter)oracleCommand.Parameters[3]).Value = (object)(id + this.m_appID);
                            oracleCommand.Parameters.Add(new OracleParameter("lockCookie", (OracleDbType)112));
                            ((DbParameter)oracleCommand.Parameters[4]).Value = (object)num;
                            ((DbCommand)oracleCommand).ExecuteNonQuery();
                        }
                        else
                        {
                            oracleCommand = new OracleCommand(OracleSessionStateStore.ora_aspnet_Sessn_UpdStateItem_CommandText, connectionHolder.Connection);
                            ((DbCommand)oracleCommand).CommandTimeout = this.m_CommandTimeout;
                            ((DbCommand)oracleCommand).CommandType    = CommandType.Text;
                            oracleCommand.BindByName = true;
                            oracleCommand.Parameters.Add(new OracleParameter("itemShort", (OracleDbType)120, 2000));
                            ((DbParameter)oracleCommand.Parameters[0]).Value = (object)DBNull.Value;
                            if (length <= int.MaxValue)
                            {
                                oracleCommand.Parameters.Add(new OracleParameter("itemLong", (OracleDbType)110));
                                ((DbParameter)oracleCommand.Parameters[1]).Size  = length;
                                ((DbParameter)oracleCommand.Parameters[1]).Value = (object)buffer;
                            }
                            else
                            {
                                oracleCommand.Parameters.Add(new OracleParameter("itemLong", (OracleDbType)102));
                                OracleBlob oracleBlob = new OracleBlob(oracleCommand.Connection, true);
                                ((Stream)oracleBlob).Write(buffer, 0, length);
                                ((DbParameter)oracleCommand.Parameters[1]).Value = (object)oracleBlob;
                            }
                            oracleCommand.Parameters.Add(new OracleParameter("timeout", (OracleDbType)112));
                            ((DbParameter)oracleCommand.Parameters[2]).Value = (object)item.Timeout;
                            oracleCommand.Parameters.Add(new OracleParameter(nameof(id), (OracleDbType)119, OracleSessionStateStore.ID_LENGTH));
                            ((DbParameter)oracleCommand.Parameters[3]).Value = (object)(id + this.m_appID);
                            oracleCommand.Parameters.Add(new OracleParameter("lockCookie", (OracleDbType)112));
                            ((DbParameter)oracleCommand.Parameters[4]).Value = (object)num;
                            ((DbCommand)oracleCommand).ExecuteNonQuery();
                        }
                    }
                    else if (length <= 2000)
                    {
                        oracleCommand = new OracleCommand(OracleSessionStateStore.ora_aspnet_Sessn_InsStateItem_CommandText, connectionHolder.Connection);
                        ((DbCommand)oracleCommand).CommandTimeout = this.m_CommandTimeout;
                        ((DbCommand)oracleCommand).CommandType    = CommandType.Text;
                        oracleCommand.BindByName = true;
                        oracleCommand.Parameters.Add(new OracleParameter(nameof(id), (OracleDbType)119, OracleSessionStateStore.ID_LENGTH));
                        ((DbParameter)oracleCommand.Parameters[0]).Value = (object)(id + this.m_appID);
                        oracleCommand.Parameters.Add(new OracleParameter("itemShort", (OracleDbType)120, 2000));
                        ((DbParameter)oracleCommand.Parameters[1]).Size  = length;
                        ((DbParameter)oracleCommand.Parameters[1]).Value = (object)buffer;
                        oracleCommand.Parameters.Add(new OracleParameter("itemLong", (OracleDbType)102));
                        ((DbParameter)oracleCommand.Parameters[2]).Value = (object)DBNull.Value;
                        oracleCommand.Parameters.Add(new OracleParameter("timeout", (OracleDbType)112));
                        ((DbParameter)oracleCommand.Parameters[3]).Value = (object)item.Timeout;
                        ((DbCommand)oracleCommand).ExecuteNonQuery();
                    }
                    else
                    {
                        oracleCommand = new OracleCommand(OracleSessionStateStore.ora_aspnet_Sessn_InsStateItem_CommandText, connectionHolder.Connection);
                        ((DbCommand)oracleCommand).CommandTimeout = this.m_CommandTimeout;
                        ((DbCommand)oracleCommand).CommandType    = CommandType.Text;
                        oracleCommand.BindByName = true;
                        oracleCommand.Parameters.Add(new OracleParameter(nameof(id), (OracleDbType)119, OracleSessionStateStore.ID_LENGTH));
                        ((DbParameter)oracleCommand.Parameters[0]).Value = (object)(id + this.m_appID);
                        oracleCommand.Parameters.Add(new OracleParameter("itemShort", (OracleDbType)120, 2000));
                        ((DbParameter)oracleCommand.Parameters[1]).Value = (object)DBNull.Value;
                        if (length <= int.MaxValue)
                        {
                            oracleCommand.Parameters.Add(new OracleParameter("itemLong", (OracleDbType)110));
                            ((DbParameter)oracleCommand.Parameters[2]).Size  = length;
                            ((DbParameter)oracleCommand.Parameters[2]).Value = (object)buffer;
                        }
                        else
                        {
                            oracleCommand.Parameters.Add(new OracleParameter("itemLong", (OracleDbType)102));
                            OracleBlob oracleBlob = new OracleBlob(oracleCommand.Connection, true);
                            ((Stream)oracleBlob).Write(buffer, 0, length);
                            ((DbParameter)oracleCommand.Parameters[2]).Value = (object)oracleBlob;
                        }
                        oracleCommand.Parameters.Add(new OracleParameter("timeout", (OracleDbType)112));
                        ((DbParameter)oracleCommand.Parameters[3]).Value = (object)item.Timeout;
                        ((DbCommand)oracleCommand).ExecuteNonQuery();
                    }
                }
                catch (OracleException ex)
                {
                    if (newItem && ex.Number == 1)
                    {
                        return;
                    }
                    throw;
                }
                catch
                {
                    throw;
                }
                finally
                {
                    ((Component)oracleCommand)?.Dispose();
                    connectionHolder?.Close();
                }
            }
Example #15
0
            public override void RemoveItem(
                HttpContext context,
                string id,
                object lockId,
                SessionStateStoreData item)
            {
                int           num           = (int)lockId;
                OracleCommand oracleCommand = (OracleCommand)null;

                try
                {
                    oracleCommand = new OracleCommand("ora_aspnet_Sessn_RmStateItem", OracleConnectionHelper.GetConnection(this.m_OracleConnectionString).Connection);
                    ((DbCommand)oracleCommand).CommandTimeout = this.m_CommandTimeout;
                    ((DbCommand)oracleCommand).CommandType    = CommandType.StoredProcedure;
                    oracleCommand.Parameters.Add(new OracleParameter("OutResult", (OracleDbType)112, ParameterDirection.ReturnValue));
                    ((DbParameter)oracleCommand.Parameters[0]).DbType = DbType.Int32;
                    oracleCommand.Parameters.Add(new OracleParameter(nameof(id), (OracleDbType)119, OracleSessionStateStore.ID_LENGTH));
                    ((DbParameter)oracleCommand.Parameters[1]).Value = (object)(id + this.m_appID);
                    oracleCommand.Parameters.Add(new OracleParameter("lockCookie", (OracleDbType)112));
                    ((DbParameter)oracleCommand.Parameters[2]).Value = (object)num;
                    ((DbCommand)oracleCommand).ExecuteNonQuery();
                }
                catch
                {
                    throw;
                }
                finally
                {
                    ((Component)oracleCommand)?.Dispose();
                }
            }
Example #16
0
        void CreateSchema(OracleAQInitializationOptions options)
        {
            using (var connection = _connectionHelper.GetConnection())
            {
                var tableNames = connection.GetTableNames();

                if (tableNames.Contains(options.TableName, StringComparer.OrdinalIgnoreCase))
                {
                    _log.Info("Database already contains a table named {tableName} - will not create anything", options.TableName);
                    return;
                }

                _log.Info("Table {tableName} does not exist - it will be created with the queue now", options.TableName);

                ExecuteCommands(connection, $@"
                     DECLARE
                        v_count NUMBER(10);
                    BEGIN
                        SELECT COUNT(*) INTO v_count
                        FROM user_objects
                        WHERE 
                             object_type = 'TYPE'
                         AND UPPER(object_name) = 'REBUS_MESSAGE_V2';

                        IF v_count = 0 THEN
                            EXECUTE IMMEDIATE 'CREATE OR REPLACE TYPE REBUS_MSG_HEADER AS OBJECT (
                                           KEY VARCHAR2(4000),
                                           VALUE VARCHAR2(4000)
                                        );';

                            EXECUTE IMMEDIATE 'CREATE OR REPLACE TYPE REBUS_MSG_HEADERS IS VARRAY(100) OF REBUS_MSG_HEADER NOT NULL;';


                            EXECUTE IMMEDIATE 'create or replace type REBUS_MESSAGE_V2 as object
                                                (
                                                      HEADERS         REBUS_MSG_HEADERS,                                           
                                                      BODY_RAW        RAW(2000),
                                                      BODY_BLOB       BLOB,
                                                      MEMBER FUNCTION ContainsHeader(p_header_key VARCHAR2) RETURN NUMBER,
                                                      MEMBER FUNCTION GetHeaderValue(p_header_key VARCHAR2)RETURN VARCHAR2
                                                );';
                                                
                            EXECUTE IMMEDIATE 'create or replace type body REBUS_MESSAGE_V2 is
  
                                                  -- Member procedures and functions
                                                  MEMBER FUNCTION ContainsHeader(p_header_key VARCHAR2) RETURN NUMBER
                                                  IS
                                                  BEGIN
                                                    FOR i IN 1..HEADERS.Count LOOP
                                                      BEGIN
                                                        IF HEADERS(i).KEY = p_header_key
                                                        THEN
                                                          RETURN 1;
                                                        END IF;
                                                      END;
                                                    END LOOP;
         
                                                    RETURN 0;
                                                  END; 
  
                                                  MEMBER FUNCTION GetHeaderValue(p_header_key VARCHAR2)RETURN VARCHAR2
                                                  IS        
                                                  BEGIN
    
                                                    FOR i IN 1..HEADERS.Count LOOP
                                                      BEGIN
                                                        IF HEADERS(i).KEY = p_header_key
                                                        THEN
                                                          RETURN HEADERS(i).VALUE;
                                                        END IF;
                                                      END;
                                                    END LOOP;
        
                                                    RETURN NULL;
                                                  END; 
  
                                                end;';
                                                
                            EXECUTE IMMEDIATE 'create or replace package PKG_REBUS is
                                                  TYPE VARCHAR2_ARRAY IS TABLE OF VARCHAR2(4000)  -- Associative array type
                                                       INDEX BY PLS_INTEGER;      

                                                  PROCEDURE P_Enqueue_Rebus_Msg
                                                  (
                                                       p_Queue_Name         IN    VARCHAR2,
                                                       p_EO_Visibility      IN    BINARY_INTEGER,       
                                                       p_EO_Transformation  IN    VARCHAR2,
                                                       p_EO_Delivery_Mode   IN    PLS_INTEGER,
                                                       p_MP_Priority        IN    BINARY_INTEGER,
                                                       p_MP_Delay           IN    BINARY_INTEGER,
                                                       p_MP_Expiration      IN    BINARY_INTEGER,
                                                       p_Headers_Keys       IN    VARCHAR2_ARRAY,
                                                       p_Headers_Values     IN    VARCHAR2_ARRAY,
                                                       p_Body_Raw           IN    RAW,
                                                       p_Body_Blob          IN    BLOB
                                                  );
  
                                                  PROCEDURE P_Dequeue_Rebus_Msg
                                                  (
                                                       p_Queue_Name         IN    VARCHAR2,
                                                       p_DO_Consumers_Names IN    VARCHAR2_ARRAY,
                                                       p_DO_Visibility      IN    BINARY_INTEGER,
                                                       p_DO_Wait            IN    BINARY_INTEGER, 
                                                       p_DO_Transformation  IN    VARCHAR2,
                                                       p_DO_Delivery_Mode   IN    PLS_INTEGER,       
                                                       p_Headers_Keys       OUT   VARCHAR2_ARRAY,
                                                       p_Headers_Values     OUT   VARCHAR2_ARRAY,
                                                       p_Body_Raw           OUT   RAW,
                                                       p_Body_Blob          OUT   BLOB
                                                   );

                                                end PKG_REBUS; ';
                                                
                            EXECUTE IMMEDIATE 'create or replace package body PKG_REBUS is

                                                   PROCEDURE P_Enqueue_Rebus_Msg
                                                   (
                                                       p_Queue_Name         IN    VARCHAR2,
                                                       p_EO_Visibility      IN    BINARY_INTEGER,       
                                                       p_EO_Transformation  IN    VARCHAR2,
                                                       p_EO_Delivery_Mode   IN    PLS_INTEGER,
                                                       p_MP_Priority        IN    BINARY_INTEGER,
                                                       p_MP_Delay           IN    BINARY_INTEGER,
                                                       p_MP_Expiration      IN    BINARY_INTEGER,
                                                       p_Headers_Keys       IN    VARCHAR2_ARRAY,
                                                       p_Headers_Values     IN    VARCHAR2_ARRAY,
                                                       p_Body_Raw           IN    RAW,
                                                       p_Body_Blob          IN    BLOB
                                                   ) IS
                                                      v_Enqueue_Options     dbms_aq.enqueue_options_t;
                                                      v_Message_Properties  dbms_aq.message_properties_t;
                                                      v_message_handle      RAW(16);
                                                      v_headers             rebus_msg_headers;
                                                   BEGIN
                                                      v_Enqueue_Options.visibility      := p_EO_Visibility;
                                                      v_Enqueue_Options.delivery_mode   := p_EO_Delivery_Mode;
                                                      v_Enqueue_Options.transformation  := p_EO_Transformation;

                                                      v_Message_Properties.priority     := p_MP_Priority;
                                                      v_Message_Properties.delay        := p_MP_Delay;
                                                      v_Message_Properties.expiration   := p_MP_Expiration;
        
                                                      v_headers                         := rebus_msg_headers();
                                                      v_headers.extend(p_Headers_Keys.count);

                                                      FOR i IN 1..p_Headers_Keys.count LOOP
                                                        v_headers(i) := rebus_msg_header(p_Headers_Keys(i), p_Headers_Values(i));
                                                      END LOOP;                    

                                                      DBMS_AQ.ENQUEUE(
                                                          QUEUE_NAME => p_Queue_Name,
                                                          ENQUEUE_OPTIONS => v_Enqueue_Options,
                                                          MESSAGE_PROPERTIES => v_Message_Properties,
                                                          PAYLOAD => new REBUS_MESSAGE_V2(v_headers, p_Body_Raw, p_Body_Blob),
                                                          MSGID => v_message_handle);
                                                   END P_Enqueue_Rebus_Msg;
   
                                                   PROCEDURE P_Dequeue_Rebus_Msg
                                                   (
                                                       p_Queue_Name         IN    VARCHAR2,
                                                       p_DO_Consumers_Names IN    VARCHAR2_ARRAY,
                                                       p_DO_Visibility      IN    BINARY_INTEGER,
                                                       p_DO_Wait            IN    BINARY_INTEGER, 
                                                       p_DO_Transformation  IN    VARCHAR2,
                                                       p_DO_Delivery_Mode   IN    PLS_INTEGER,       
                                                       p_Headers_Keys       OUT   VARCHAR2_ARRAY,
                                                       p_Headers_Values     OUT   VARCHAR2_ARRAY,
                                                       p_Body_Raw           OUT   RAW,
                                                       p_Body_Blob          OUT   BLOB
                                                   ) IS
                                                      v_Dequeue_Options     dbms_aq.DEQUEUE_OPTIONS_T;
                                                      v_Message_Properties  dbms_aq.message_properties_t;
                                                      v_Message_Handle      RAW(16);
                                                      v_Payload             REBUS_MESSAGE_V2;
                                                      v_Agent_List          DBMS_AQ.AQ$_AGENT_LIST_T;
                                                      v_Agent               SYS.AQ$_AGENT;
                                                   BEGIN
                                                      v_Dequeue_Options.visibility      := p_DO_Visibility;
                                                      v_Dequeue_Options.delivery_mode   := p_DO_Delivery_Mode;
                                                      v_Dequeue_Options.transformation  := p_DO_Transformation;
                                                      v_Dequeue_Options.WAIT            := p_DO_Wait;
                                                      v_Dequeue_Options.NAVIGATION      := DBMS_AQ.FIRST_MESSAGE;
    
                                                      IF p_DO_Consumers_Names IS NULL OR 
                                                         p_DO_Consumers_Names.count = 0 OR 
                                                         p_DO_Consumers_Names(1) IS NULL 
                                                      THEN
                                                        DBMS_AQ.DEQUEUE(
                                                            QUEUE_NAME => p_Queue_Name,
                                                            DEQUEUE_OPTIONS => v_Dequeue_Options,
                                                            MESSAGE_PROPERTIES => v_Message_Properties,
                                                            PAYLOAD => v_Payload,
                                                            MSGID => v_Message_Handle);
    
                                                        FOR i IN 1..v_Payload.HEADERS.count LOOP
                                                          p_Headers_Keys(i) := v_Payload.HEADERS(i).KEY;
                                                          p_Headers_Values(i) := v_Payload.HEADERS(i).VALUE;
                                                        END LOOP;  
                                                
                                                        p_Body_Raw       := v_Payload.BODY_RAW;
                                                        p_Body_Blob      := v_Payload.BODY_BLOB;
                                                      ELSE      
                                                        FOR i IN 1..p_DO_Consumers_Names.count LOOP
                                                          v_Agent_List(i) := SYS.AQ$_AGENT(p_DO_Consumers_Names(i), p_Queue_Name, NULL);
                                                        END LOOP;         

                                                        DBMS_AQ.LISTEN (
                                                            agent_list => v_Agent_List,
                                                            wait => p_DO_Wait,
                                                            agent => v_Agent);
      
                                                        IF v_Agent IS NOT NULL 
                                                        THEN
                                                          v_Dequeue_Options.CONSUMER_NAME   := v_Agent.name;
                            
                                                          DBMS_AQ.DEQUEUE(
                                                              QUEUE_NAME => p_Queue_Name,
                                                              DEQUEUE_OPTIONS => v_Dequeue_Options,
                                                              MESSAGE_PROPERTIES => v_Message_Properties,
                                                              PAYLOAD => v_Payload,
                                                              MSGID => v_Message_Handle);
        
                                                          FOR i IN 1..v_Payload.HEADERS.count LOOP
                                                            p_Headers_Keys(i) := v_Payload.HEADERS(i).KEY;
                                                            p_Headers_Values(i) := v_Payload.HEADERS(i).VALUE;
                                                          END LOOP;  
        
                                                          p_Headers_Keys(v_Payload.HEADERS.count + 1) := ''rbs2-consumer-name'';
                                                          p_Headers_Values(v_Payload.HEADERS.count + 1) := v_Agent.name;
                                                                
                                                          p_Body_Raw       := v_Payload.BODY_RAW;
                                                          p_Body_Blob      := v_Payload.BODY_BLOB;
                                                        END IF;     
                                                      END IF;
                                                   EXCEPTION 
                                                     WHEN OTHERS THEN
                                                      IF SQLCODE = -25228 --ORA-25228 Timeout or End-of-Fetch Error When Dequeuing Messages
                                                         OR SQLCODE = -25254 --ORA-25254: time-out in LISTEN while waiting for a message
                                                      THEN      
                                                        p_Body_Raw         := NULL;
                                                        p_Body_Blob        := NULL;
                                                      ELSE
                                                         RAISE;
                                                      END IF;    
                                                   END P_Dequeue_Rebus_Msg;
  
                                                end PKG_REBUS;';                    
                         
                        END IF;
                    END;
                    ----
                    BEGIN
                    -- Call the procedure
                        sys.dbms_aqadm.create_queue_table(queue_table => '{options.TableName}',
                                                        queue_payload_type => 'REBUS_MESSAGE_V2', 
                                                        primary_instance => 1);
                                    
                        sys.dbms_aqadm.create_queue(queue_name => '{options.InputQueueName}',
                                                    queue_table => '{options.TableName}',
                                                    max_retries => 10, 
                                                    retry_delay => 3);

                        sys.dbms_aqadm.start_queue(queue_name => '{options.InputQueueName}');
                    END;
                ");

                connection.Complete();
            }
        }