[Home] [Help]
PACKAGE BODY: APPS.WFJ_QUEUE
Source
1 package body WFJ_QUEUE as
2 /* $Header: wfjqueb.pls 120.1 2005/07/02 02:47:52 appldev noship $ */
3
4 --
5 -- Exceptions
6 --
7 dequeue_timeout exception;
8 pragma EXCEPTION_INIT(dequeue_timeout, -25228);
9
10 dequeue_disabled exception;
11 pragma EXCEPTION_INIT(dequeue_disabled, -25226);
12
13 dequeue_outofseq exception;
14 pragma EXCEPTION_INIT(dequeue_outofseq, -25237);
15
16 no_queue exception;
17 pragma EXCEPTION_INIT(no_queue, -24010);
18
19 shutdown_pending exception;
20
21 -- ====================================================================
22 -- NAME: enqueueInbound
23 -- Provides a wrapper for the JAVA function to enqueue the
24 -- result of the function activity
25 -- Item Type
26 -- Item Key
27 -- Result
28 -- Attribute List
29 -- Correlation ID
30 -- Error Stack
31 procedure enqueueInbound(pItemType IN VARCHAR2, pItemKey IN VARCHAR2,
32 pActID IN NUMBER, pResult IN VARCHAR2,
33 pAttrList IN VARCHAR2,
34 pCorrelation IN VARCHAR2, pErrorStack IN VARCHAR2)
35 AS
36 BEGIN
37 WF_QUEUE.EnqueueInbound(pItemType, pItemKey, pActID, pResult,
38 pAttrList, pCorrelation, pErrorStack);
39 EXCEPTION
40 WHEN OTHERS THEN
41 raise;
42 END enqueueInbound;
43
44 -- NAME: dequeueOutbound
45 -- To remove a message from the Outbound Queue which will be a
46 -- request to execute an external funtion activity
47 -- The payload is seperated into the individuate data elements
48 -- Dequeu Mode
49 -- Navigation
50 -- Correlation ID
51 -- Item Type
52 -- Item Key
53 -- Payload.Item Type
54 -- Payload.Item Key
55 -- Payload.Activity ID
56 -- Payload.Function Name
57 -- Payload Parameter List
58 -- Payload.Result
59 -- Message Handle
60 -- Time Out
61 procedure dequeueOutbound(pDequeueMode IN NUMBER, pNavigation IN NUMBER,
62 pCorrelation IN VARCHAR2, pItemType IN VARCHAR2,
63 pPLItemType OUT NOCOPY VARCHAR2, pPLItemKey OUT NOCOPY VARCHAR2,
64 pPLActID OUT NOCOPY NUMBER, pPLFunctionName OUT NOCOPY VARCHAR2,
65 pPLParamList OUT NOCOPY VARCHAR2, pPLResult OUT NOCOPY VARCHAR2,
66 pMessageHandle IN OUT NOCOPY VARCHAR2, pTimeOut OUT NOCOPY VARCHAR2)
67 AS
68 lCorrelation VARCHAR2(80);
69 lPayLoad SYSTEM.WF_PAYLOAD_T;
70 lMessageHandle raw(16);
71 lTimeout boolean;
72 lDequeue_options dbms_aq.dequeue_options_t;
73 lMessage_properties dbms_aq.message_properties_t;
74
75 BEGIN
76
77 wf_queue.set_queue_names;
78
79 if pCorrelation is not null then
80 lCorrelation := pCorrelation;
81 else
82 lCorrelation := wf_queue.account_name||nvl(pItemType,'%');
83 end if;
84 lDequeue_options.correlation := lCorrelation;
85 lDequeue_options.dequeue_mode := pDequeueMode;
86 lDequeue_options.wait := wfj_queue.dequeueDelay;
87 lDequeue_options.navigation := pNavigation;
88
89 lMessageHandle := hextoraw(pMessageHandle);
90 dbms_aq.dequeue
91 (
92 queue_name => wf_queue.OutboundQueue,
93 dequeue_options => lDequeue_options,
94 message_properties => lMessage_properties,
95 payload => lPayLoad,
96 msgid => lMessageHandle
97 );
98 pTimeout := 'FALSE';
99 pPLItemType := lPayLoad.ItemType;
100 pPLItemKey := lPayload.ItemKey;
101 pPLActID := lPayLoad.actID;
102 pPLFunctionName := lPayLoad.Function_name;
103 pPLParamList := lPayload.Param_List;
104 pPLResult := lPayLoad.Result;
105 pMessagehandle := rawtohex(lMessageHandle);
106
107 EXCEPTION
108 WHEN dequeue_timeout then
109 pTimeout := 'TRUE';
110 WHEN OTHERS THEN
111 pTimeout := 'FALSE';
112 raise;
113 END dequeueOutBound;
114
115 -- NAME: getEventData
116 -- To retrieve the CLOB data from the event message
117 -- Item Type
118 -- Item Key
119 -- Name of the Item Attribute containing the event
120 -- Event data to be returned.
121 procedure getEventData(p_item_type in VARCHAR2,
122 p_item_key in VARCHAR2,
123 p_name in VARCHAR2,
124 p_event_data out NOCOPY CLOB)
125 AS
126
127 l_event_message WF_EVENT_T;
128 l_data CLOB := null;
129
130 BEGIN
131 l_event_message := wf_engine.getItemAttrEvent(p_item_type,
132 p_item_key, p_name);
133 p_event_data := l_event_message.event_data;
134 EXCEPTION
135 WHEN OTHERS THEN
136 NULL;
137 end getEventData;
138 -- For Web Services
139 -- NAME: setEventData
140 -- To set the CLOB data on the event message
141 -- Item Type
142 -- Item Key
143 -- Name of the Item Attribute containing the event
144 -- Event data to be set.
145 procedure setEventData(p_item_type in VARCHAR2,
146 p_item_key in VARCHAR2,
147 p_name in VARCHAR2,
148 p_event_data in CLOB)
149 AS
150
151 l_event_message WF_EVENT_T;
152
153 BEGIN
154 wf_event_t.initialize(l_event_message);
155 --We might have to initialize the event
156 l_event_message.event_data := p_event_data;
157 wf_engine.setItemAttrEvent(p_item_type,p_item_key, p_name,l_event_message);
158 EXCEPTION
159 WHEN OTHERS THEN
160 raise ;
161 end setEventData;
162
163 --
164 -- ApplyTransformation
165 -- Copy the contents of the event from the source to the
166 -- destination events. Then open the destination for update
167 -- to receive the transformation
168 -- IN
169 -- itemtype - process item type
170 -- itemkey - process item key
171 -- name - attribute name
172 -- RETURNS
173 -- EVENT_DATA CLOB
174 --
175 function ApplyTransformation(
176 itemtype in varchar2,
177 itemkey in varchar2,
178 srcName in varchar2,
179 dstName in varchar2)
180 return ROWID
181 is
182 srcValue wf_event_t;
183 dstValue wf_event_t;
184 lvalue wf_event_t;
185 lRowid ROWID;
186
187 begin
188 -- Not allowed in synch mode
189 if (itemkey = wf_engine.eng_synch) then
190 wf_core.token('OPERATION', 'Wf_Engine.SetItemAttrEvent');
191 wf_core.raise('WFENG_SYNCH_DISABLED');
192 end if;
193
194 -- Get the source event
195 select EVENT_VALUE
196 into srcValue
197 from WF_ITEM_ATTRIBUTE_VALUES
198 where ITEM_TYPE = ApplyTransformation.itemtype
199 and ITEM_KEY = ApplyTransformation.itemkey
200 and NAME = ApplyTransformation.srcName;
201
202 -- Get the destination event
203 select ROWID
204 into lRowid
205 from WF_ITEM_ATTRIBUTE_VALUES
206 where ITEM_TYPE = ApplyTransformation.itemtype
207 and ITEM_KEY = ApplyTransformation.itemkey
208 and NAME = ApplyTransformation.dstName;
209
210 wf_event_t.initialize(dstValue);
211 dstValue.PRIORITY := srcValue.PRIORITY;
212 dstValue.SEND_DATE := srcValue.SEND_DATE;
213 dstValue.RECEIVE_DATE := srcValue.RECEIVE_DATE;
214 dstValue.CORRELATION_ID := srcValue.CORRELATION_ID;
215 dstValue.PARAMETER_LIST := srcValue.PARAMETER_LIST;
216 dstValue.EVENT_NAME := srcValue.EVENT_NAME;
217 dstValue.EVENT_KEY := srcValue.EVENT_KEY;
218 dstValue.FROM_AGENT := srcValue.FROM_AGENT;
219 dstValue.TO_AGENT := srcValue.TO_AGENT;
220 dstValue.ERROR_SUBSCRIPTION := srcValue.ERROR_SUBSCRIPTION;
221 dstValue.ERROR_MESSAGE := srcValue.ERROR_MESSAGE;
222 dstValue.ERROR_STACK := srcValue.ERROR_STACK;
223
224 -- Assign the source to the destination
225 update WF_ITEM_ATTRIBUTE_VALUES
226 set EVENT_VALUE = dstValue
227 where ITEM_TYPE = ApplyTransformation.itemType
228 and ITEM_KEY = ApplyTransformation.itemkey
229 and NAME = ApplyTransformation.dstName;
230
231 return(lRowid);
232 exception
233 when no_data_found then
234 Wf_Core.Context('Wfj_Queue', 'ApplyTransformation', itemtype, itemkey,
235 srcName, dstName);
236 Wf_Core.Token('TYPE', itemtype);
237 Wf_Core.Token('KEY', itemkey);
238 Wf_Core.Token('ATTRIBUTE', srcName);
239 Wf_Core.Token('ATTRIBUTE', dstName);
240 Wf_Core.Raise('WFENG_ITEM_ATTR');
241 when others then
242 Wf_Core.Context('Wfj_Queue', 'ApplyTransformation', itemtype,
243 itemkey, srcName, dstName);
244 raise;
245 end ApplyTransformation;
246
247 -- ====================================================================
248 -- NAME: setDequeueDelay
249 -- Provides a wrapper for the dequeueDelay spec variable
250 -- pDelay - The number of seconds the dequeue operation should block for
251 procedure setDequeueDelay(pDelay in INTEGER)
252 is
253 begin
254 wfj_queue.dequeueDelay := pDelay;
255 end;
256
257 -- ====================================================================
258 -- NAME: getDequeueDelay
259 -- Provides a wrapper for the dequeueDelay spec variable
260 function getDequeueDelay return integer
261 is
262 begin
263 return wfj_queue.dequeueDelay;
264 end;
265
266 end WFJ_QUEUE;