[Home] [Help]
PACKAGE BODY: APPS.ARP_QUEUE
Source
1 PACKAGE BODY arp_queue AS
2 -- $Header: ARPQUEFB.pls 115.9 2003/10/10 14:25:45 mraymond ship $
3
4 g_nq_opts DBMS_AQ.ENQUEUE_OPTIONS_T;
5 g_dq_opts DBMS_AQ.DEQUEUE_OPTIONS_T;
6 g_recipients DBMS_AQ.AQ$_RECIPIENT_LIST_T;
7 g_msg_id RAW(16);
8 g_full_qname VARCHAR2(61);
9
10 l_no_more_msgs EXCEPTION;
11 PRAGMA EXCEPTION_INIT(l_no_more_msgs, -25228);
12
13 /*=========================================================================+
14 | Enqueue the message in the queue |
15 +=========================================================================*/
16
17 PG_DEBUG varchar2(1) := NVL(FND_PROFILE.value('AFLOG_ENABLED'), 'N');
18
19 PROCEDURE enqueue (p_msg IN system.AR_REV_REC_TYP) AS
20
21 trx_with_no_rules EXCEPTION;
22 l_msg system.AR_REV_REC_TYP := p_msg;
23 l_msg_prop DBMS_AQ.MESSAGE_PROPERTIES_T;
24
25 BEGIN
26
27 --
28 arp_util.print_fcn_label('arp_queue.enqueue()+');
29 --
30 -- Create a message to enqueue.
31
32 l_msg_prop.recipient_list := g_recipients;
33
34 IF PG_DEBUG in ('Y', 'C') THEN
35 arp_standard.debug('enqueue: ' || '> Processing Trx number : <' || p_msg.trx_number || '> Trx Id <' ||
36 p_msg.customer_trx_id || '> Created From : <' || p_msg.created_from || ' ' ||p_msg.org_id );
37 END IF;
38
39 -- Enqueue it with the default options.
40 DBMS_AQ.ENQUEUE(
41 queue_name => get_full_qname('AR_REV_REC_Q'),
42 enqueue_options => g_nq_opts,
43 message_properties => l_msg_prop,
44 payload => l_msg,
45 msgid => g_msg_id);
46
47 --
48 arp_util.print_fcn_label('arp_queue.enqueue()-');
49 --
50 EXCEPTION
51 WHEN trx_with_no_rules THEN
52 NULL;
53 WHEN OTHERS THEN
54 RAISE;
55 END enqueue;
56
57 /*=========================================================================+
58 | Dequeue the message from the queue |
59 +=========================================================================*/
60
61 PROCEDURE dequeue (p_msg IN OUT NOCOPY system.AR_REV_REC_TYP,
62 p_browse IN BOOLEAN := FALSE,
63 p_wait IN INTEGER := DBMS_AQ.NO_WAIT,
64 p_first IN BOOLEAN := FALSE) AS
65
66 l_msg_prop DBMS_AQ.MESSAGE_PROPERTIES_T;
67
68 l_no_more_msgs EXCEPTION;
69 PRAGMA EXCEPTION_INIT(l_no_more_msgs, -25228);
70
71 BEGIN
72
73 -- Set the dequeue mode based on the i/p parameter
74 --
75 arp_util.print_fcn_label('arp_queue.dequeue()+');
76 --
77
78 IF p_browse THEN
79 g_dq_opts.dequeue_mode := DBMS_AQ.BROWSE;
80 ELSE
81 g_dq_opts.dequeue_mode := DBMS_AQ.REMOVE;
82 END IF;
83
84 IF p_first THEN
85 g_dq_opts.navigation := DBMS_AQ.FIRST_MESSAGE; --- Get the First available message
86 ELSE
87 g_dq_opts.navigation := DBMS_AQ.NEXT_MESSAGE; --- Get the Next available message
88 END IF;
89
90 g_dq_opts.wait := p_wait;
91 g_dq_opts.consumer_name := consumer_name;
92 g_dq_opts.visibility := DBMS_AQ.IMMEDIATE;
93 --
94 DBMS_AQ.DEQUEUE(
95 queue_name => get_full_qname('AR_REV_REC_Q'),
96 dequeue_options => g_dq_opts,
97 message_properties => l_msg_prop,
98 payload => p_msg,
99 msgid => g_msg_id);
100
101 --
102 arp_util.print_fcn_label('arp_queue.dequeue()-');
103 --
104 EXCEPTION
105 WHEN l_no_more_msgs THEN
106 RAISE;
107 WHEN OTHERS THEN
108 RAISE;
109 END dequeue;
110 --
111 /*=========================================================================+
112 | Get the full Queue name based on the product schema |
113 +=========================================================================*/
114
115 FUNCTION get_full_qname(p_qname IN VARCHAR2) RETURN VARCHAR2 AS
116
117 l_schema varchar2(30);
118 l_status varchar2(1);
119 l_industry varchar2(1);
120
121 BEGIN
122
123 arp_util.print_fcn_label('arp_queue.get_full_qname()+');
124
125 /* Bug 2133254 - Check to see if global is null before
126 executing fnd_installation call */
127
128 IF (g_full_qname IS NULL) THEN
129 IF (fnd_installation.get_app_info('AR', l_status, l_industry, l_schema)) THEN
130
131 g_full_qname := l_schema||'.'|| p_qname;
132 ELSE
133 raise_application_error(-20000,
134 'Failed to get information for product '||
135 'AR');
136 END IF;
137 END IF;
138
139 --
140 arp_util.print_fcn_label('arp_queue.get_full_qname()-');
141 --
142 RETURN g_full_qname;
143 END get_full_qname;
144
145 BEGIN
146 --
147 -- Using the consumers to separate the org specific request from the queue
148 --
149 --
150 arp_util.print_fcn_label('arp_queue()+');
151 --
152 consumer_name := 'AGENT_' || NVL(arp_global.sysparam.org_id, 0);
153 --
154 g_recipients(1) := sys.aq$_agent(consumer_name,
155 null, null) ;
156 --
157 arp_util.print_fcn_label('arp_queue()-');
158 --
159
160 END;