Class: DbMeta::Oracle::Queue

Inherits:
Base
  • Object
show all
Defined in:
lib/db_meta/oracle/types/queue.rb

Constant Summary

Constants inherited from Base

Base::TYPES

Instance Attribute Summary collapse

Attributes inherited from Base

#extract_type, #name, #status, #system_object, #type

Instance Method Summary collapse

Methods inherited from Base

from_type, #initialize, register_type, #system_object?

Methods included from Helper

#block, #create_folder, #pluralize, #remove_folder, #type_sequence, #write_buffer_to_file

Constructor Details

This class inherits a constructor from DbMeta::Oracle::Base

Instance Attribute Details

#compatibleObject (readonly)

Returns the value of attribute compatible.



6
7
8
# File 'lib/db_meta/oracle/types/queue.rb', line 6

def compatible
  @compatible
end

#max_retriesObject (readonly)

Returns the value of attribute max_retries.



6
7
8
# File 'lib/db_meta/oracle/types/queue.rb', line 6

def max_retries
  @max_retries
end

#payload_typeObject (readonly)

Returns the value of attribute payload_type.



6
7
8
# File 'lib/db_meta/oracle/types/queue.rb', line 6

def payload_type
  @payload_type
end

#queue_tableObject (readonly)

Returns the value of attribute queue_table.



6
7
8
# File 'lib/db_meta/oracle/types/queue.rb', line 6

def queue_table
  @queue_table
end

#queue_typeObject (readonly)

Returns the value of attribute queue_type.



6
7
8
# File 'lib/db_meta/oracle/types/queue.rb', line 6

def queue_type
  @queue_type
end

#retry_delayObject (readonly)

Returns the value of attribute retry_delay.



6
7
8
# File 'lib/db_meta/oracle/types/queue.rb', line 6

def retry_delay
  @retry_delay
end

#sort_orderObject (readonly)

Returns the value of attribute sort_order.



6
7
8
# File 'lib/db_meta/oracle/types/queue.rb', line 6

def sort_order
  @sort_order
end

Instance Method Details

#ddl_dropObject



59
60
61
62
63
64
65
66
67
68
69
# File 'lib/db_meta/oracle/types/queue.rb', line 59

def ddl_drop
  buffer = []
  buffer << "begin"
  buffer << "  dbms_aqadm.stop_queue('#{@name}');"
  buffer << "  dbms_aqadm.stop_queue('AQ$_#{@queue_table}_E');"
  buffer << "  dbms_aqadm.drop_queue(queue_name => '#{@name}');"
  buffer << "  dbms_aqadm.drop_queue_table(queue_table => '#{@queue_table}', force => true);"
  buffer << "end;"
  buffer << "/"
  buffer.join("\n")
end

#extract(args = {}) ⇒ Object



30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
# File 'lib/db_meta/oracle/types/queue.rb', line 30

def extract(args = {})
  buffer = [block(@name)]

  buffer << "begin"
  buffer << "  dbms_aqadm.create_queue_table("
  buffer << "    queue_table => '#{@queue_table}',"
  buffer << "    queue_payload_type => '#{@payload_type}',"
  buffer << "    sort_list => '#{sort_order_translated}',"
  buffer << "    compatible => '#{@compatible}'"
  buffer << "  );"
  buffer << "end;"
  buffer << "/"
  buffer << nil

  buffer << "begin"
  buffer << "  dbms_aqadm.create_queue("
  buffer << "    queue_name => '#{@name}',"
  buffer << "    queue_table => '#{@queue_table}',"
  buffer << "    max_retries => #{@max_retries},"
  buffer << "    retry_delay => #{@retry_delay}"
  buffer << "  );"
  buffer << "  dbms_aqadm.start_queue('#{@name}');"
  buffer << "  dbms_aqadm.start_queue('AQ$_#{@queue_table}_E', false, true);"
  buffer << "end;"
  buffer << "/"
  buffer << nil
  buffer.join("\n")
end

#fetchObject



8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
# File 'lib/db_meta/oracle/types/queue.rb', line 8

def fetch
  connection = Connection.instance.get
  cursor = connection.exec("select * from user_queues where name = '#{@name}'")
  cursor.fetch_hash do |row|
    @queue_table = row["QUEUE_TABLE"]
    @queue_type = row["QUEUE_TYPE"]
    @max_retries = row["MAX_RETRIES"].to_i
    @retry_delay = row["RETRY_DELAY"].to_f
  end
  cursor.close

  cursor = connection.exec("select * from user_queue_tables where queue_table = '#{@queue_table}'")
  cursor.fetch_hash do |row|
    @payload_type = row["OBJECT_TYPE"]
    @sort_order = row["SORT_ORDER"]
    @compatible = row["COMPATIBLE"]
  end
  cursor.close
ensure
  connection.logoff
end