1: package body WF_EVENT_QH as
2: /* $Header: wfquhndb.pls 120.1.12000000.2 2007/07/03 04:03:38 sstomar ship $ */
3: ------------------------------------------------------------------------------
4: PROCEDURE dequeue(p_agent_guid in raw,
5: p_event out nocopy wf_event_t,
1: package body WF_EVENT_QH as
2: /* $Header: wfquhndb.pls 120.1.12000000.2 2007/07/03 04:03:38 sstomar ship $ */
3: ------------------------------------------------------------------------------
4: PROCEDURE dequeue(p_agent_guid in raw,
5: p_event out nocopy wf_event_t,
6: p_wait in binary_integer default dbms_aq.no_wait)
7: is
8: x_queue_name varchar2(80);
9: x_agent_name varchar2(30);
23: where guid = p_agent_guid;
24:
25: if (wf_log_pkg.level_procedure >= fnd_log.g_current_runtime_level) then
26: wf_log_pkg.string(wf_log_pkg.level_procedure,
27: 'wf.plsql.WF_EVENT_QH.dequeue.Begin',
28: 'Dequeuing '||x_queue_name||' on '||x_agent_name);
29: end if;
30:
31: -- Set correlation Id for dequeue if only available and not '%'
28: 'Dequeuing '||x_queue_name||' on '||x_agent_name);
29: end if;
30:
31: -- Set correlation Id for dequeue if only available and not '%'
32: if (wf_event.g_correlation is not null and wf_event.g_correlation <> '%') then
33: -- Seeded agent with this queue handler
34: if (x_agent_name like 'WF_%') then
35: if (wf_event.account_name is null) then
36: wf_event.SetAccountName;
31: -- Set correlation Id for dequeue if only available and not '%'
32: if (wf_event.g_correlation is not null and wf_event.g_correlation <> '%') then
33: -- Seeded agent with this queue handler
34: if (x_agent_name like 'WF_%') then
35: if (wf_event.account_name is null) then
36: wf_event.SetAccountName;
37: end if;
38: x_dequeue_options.correlation := wf_event.account_name || ':' || wf_event.g_correlation;
39: else
32: if (wf_event.g_correlation is not null and wf_event.g_correlation <> '%') then
33: -- Seeded agent with this queue handler
34: if (x_agent_name like 'WF_%') then
35: if (wf_event.account_name is null) then
36: wf_event.SetAccountName;
37: end if;
38: x_dequeue_options.correlation := wf_event.account_name || ':' || wf_event.g_correlation;
39: else
40: x_dequeue_options.correlation := wf_event.g_correlation;
34: if (x_agent_name like 'WF_%') then
35: if (wf_event.account_name is null) then
36: wf_event.SetAccountName;
37: end if;
38: x_dequeue_options.correlation := wf_event.account_name || ':' || wf_event.g_correlation;
39: else
40: x_dequeue_options.correlation := wf_event.g_correlation;
41: end if;
42: end if;
36: wf_event.SetAccountName;
37: end if;
38: x_dequeue_options.correlation := wf_event.account_name || ':' || wf_event.g_correlation;
39: else
40: x_dequeue_options.correlation := wf_event.g_correlation;
41: end if;
42: end if;
43:
44: if (wf_log_pkg.level_procedure >= fnd_log.g_current_runtime_level) then
41: end if;
42: end if;
43:
44: if (wf_log_pkg.level_procedure >= fnd_log.g_current_runtime_level) then
45: if (wf_event.g_correlation is not null) then
46: wf_log_pkg.string(wf_log_pkg.level_procedure,
47: 'wf.plsql.WF_EVENT_QH.dequeue.corrid',
48: 'Dequeuing with Correlation ' || x_dequeue_options.correlation);
49: else
43:
44: if (wf_log_pkg.level_procedure >= fnd_log.g_current_runtime_level) then
45: if (wf_event.g_correlation is not null) then
46: wf_log_pkg.string(wf_log_pkg.level_procedure,
47: 'wf.plsql.WF_EVENT_QH.dequeue.corrid',
48: 'Dequeuing with Correlation ' || x_dequeue_options.correlation);
49: else
50: wf_log_pkg.string(wf_log_pkg.level_procedure,
51: 'wf.plsql.WF_EVENT_QH.dequeue.corrid',
47: 'wf.plsql.WF_EVENT_QH.dequeue.corrid',
48: 'Dequeuing with Correlation ' || x_dequeue_options.correlation);
49: else
50: wf_log_pkg.string(wf_log_pkg.level_procedure,
51: 'wf.plsql.WF_EVENT_QH.dequeue.corrid',
52: 'Dequeuing with No Correlation');
53: end if;
54: end if;
55:
52: 'Dequeuing with No Correlation');
53: end if;
54: end if;
55:
56: if ((WF_EVENT.g_queueType is NULL) or
57: (WF_EVENT.g_queueType <> 'EXCEPTION_QUEUE')) then
58: x_dequeue_options.consumer_name := x_agent_name;
59: end if;
60:
53: end if;
54: end if;
55:
56: if ((WF_EVENT.g_queueType is NULL) or
57: (WF_EVENT.g_queueType <> 'EXCEPTION_QUEUE')) then
58: x_dequeue_options.consumer_name := x_agent_name;
59: end if;
60:
61: -- This functionality is dependent on 9i, so it cannot be uncommented in this
60:
61: -- This functionality is dependent on 9i, so it cannot be uncommented in this
62: -- file until 9i is the minimum rdbms on both e-business suite and iAS.
63: --
64: -- if (WF_EVENT.g_deq_condition is not NULL) then
65: -- x_dequeue_options.deq_condition := WF_EVENT.g_deq_condition;
66: --
67: -- end if;
68: --
61: -- This functionality is dependent on 9i, so it cannot be uncommented in this
62: -- file until 9i is the minimum rdbms on both e-business suite and iAS.
63: --
64: -- if (WF_EVENT.g_deq_condition is not NULL) then
65: -- x_dequeue_options.deq_condition := WF_EVENT.g_deq_condition;
66: --
67: -- end if;
68: --
69:
67: -- end if;
68: --
69:
70: x_dequeue_options.wait := p_wait;
71: x_dequeue_options.navigation := wf_event.navigation;
72:
73:
74: BEGIN
75: DBMS_AQ.DEQUEUE(queue_name => x_queue_name,
77: message_properties => x_message_properties, /* OUT */
78: payload => p_event, /* OUT */
79: msgid => x_msgid); /* OUT */
80:
81: wf_event.navigation := dbms_aq.next_message;
82: EXCEPTION
83: when no_messages then
84: if (wf_log_pkg.level_event >= fnd_log.g_current_runtime_level) then
85: wf_log_pkg.string(wf_log_pkg.level_event,
82: EXCEPTION
83: when no_messages then
84: if (wf_log_pkg.level_event >= fnd_log.g_current_runtime_level) then
85: wf_log_pkg.string(wf_log_pkg.level_event,
86: 'wf.plsql.WF_EVENT_QH.dequeue.queue_empty',
87: 'No more messages in dequeue.');
88: end if;
89:
90: wf_event.navigation := dbms_aq.first_message;
86: 'wf.plsql.WF_EVENT_QH.dequeue.queue_empty',
87: 'No more messages in dequeue.');
88: end if;
89:
90: wf_event.navigation := dbms_aq.first_message;
91: p_event := NULL;
92: return;
93: --Capture the snapshot too old error
94: when snap_too_old then
94: when snap_too_old then
95: --Workaround for AQ when receiving ORA-01555 using NEXT_MESSAGE as
96: --navigation. We will try to set to FIRST_MESSAGE and dequeue to
97: --silently handle this exception.
98: if (wf_event.navigation = dbms_aq.FIRST_MESSAGE) then
99: raise;
100: else
101: -- if wf_dequeue is called indivudiually, we should return the event.
102: -- because the consumer doesn't know the navigation_option.
99: raise;
100: else
101: -- if wf_dequeue is called indivudiually, we should return the event.
102: -- because the consumer doesn't know the navigation_option.
103: wf_event.navigation := dbms_aq.FIRST_MESSAGE;
104: x_dequeue_options.navigation := wf_event.navigation ;
105: DBMS_AQ.DEQUEUE(queue_name => x_queue_name,
106: dequeue_options => x_dequeue_options,
107: message_properties => x_message_properties, /* OUT */
100: else
101: -- if wf_dequeue is called indivudiually, we should return the event.
102: -- because the consumer doesn't know the navigation_option.
103: wf_event.navigation := dbms_aq.FIRST_MESSAGE;
104: x_dequeue_options.navigation := wf_event.navigation ;
105: DBMS_AQ.DEQUEUE(queue_name => x_queue_name,
106: dequeue_options => x_dequeue_options,
107: message_properties => x_message_properties, /* OUT */
108: payload => p_event, /* OUT */
109: msgid => x_msgid); /* OUT */
110:
111:
112: --Now set the navigation to next message
113: wf_event.navigation := dbms_aq.next_message;
114: end if;
115: when others then
116: wf_event.navigation := dbms_aq.FIRST_MESSAGE;
117: raise;
112: --Now set the navigation to next message
113: wf_event.navigation := dbms_aq.next_message;
114: end if;
115: when others then
116: wf_event.navigation := dbms_aq.FIRST_MESSAGE;
117: raise;
118: END;
119:
120: -- Set the Receive Date
120: -- Set the Receive Date
121: p_event.SetReceiveDate(sysdate);
122: if (wf_log_pkg.level_procedure >= fnd_log.g_current_runtime_level) then
123: wf_log_pkg.string(wf_log_pkg.level_procedure,
124: 'wf.plsql.WF_EVENT_QH.dequeue.End',
125: 'Finished');
126: end if;
127: exception
128: when others then
125: 'Finished');
126: end if;
127: exception
128: when others then
129: Wf_Core.Context('Wf_Event_QH', 'Dequeue', x_queue_name,
130: 'SQL err is '||substr(sqlerrm,1,200));
131: raise;
132: end dequeue;
133: ------------------------------------------------------------------------------
130: 'SQL err is '||substr(sqlerrm,1,200));
131: raise;
132: end dequeue;
133: ------------------------------------------------------------------------------
134: PROCEDURE enqueue(p_event in wf_event_t,
135: p_out_agent_override in wf_agent_t default null)
136: is
137: x_out_agent_name varchar2(30);
138: x_out_system_name varchar2(30);
190: -- Determine the to queue (if set) --
191: -- If there is a to queue, need to set recipient list address --
192: if (p_event.To_Agent is not null) AND
193: (x_out_agent_name <> 'WF_DEFERRED') then
194: WF_EVENT.Set_Recipient_List(p_event,
195: x_out_agent_name ,
196: x_out_system_name,
197: x_message_properties);
198: end if;
207: */
208: if (p_event.Send_Date > sysdate) then
209: if (wf_log_pkg.level_statement >= fnd_log.g_current_runtime_level) then
210: wf_log_pkg.string(wf_log_pkg.level_statement,
211: 'wf.plsql.WF_EVENT_QH.enqueue.delay',
212: 'Delay Detected');
213: end if;
214:
215: delay := (p_event.Send_Date - sysdate) *24*60*60;
215: delay := (p_event.Send_Date - sysdate) *24*60*60;
216:
217: if (wf_log_pkg.level_statement >= fnd_log.g_current_runtime_level) then
218: wf_log_pkg.string(wf_log_pkg.level_statement,
219: 'wf.plsql.WF_EVENT_QH.enqueue.delay_time',
220: 'Delay ='||to_char(delay));
221: end if;
222:
223: if delay > 1 then
236: ** into the correlation id
237: */
238: if (x_out_agent_name like 'WF_%'
239: or x_to_agent_name like 'WF_%') then
240: if wf_event.account_name is null then
241: wf_event.SetAccountName;
242: end if;
243: x_message_properties.correlation := wf_event.account_name;
244: end if;
237: */
238: if (x_out_agent_name like 'WF_%'
239: or x_to_agent_name like 'WF_%') then
240: if wf_event.account_name is null then
241: wf_event.SetAccountName;
242: end if;
243: x_message_properties.correlation := wf_event.account_name;
244: end if;
245: if (x_out_agent_name = 'WF_DEFERRED'
239: or x_to_agent_name like 'WF_%') then
240: if wf_event.account_name is null then
241: wf_event.SetAccountName;
242: end if;
243: x_message_properties.correlation := wf_event.account_name;
244: end if;
245: if (x_out_agent_name = 'WF_DEFERRED'
246: or x_to_agent_name = 'WF_DEFERRED') then
247: --Bug 2505492
266: end if;
267: END IF;
268: if (wf_log_pkg.level_statement >= fnd_log.g_current_runtime_level) then
269: wf_log_pkg.string(wf_log_pkg.level_statement,
270: 'wf.plsql.WF_EVENT_QH.enqueue.dbms_aq',
271: 'calling dbms_aq.enqueue');
272: end if;
273:
274: DBMS_AQ.ENQUEUE(
278: payload => p_event,
279: msgid => x_msgid); /* OUT*/
280:
281: --
282: WF_EVENT.g_msgid := x_msgid;
283:
284: if (wf_log_pkg.level_procedure >= fnd_log.g_current_runtime_level) then
285: wf_log_pkg.string(wf_log_pkg.level_procedure,
286: 'wf.plsql.WF_EVENT_QH.enqueue.End',
282: WF_EVENT.g_msgid := x_msgid;
283:
284: if (wf_log_pkg.level_procedure >= fnd_log.g_current_runtime_level) then
285: wf_log_pkg.string(wf_log_pkg.level_procedure,
286: 'wf.plsql.WF_EVENT_QH.enqueue.End',
287: 'finished calling dbms_aq.enqueue');
288: end if;
289:
290: exception
288: end if;
289:
290: exception
291: when others then
292: Wf_Core.Context('Wf_Event_QH', 'Enqueue', x_out_queue,
293: 'SQL err is '||substr(sqlerrm,1,200));
294: raise;
295: end enqueue;
296: ------------------------------------------------------------------------------
293: 'SQL err is '||substr(sqlerrm,1,200));
294: raise;
295: end enqueue;
296: ------------------------------------------------------------------------------
297: end WF_EVENT_QH;