1 PACKAGE BODY fnd_cp_opp_cmd AS
2 /* $Header: AFCPOPCB.pls 120.2.12010000.2 2009/10/30 19:25:25 smadhapp ship $ */
3
4
5 ICM_ID constant varchar2(8) := 'FNDICM';
6 OPP_ID constant varchar2(8) := 'FNDOPP';
7 OPP_PACKAGE constant varchar2(30) := 'oracle.apps.fnd.cp.opp';
8
9 -- Commands
10 OPP_SHUTDOWN_CMD constant varchar2(64) := OPP_PACKAGE || '.' || 'OPPImmediateShutdownCommand';
11 OPP_TERMINATE_CMD constant varchar2(64) := OPP_PACKAGE || '.' || 'OPPTerminateCommand';
12 OPP_PING_CMD constant varchar2(64) := OPP_PACKAGE || '.' || 'OPPPingCommand';
13
14
15 --------------------------------------------------------------------------------
16
17
18 --
19 -- Send an immediate shutdown request to a specific OPP process
20 --
21 procedure send_opp_shutdown_request(cpid in number) is
22
23 begin
24
25 fnd_cp_opp_ipc.send_command(cpid, ICM_ID, OPP_SHUTDOWN_CMD, '');
26
27
28 end;
29
30
31 --
32 -- Requests termination of postprocessing for a specific request
33 --
34 procedure terminate_opp_request(reqid in number, senderid in number) is
35
36 pragma autonomous_transaction;
37
38 cpid number;
39 complete varchar2(1);
40 deadlock_detected exception;
41 dummy number;
42 resource_busy exception;
43 pragma exception_init(resource_busy, -54);
44 pragma exception_init(deadlock_detected , -60);
45
46 begin
47
48 select processor_id, completed
49 into cpid, complete
50 from fnd_conc_pp_actions
51 where concurrent_request_id = reqid
52 and action_type = 6
53 and sequence = 1;
54
55 if cpid is null then
56
57 -- post-processor has not started yet, update the table with our id
58 -- so the post-processor will not pick it up.
59
60 update fnd_conc_pp_actions
61 set processor_id = senderid
62 where concurrent_request_id = reqid;
63
64 commit;
65
66 -- also update the post-processing status of the request
67 -- this could possibly cause a deadlock if the manager running the request still has the lock
68 begin
69 select 1 into dummy from fnd_concurrent_requests where request_id = reqid for update of pp_end_date, post_request_status nowait;
70 update fnd_concurrent_requests
71 set pp_end_date = sysdate,
72 post_request_status = 'E'
73 where request_id = reqid;
74 commit;
75 exception
76 when deadlock_detected then
77 rollback;
78 when resource_busy then
79 rollback;
80 end;
81
82 else
83 if complete <> 'Y' then
84
85 -- post-processor is actively running it, send a terminate command
86
87 fnd_cp_opp_ipc.send_command(cpid, senderid, OPP_TERMINATE_CMD, reqid);
88
89 end if;
90
91 end if;
92
93 commit;
94
95 exception
96 when no_data_found then
97 rollback;
98
99
100 end;
101
102 --
103 -- BUG 9062358 - GSI:GLOBAL ENQUEUE SERVICES DEADLOCK DETECTED
104 -- Requests termination of postprocessing for a specific request without autonomous_transaction
105 --
106 procedure terminate_opp_request_this_txn(reqid in number, senderid in number) is
107 cpid number;
108 complete varchar2(1);
109 begin
110
111 select processor_id, completed
112 into cpid, complete
113 from fnd_conc_pp_actions
114 where concurrent_request_id = reqid
115 and action_type = 6
116 and sequence = 1;
117
118 if cpid is null then
119 -- post-processor has not started yet, update the table with our id
120 -- so the post-processor will not pick it up.
121 update fnd_conc_pp_actions
122 set processor_id = senderid
123 where concurrent_request_id = reqid;
124
125 update fnd_concurrent_requests
126 set pp_end_date = sysdate,
127 post_request_status = 'E'
128 where request_id = reqid;
129 else
130 if complete <> 'Y' then
131 -- post-processor is actively running it, send a terminate command
132 fnd_cp_opp_ipc.send_command(cpid, senderid, OPP_TERMINATE_CMD, reqid);
133 end if;
134 end if;
135 exception
136 when no_data_found then
137 null;
138 end;
139
140 --
141 -- Ping a specific OPP service process
142 -- Returns TRUE if process replies.
143 --
144 function ping_opp_service(cpid in number, senderid in number, timeout in number) return boolean is
145
146 flag varchar2(1);
147 msgtype number;
148 message varchar2(240);
149 params varchar2(2000);
150 sender varchar2(30);
151 msggroup varchar2(30);
152
153 begin
154
155 fnd_cp_opp_ipc.send_command(cpid, senderid, OPP_PING_CMD, '');
156
157 -- should not have to wait long for the reply
158 fnd_cp_opp_ipc.get_message(senderid, flag, msgtype, msggroup, message, params, sender, timeout);
159
160 if flag = 'Y' and message = 'PING' then
161 return true;
162 end if;
163
164 return false;
165
166 end;
167
168
169 END fnd_cp_opp_cmd;