Adding CFC timeout?
iam trying add a timeout in a CFC but having some issues with
it...I need help...here is my sample CFC which needs a timeout
added....could somebody please help me how to add a timeout in the
code..i tried requesttimeout using cfsetting but i could not pull
WSDL up..
<cfsetting requesttimeout="30" />
<cfcomponent>
<cffunction name = "test" access="remote"
returntype="struct" output="no">
<cfargument name="var1" required="true">
<cfargument name="var2" required="true">
<cfscript>
//Request structure
stOrder = structNew();
stOrder.var11 = #arguments.var1#;
stOrder.var21 = #arguments.var1#;
//needs a timeout added around this call
ws = createObject("webservice", "#WebServiceURL#");
myReturnVar = ws.NewOrder(stOrder); //end of timeout
</cfscript>
<CFSET returnStruct = StructNew()>
<CFSET structRC = StructInsert(returnStruct, "output",
myReturnVar.outputvar1)>
<cfreturn returnStruct>
</cffunction>
</cfcomponent>
adding CFC timeout?
No, I wouldn't. When my employer sends me to get a job done, he is the one with the stop-watch in his hand, not me.
In my opinion, the calling page should be the one to decide that a function is taking too long, not the component. I would design it like this:
callingPage.cfm
=============
<cfsetting requesttimeout="30" />
<!--- instantiate component or web service and call test() --->
Similar Messages
-
Adding a timeout to Auto Complete doesn't work for IE
We implemented our own declarative auto complete component. So we're manually handling KeyUp and KeyDown.
One thing that we need to do is to add a timeout so that when the user is typing, we don't fire the bean code to do the query on every key pressed, but only do it after say half a second. That way if the user is intending to type 3 keys, we only need to fire our query once, where realHandleKeyUpOnSuggestField is the function that calls the query among other things.
This is called from our ClientListener
function handleKeyUpOnSuggestField(evt) {
var realHandleKeyUpOnSuggestField = function () {
// start the popup aligned to the component that launched it
var inputField = evt.getSource();
var suggestPopup = inputField.findComponent("suggestPopup");
// var suggestTable = inputField.findComponent("suggestTable");
//don't open when user "tabs" into field
var valueStr = inputField.getSubmittedValue();
// Special characters coming from scanner. Don't popup if that's the case.
if (suggestPopup.isShowing() == false && evt.getKeyCode() != AdfKeyStroke.TAB_KEY) {
//hints = {align:AdfRichPopup.ALIGN_AFTER_START, alignId:evt.getSource().getClientId()+"::content"};
var alignTo = inputField.getClientId() + "::content";
var hints = {
align : AdfRichPopup.ALIGN_AFTER_START, alignId : alignTo
suggestPopup.show(hints);
//disable popup hide to avoid popup to flicker on
//key press
suggestPopup.hide = function () {
//suppress server access for the following keys
//for better performance
if (evt.getKeyCode() == AdfKeyStroke.ARROWLEFT_KEY || evt.getKeyCode() == AdfKeyStroke.ARROWRIGHT_KEY || evt.getKeyCode() == AdfKeyStroke.ARROWLEFT_KEY || evt.getKeyCode() == AdfKeyStroke.SHIFT_MASK || evt.getKeyCode() == AdfKeyStroke.END_KEY || evt.getKeyCode() == AdfKeyStroke.ALT_KEY || evt.getKeyCode() == AdfKeyStroke.HOME_KEY) {
return false;
if (evt.getKeyCode() == AdfKeyStroke.ESC_KEY) {
hidePopup(evt);
return false;
// query suggest list on the server
AdfCustomEvent.queue(suggestPopup, "suggestServerListener",
// Send single parameter
filterString : valueStr
true);
var inputField = evt.getSource();
if (window["timer" + inputField.getClientId()]) {
window.clearTimeout(window["timer" + inputField.getClientId()]);
window["timer" + inputField.getClientId()] = window.setTimeout(realHandleKeyUpOnSuggestField, 500);
}This works fine in FireFox and Safari and Chrome, but not in IE.
The following error occurs:
>
Webpage error details
User Agent: Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 6.0; WOW64; Trident/4.0; SLCC1; .NET CLR 2.0.50727; .NET CLR 3.5.30729; .NET CLR 3.0.30729)
Timestamp: Thu, 13 May 2010 20:27:33 UTC
Message: Member not found.
Line: 6034
Char: 2
Code: 0
URI: http://127.0.0.1:7101/NC2DealerPartOrderTracking-ViewController-context-root/afr/partition/ie/default/opt/core-SHEPHERD-PS1-9296.js
>
When I debugged through, it seems like the event's getKeyCode() doesn't exist. I'm assuming it's something to do with scope for IE working different than FireFox.
I realize this is more JavaScript question, but I'm wondering if anyone got something like that to work on ADF. As far as I know, there's no other way besides using JavaScript and IE doesn't seem handle scoping very well. I can't use a global parameter because I'm using this in a component and you can have multiple components in a page.Clicking the link to the .PDF launches the file in a browser (same gimped toolbar for both IE 8 and Firefox). When I right-click the .PDF toolbar in-browser, I have access to the following toolbars:
File
Find
Page Display
Page Navigation
Select and Zoom
Tasks
I don't see anything for Commenting / Annotation. -
A script for adding the current date to file name?
I am working in Indesign CS3. I frequently save file as PDFs into a designated folder. I was hoping for help in writing a script that would apply the current date to the end of the file name, when saved into this folder. Some days, I save the same file several times, into this folder. I was also hoping there was a way to add a date and version, for example "filename_2.25.11(1).pdf" Is this possible? Can someone help me?
ok, I ended up with this test routine:
on adding folder items to this_folder after receiving added_items
tell application "Finder"
repeat with this in added_items
my checkifopened(this)
display dialog (name of this) as text
end repeat
end tell
end adding folder items to
on checkifopened(this)
set a to POSIX path of (this as alias)
repeat until 1 = 0
## don't like that one because it relies on an error msg ... so
(** try
set b to do shell script "lsof | grep " & quoted form of a
on error
exit repeat
end try**)
##so I use this one
set b to do shell script "lsof"
if b does not contain a then
exit repeat
else
say "still opened"
end if
end repeat
end checkifopened
this is a folder action that tests if the added file is still opened by an application... there is no delay between each test-loop since lsof takes some time to execute...
And after adding a timeout (just in case) to this function the final script looks like this:
on adding folder items to thefolder after receiving added_items
tell application "Finder"
set folderkind to kind of thefolder
set myfiles to every item of thefolder whose name does not contain "#" and kind is not folderkind
repeat with myfile in myfiles
set myfile_datestring to my get_datestring(creation date of myfile)
set myfilename to name of myfile
if (count of every character of myfilename) > 4 and (character -4 of myfilename) as text is "." then
set filestatus to my checkifopened(myfile, 60)
if filestatus = false then
display dialog "timeout on folder action"
else
set tmp to ((characters 1 through -5 of myfilename) & "#" & myfile_datestring & (characters -4 through -1 of myfilename)) as text
set myfilename to my checknamewith_pdfsuffix(tmp, thefolder, false)
set name of myfile to myfilename
end if
end if
end repeat
end tell
end adding folder items to
on get_datestring(mydate)
return year of mydate & "-" & (characters -2 through -1 of (("0" & (month of mydate as integer)) as text)) & "-" & (characters -2 through -1 of (("0" & (day of mydate as integer)) as text)) as text
end get_datestring
on checknamewith_pdfsuffix(n, D, looped)
--check if filename exists in D
-- so if "A File.pdf" exists it names it "A File 1.pdf","A File 2.pdf",...
#n = string of the filename
#D = file reference to the directory to check
#looped = boolean used for recursive loop...
tell application "Finder"
set thefiles to name of every item of (D as alias)
end tell
if thefiles contains n then
if looped = false then
set n to ((characters 1 through -5 of n) & "(1)" & (characters -4 through -1 of n)) as text
my checknamewith_pdfsuffix(n, D, true)
else
set tmp to (last word of ((characters 1 through -5 of n) as text) as integer)
set tmpcount to (count of characters of (tmp as text)) + 5
set tmp to tmp + 1
set n to ((characters 1 through (-1 * tmpcount) of n) & "(" & tmp & ")" & (characters -4 through -1 of n)) as text
my checknamewith_pdfsuffix(n, D, true)
end if
else
return n
end if
end checknamewith_pdfsuffix
on checkifopened(this, mytimeout)
## this file reference
## timeout in seconds
set a to POSIX path of (this as alias)
set startdate to current date
repeat until 1 = 0
## don't like that one because it relies on an error msg ... so
(** try
set b to do shell script "lsof | grep " & quoted form of a
on error
exit repeat
end try**)
##so I use this one
set b to do shell script "lsof"
if b does not contain a then
return true
else if ((current date) - startdate) > mytimeout then
return false
else
##say "still opened"
end if
end repeat
end checkifopened
to use this save this script in /Library/Scripts/Folder Action Scripts
and add this as a folder action to your folder...
The script processes all files inside that folder each time a new files is added... -
Long sync calls and timeout.
2. TIMEOUT
Consider the following situation :
Flows 1 --- async call ----> FLows 2 ------ async call --------> Flows 3 -----sync call ----> axis ws
The last sync call can take a long time.
If this time is too long , Flows 1 , FLows 2 , Flows 3 goes in stale state ...
How can i manage timeout/set maximum time for Async and Sync call ?
What's the best way to manage this ?I circled back with the engineering team on this: we are in the process of adding a timeout configuration parameter to the partnerLinkBinding information embedded in the BPEL deployment descriptor (bpel.xml). An associated runtime BPEL fault will be defined for process designer to catch and handle this type of synchronous timeout. This feature will be available in the September service pack.
The async timeout can be managed using the bpel pick/onMessage and onAlarm.
Edwin -
I have a synchronous webservice (external system > PI > SAP), and due to the volume of data get timeout issue. I have tried adding XI.Timeout to the sender soap adapter communication channel and set to 5 minutes (300000ms) but it has no affect and still times out after 60 seconds.
If I update the max processing time in smicm then this resolves the issue, but I thought I could specify this on the webservice via XI.Timeout - is that correct?. Or is there another XI.parameter that I need to set on the communication channel?
Using PI 7.0 SP15.
Interestingly if I set the XI.Timeout to a low value, it does time out quicker, so it makes my think the timeout is happening at a different point.
I have looked at the 'How To... Investigate Timeouts In Synchronous XI/PI Scenarios' document - but would like some specific advice.
ThanksHi Trig,
Increase the values (TIMEOUT AND PROCTIMEOUT) as seen below example for the R/3 parameters (via SMICM):
First increase the parameter "icm/keep_alive_timeout":
old value: <your_old_value>
new value: 900
You will also see the parameters where PROT=HTTP. Change the values here too similar to as seen below:
icm/server_port_0
old value: PROT=HTTP,PORT=<your_port>,HOST=<your_host>
,TIMEOUT=<your_old_value>, PROCTIMEOUT=<your_old_value>
new value: PROT=HTTP,PORT=<your_port>,HOST=<your_host>
,TIMEOUT=900,PROCTIMEOUT=900
icm/server_port_<n>
old value: PORT=<your_port_value>,PROT=HTTP
new value: PORT=<your_port_value>,PROT=HTTP,TIMEOUT=900
,PROCTIMEOUT=900
Also, change the icm/host_name_full to full qualified host name.
You could also take a look into these notes:
#824554 - ICM and SAP Web Dispatcher Timeout Parameter
Afterwards, restart the system for the new values to take effect.
Regards,
Caio Cagnani -
Monitor EJB transaction timeout value
Hi,
I try to create a test case to monitor transaction timeout and rollback value
(not 0) from weblogic 6.1 console. By adding the timeout value to the weblogic-ejb-jar.xml
and rebuild the beanManaged example, I successfully create the scenario by seeing
the timeout and transaction rollback exception from the server. However, from
console the timeout value and rollback value of EJB monitoring still show "0"
not any number I expected. Any bug from Weblogic?
Thanks, CathyThe following configuration seems working:
version: OC4J (9.0.3.0.0) (build 020927.1699)
AM deployment:
- bc4j.xcfg: <jbo.ejb.txntimeout>30000</jbo.ejb.txntimeout>
- orion-ejb-jar.xml: <session-deployment name="..." timeout="0"/>
OC4J config:
- data-source: inactivity-timeout="30000"
This keeps connection open for more than default 30 mins of inactivity (30000 secs configured).
Although, oc4j console prints multiple warnings:
DriverManagerConnectionPoolConnection not closed, check your code!
Looks like this is not an intended usage - but working.
Notice that it was a test, not a production environment.
Also pls see 9033: AM as EJB Session bean: pooled connection lost for new txn
I would be thankful for any experience in running AM Session EJB w/o timeout. -
Shell Script Resource-Timeout error
Hi!!
I have an issue with the Shell Script Resource, the problem is as follows:
When I created a user in this resource and appears a error message:
com.waveset.util.WavesetException: An error occurred adding user 'user01' to resource 'Shell Script'. com.waveset.util.WavesetException: Script failed waiting for "_,)#+(:" in response "" com.waveset.util.WavesetException: Script processor timed out with nothing to read and the following unprocessed text: "".
I added the timeout property = 300 000 in my shell script is as follows:
<ResTypeAction restype='Shell Script' timeout='300000'>
but it doesn't work.
I had the IDM 8 with the patch 4 but the problem beging when I did upgrade to patch 4 to 6.
Does anyone knows what could be the problem.
Thanks in advance!Hello!
That isn't the problem the test connection works fine but when I try provisioning a user the shell script execute some instructions, in the shell script I need to set the timeout property in order to give more time to finish execute the instructions before the script execute the following command.
I tested the timeout property in the shell script and work to fine for IDM 8 patch 4 I upgrade to patch 10 and stopped to work.
Does anyone knows What could be the rigth way to set the timeout property in a resource action for shell script resource?
Thanks... -
Which timeout is killing me?
I hava one process loading 30,000 entries into NamedCache and then launching a remote task via InvocationService.execute call
this task on the remote node loads the entries from the cache one by one until about 30 seconds later it is interrupted:
(Wrapped) java.lang.InterruptedException
at com.tangosol.coherence.component.util.daemon.queueProcessor.service.Grid.poll(Grid.CDB:59)
at com.tangosol.coherence.component.util.daemon.queueProcessor.service.Grid.poll(Grid.CDB:11)
at com.tangosol.coherence.component.util.daemon.queueProcessor.service.grid.DistributedCache$BinaryMap.get(DistributedCache.CDB:24)
at com.tangosol.util.ConverterCollections$ConverterMap.get(ConverterCollections.java:1522)
at com.tangosol.coherence.component.util.daemon.queueProcessor.service.grid.DistributedCache$ViewMap.get(DistributedCache.CDB:1)
at com.tangosol.coherence.component.util.SafeNamedCache.get(SafeNamedCache.CDB:1)
at com.my.coherence.CoherenceMember.initData(CoherenceMember.java:85)
at com.my.coherence.CoherenceTask.run(CoherenceTask.java:61)
at com.tangosol.coherence.component.util.daemon.queueProcessor.service.grid.InvocationService.onInvocationRequest(InvocationService.CDB:10)
at com.tangosol.coherence.component.util.daemon.queueProcessor.service.grid.InvocationService$InvocationRequest.onReceived(InvocationService.CDB:40)
at com.tangosol.coherence.component.util.daemon.queueProcessor.service.Grid.onMessage(Grid.CDB:9)
at com.tangosol.coherence.component.util.daemon.queueProcessor.service.Grid.onNotify(Grid.CDB:136)
at com.tangosol.coherence.component.util.Daemon.run(Daemon.CDB:42)
at java.lang.Thread.run(Thread.java:619)
Caused by: java.lang.InterruptedException
at java.lang.Object.wait(Native Method)
at java.lang.Object.wait(Object.java:485)
at com.tangosol.coherence.component.util.daemon.queueProcessor.service.Grid.poll(Grid.CDB:31)
... 13 more
and I get memberFailed in the master node. I run with default development mode config and wonder which of the timeout settings should I adjust to give my task more time?
I've also tried adding
<request-timeout>310000</request-timeout>
<task-timeout>310000</task-timeout>
<task-hung-threshold>310000</task-hung-threshold>
into <distributed-scheme> but this does not help :(This is likely the Service Guardian killing a long running invocation.
Use the following property override to set it to an arbitrary new timeout in milliseconds:
-Dtangosol.coherence.guard.timeout=60000 // sets it to 60 seconds
Setting it to 0 turns it off.
More about the Service Guardian in Patrick Peralta's blog post here:
http://blackbeanbag.net/wp/2009/07/20/coherence-3-5-service-guardian-deadlock-detection/
And more about the configuration for the guardian here:
http://wiki.tangosol.com/display/COH35UG/service-guardian
/Christer -
PL/SQL Mail Utility :: Binary/Ascii/Cc/Bcc/FileDump
I was working on my mail package and decided it was overtly complicated and
stripped it down to its bare bones. Here is what I came up with. Built on a previous
foundation of anothers work, I expanded the functionality considerably. You will find all
the features I think that you will need regarding a mail routine. There is also a nice
filedump routine included which makes very easy to create flat file dumps that you can
then attach to your emails. There are a few pre-reqs in using this though :
- 9iR2+
- DBA_Directories defined as opposed to utl_file paths
- Java Virtual Machine. Document can be found in Note :105472.1 Setup, Configuration,
and Use of the Java Virtual Machine on metalink.
As always, I welcome feedback and suggestions for improvement.
Barry C
http://www.myoracleportal.com
CREATE OR REPLACE PACKAGE mail_tools
AS
-- SENDMAIL supports variable message length with/without attachments
-- QUERY_SERVER allows you to check the status of a mail server to see if it is running
-- DUMP_FLATFILE allows you to dump flat file data from query submitted
-- Query Server to verify that the server is up and running.
-- Connects, Noop Command is executed, Disconnect.
-- GET_MAIL_ADDRESS is utilized in the SENDMAIL procedure
-- Table 100-3 SMTP Reply Codes
-- Reply Code
-- Meaning
-- 211 System status, or system help reply
-- 214 Help message [Information on how to use the receiver or the meaning of a particular non-standard command; this reply is useful only to the human user]
-- 220 <domain> Service ready
-- 221 <domain> Service closing transmission channel
-- 250 Requested mail action okay, completed
-- 251 User not local; will forward to <forward-path>
-- 252 OK, pending messages for node <node> started. Cannot VRFY user (e.g., info is not local), but will take message for this user and attempt delivery.
-- 253 OK, <messages> pending messages for node <node> started
-- 354 Start mail input; end with <CRLF>.<CRLF>
-- 355 Octet-offset is the transaction offset
-- 421 <domain> Service not available, closing transmission channel (This may be a reply to any command if the service knows it must shut down.)
-- 450 Requested mail action not taken: mailbox unavailable [for example, mailbox busy]
-- 451 Requested action aborted: local error in processing
-- 452 Requested action not taken: insufficient system storage
-- 453 You have no mail.
-- 454 TLS not available due to temporary reason. Encryption required for requested authentication mechanism.
-- 458 Unable to queue messages for node <node>
-- 459 Node <node> not allowed: reason
-- 500 Syntax error, command unrecognized (This may include errors such as command line too long.)
-- 501 Syntax error in parameters or arguments
-- 502 Command not implemented
-- 503 Bad sequence of commands
-- 504 Command parameter not implemented
-- 521 <Machine> does not accept mail.
-- 530 Must issue a STARTTLS command first. Encryption required for requested authentication mechanism.
-- 534 Authentication mechanism is too weak.
-- 538 Encryption required for requested authentication mechanism.
-- 550 Requested action not taken: mailbox unavailable [for , mailbox not found, no access]
-- 551 User not local; please try <forward-path>
-- 552 Requested mail action aborted: exceeded storage allocation
-- 553 Requested action not taken: mailbox name not allowed [for example, mailbox syntax incorrect]
-- 554 Transaction failed
This version allows for a customized seperator value. Using this function will allow you to
perform fixed width flat files by defining '' for no seperator and then RPAD/LPAD your columns as necessary.
Or use whatever seperator you wish to use, pipe, space, zeros, etc.
-- Example : This will generate a flat file which tabbed seperated
-- DECLARE
-- l_rows NUMBER;
-- l_sql VARCHAR2(32000);
-- BEGIN
-- l_sql := '
-- SELECT rpad(hou.NAME,70) udn_desc
-- , rpad(pcak.segment1,6) coid
-- , rpad(pcak.segment2,4) udn
-- FROM hr_all_organization_units hou, hr.pay_cost_allocation_keyflex pcak
-- WHERE TRUNC (SYSDATE) BETWEEN hou.date_from
-- AND NVL (hou.date_to, ''31-DEC-4712'')
-- AND pcak.cost_allocation_keyflex_id = hou.cost_allocation_keyflex_id
-- GROUP BY pcak.segment1, pcak.segment2, hou.NAME
-- ORDER BY 1, 2, 3
-- l_rows :=
-- dump_flatfile
-- (p_query =>
-- , p_dir => 'INTF000_TABLES'
-- , p_filename => 'test.csv'
-- , p_separator => ' ' -- <= tabbed 5 spaces between each column
-- , p_max_linesize => 32000
-- , p_mode => 'w' -- (w)rite mode or (a)ppend mode
-- END;
FUNCTION dump_flatfile (
p_query IN VARCHAR2
, p_dir IN VARCHAR2
, p_filename IN VARCHAR2
, p_separator IN VARCHAR2
, p_headers IN BOOLEAN DEFAULT FALSE
, p_trailing_separator IN BOOLEAN DEFAULT FALSE
, p_max_linesize IN NUMBER DEFAULT 32000
, p_mode IN VARCHAR2 DEFAULT 'w' )
RETURN NUMBER;
FUNCTION get_mail_address (
addr_list IN OUT VARCHAR2 )
RETURN VARCHAR2;
FUNCTION smtp_command (
command IN VARCHAR2
, ok IN VARCHAR2 DEFAULT '250'
, code OUT VARCHAR2
, DEBUG NUMBER DEFAULT 0 )
RETURN BOOLEAN;
FUNCTION query_server (
smtp_server VARCHAR2
, smtp_server_port PLS_INTEGER DEFAULT 25
, DEBUG NUMBER DEFAULT 0 )
RETURN BOOLEAN;
This procedure uses the UTL_TCP package to send an email message.
Up to three file names may be specified as attachments.
Written: Dave Wotton, 14/6/01 (Cambridge UK)
This script comes with no warranty or support. You are free to
modify it as you wish, but please retain an acknowledgement of
my original authorship.
Amended: Dave Wotton, 10/7/01
Now uses the utl_smtp.write_data() method to send the message,
eliminating the 32Kb message size constraint imposed by the
utl_smtp.data() procedure.
Amended: Dave Wotton, 20/7/01
Increased the v_line variable, which holds the file attachment
lines from 400 to 1000 bytes. This is the maximum supported
by RFC2821, The Simple Mail Transfer Protocol specification.
Amended: Dave Wotton, 24/7/01
Now inserts a blank line before each MIME boundary line. Some
mail-clients require this.
Amended: Dave Wotton, 4/10/01
Introduced a 'debug' parameter. Defaults to 0. If set to
non-zero then errors in opening files for attaching are
reported using dbms_output.put_line.
Include code to hand MS Windows style pathnames.
Amended: Barry Chase, 4/29/03
Added Priority to procedure and also X-Mailer ID.
Removed restrictions for email size limitation as well.
Emails are now formatted text messages, meaning you can
write your message in html format.
And finally, changed from using UTL_SMTP to UTL_TCP instead.
Amended: Barry Chase 11/10/2003
Added session timeout of 4 minutes to prevent hanging server connections
Amended: Barry Chase 12/04/2003
Added Date String so that it represents timezone of originating server
p_datestring
Amended: Barry Chase 03/01/2004
Added functionality to support binary attachments and remote attachments.
Its about 98% complete. Not work perfectly yet. Still trying to figure out
encoding to base64 or mime. Have a good start on it though.
04/12/2004
BCHASE :: Binary Support is fully functional now.
09/01/2005
BCHASE :: Modified attachment directories to use DBA_DIRECTORIES instead
of UTL_DIR in the Oracle initialization file.
02/22/2006
BCHASE :: Added variable length message email support (CLOB)
04/21/2006
BCHASE :: Expanded functionality to include Cc and Bcc
Also removed redundant calls from package. The single
mail_files command will handle flat files and binary files such as zip/pdf/etc.
SMTP Server and SMTP Server Port are parameters on the sendmail procedure now
as well.
Refer to http://home.clara.net/dwotton/dba/oracle_smtp.htm for more
details on the original source code.
For information on the enhanced mail_tools package as provided by Barry
Chase, refer to http://www.myoracleportal.com
/* Retrieves local binary file from database server.
* using DBMS_LOB commands and stores into BLOB
* return BLOB
FUNCTION get_local_binary_data (
p_dir IN VARCHAR2
, p_file IN VARCHAR2 )
RETURN BLOB;
/* Supports binary attachments and message of variable length. Uses CLOB.*/
-- DECLARE
-- t_blob BLOB;
-- BEGIN
-- Use the get_local_binary_data to collect your BLOB from the filesystem
-- or just load from a table where your BLOB is stored at, then just pass
-- as t_blob on the binaryfile parameter below. Remember to provide an
-- appropriate filename. Optionally, you can leave filename NULL and pass
-- the binaryfile parameter as EMPTY_BLOB() to send an email without an
-- attachment.
-- t_blob :=
-- mail_tools.get_local_binary_data
-- ( p_dir => 'INTF0047_TABLES'
--, p_file => 'test_file1.csv' );
-- mail_tools.sendmail
-- ( smtp_server => 'your.smtp.server'
-- , smtp_server_port => 25
-- , from_name => 'Email Address of Sender'
-- , to_name => 'list of TO email addresses separated by commas (,)'
-- , cc_name => 'list of CC email addresses separated by commas (,)'
-- , bcc_name => 'list of BCC email addresses separated by commas (,)'
-- , subject => 'Some brief Subject'
-- , MESSAGE => 'Your message goes here. Can include HTML code.'
-- , priority => '1-5 1 being the highest priority and 3 normal priority'
-- , filename => 'your.filename.txt or leave NULL'
-- , binaryfile => 'your blob is passed here otherwise leave as EMPTY_BLOB()
-- , DEBUG => 'Default is DBMS output otherwise pass a 1 to disable );
-- END;
PROCEDURE sendmail (
smtp_server VARCHAR2
, smtp_server_port PLS_INTEGER DEFAULT 25
, from_name VARCHAR2
, to_name VARCHAR2
, cc_name VARCHAR2 DEFAULT NULL
, bcc_name VARCHAR2 DEFAULT NULL
, subject VARCHAR2
, MESSAGE CLOB
, priority PLS_INTEGER DEFAULT NULL
, filename VARCHAR2 DEFAULT NULL
, binaryfile BLOB DEFAULT EMPTY_BLOB ( )
, DEBUG NUMBER DEFAULT 0 );
v_parm_value VARCHAR2 ( 4000 );
lbok BOOLEAN;
v_smtp_server VARCHAR2 ( 50 );
v_smtp_server_port NUMBER := 25;
crlf VARCHAR2 ( 10 ) := utl_tcp.crlf;
conn utl_tcp.connection;
p_debug_marker PLS_INTEGER := 0;
rc INTEGER;
p_from_name VARCHAR2 ( 100 );
p_to_name VARCHAR2 ( 4000 );
p_cc_name VARCHAR2 ( 4000 );
p_bcc_name VARCHAR2 ( 4000 );
p_subject VARCHAR2 ( 150 );
tx_timeout PLS_INTEGER := 240;
-- 240 Seconds (4 minutes);
p_datestring VARCHAR2 ( 100 )
:= 'Date: '
|| TO_CHAR ( SYSDATE, 'MM/DD/RR HH:MI AM' )
|| ' '
|| DBTIMEZONE
|| ' '
|| '(GMT'
|| DBTIMEZONE
|| ')';
-- Customize the signature that will appear in the email's MIME header.
-- Useful for versioning.
mailer_id CONSTANT VARCHAR2 ( 256 ) := 'Mailer by Oracle UTL_TCP';
max_base64_line_width CONSTANT PLS_INTEGER := 76 / 4 * 3;
END;
CREATE OR REPLACE PACKAGE BODY mail_tools
IS
PROCEDURE print_output (
p_message IN VARCHAR2 )
IS
BEGIN
dbms_output.put_line ( SUBSTR ( p_message
, 1
, 250 ));
IF LENGTH ( p_message ) > 250
THEN
dbms_output.put_line ( SUBSTR ( p_message
, 251
, 500 ));
END IF;
IF LENGTH ( p_message ) > 500
THEN
dbms_output.put_line ( SUBSTR ( p_message
, 501
, 750 ));
END IF;
IF LENGTH ( p_message ) > 750
THEN
dbms_output.put_line ( SUBSTR ( p_message
, 751
, 1000 ));
END IF;
EXCEPTION
WHEN OTHERS
THEN
NULL; -- Ignore errors... protect buffer overflow's etc.
END print_output;
FUNCTION dump_flatfile (
p_query IN VARCHAR2
, p_dir IN VARCHAR2
, p_filename IN VARCHAR2
, p_separator IN VARCHAR2
, p_headers IN BOOLEAN DEFAULT FALSE
, p_trailing_separator IN BOOLEAN DEFAULT FALSE
, p_max_linesize IN NUMBER DEFAULT 32000
, p_mode IN VARCHAR2 DEFAULT 'w' )
RETURN NUMBER
IS
l_output utl_file.file_type;
l_thecursor INTEGER DEFAULT dbms_sql.open_cursor;
l_columnvalue VARCHAR2 ( 4000 );
l_status INTEGER;
l_colcnt NUMBER DEFAULT 0;
l_cnt NUMBER DEFAULT 0;
l_separator VARCHAR2 ( 10 ) DEFAULT '';
l_line LONG;
l_desctbl dbms_sql.desc_tab;
v_sqlerrm VARCHAR2 ( 32000 );
l_mode CHAR ( 1 ) := 'w';
BEGIN
IF p_mode NOT IN ( 'w', 'a' )
THEN
l_mode := 'w';
ELSE
l_mode := p_mode;
END IF;
l_output := utl_file.fopen ( p_dir
, p_filename
, l_mode
, p_max_linesize );
dbms_sql.parse ( l_thecursor
, p_query
, dbms_sql.native );
dbms_sql.describe_columns ( l_thecursor
, l_colcnt
, l_desctbl );
FOR i IN 1 .. l_colcnt
LOOP
dbms_sql.define_column ( l_thecursor
, i
, l_columnvalue
, 4000 );
IF ( l_desctbl ( i ).col_type = 2 ) /* number type */
THEN
l_desctbl ( i ).col_max_len := l_desctbl ( i ).col_precision + 2;
ELSIF ( l_desctbl ( i ).col_type = 12 ) /* date type */
THEN
/* length of my date format */
l_desctbl ( i ).col_max_len := 20;
ELSIF ( l_desctbl ( i ).col_type = 8 ) /* LONG type */
THEN
l_desctbl ( i ).col_max_len := 2000;
END IF;
IF p_headers
THEN
utl_file.put ( l_output, l_separator || l_desctbl ( i ).col_name );
l_separator := p_separator;
END IF;
END LOOP;
IF p_trailing_separator
THEN
utl_file.put ( l_output, l_separator );
END IF;
IF p_headers
THEN
utl_file.new_line ( l_output );
END IF;
l_status := dbms_sql.EXECUTE ( l_thecursor );
LOOP
EXIT WHEN ( dbms_sql.fetch_rows ( l_thecursor ) <= 0 );
l_line := NULL;
l_separator := '';
FOR i IN 1 .. l_colcnt
LOOP
dbms_sql.COLUMN_VALUE ( l_thecursor
, i
, l_columnvalue );
IF NVL ( INSTR ( l_columnvalue, ',' ), 0 ) = 0
THEN
NULL;
ELSE
l_columnvalue := '"' || l_columnvalue || '"';
END IF;
utl_file.put ( l_output, l_separator || l_columnvalue );
l_separator := p_separator;
END LOOP;
IF p_trailing_separator
THEN
utl_file.put ( l_output, l_separator );
END IF;
utl_file.new_line ( l_output );
l_cnt := l_cnt + 1;
END LOOP;
dbms_sql.close_cursor ( l_thecursor );
utl_file.fclose ( l_output );
RETURN l_cnt;
EXCEPTION
WHEN NO_DATA_FOUND
THEN
dbms_output.put_line ( 'NO_DATA_FOUND' );
utl_file.fclose ( l_output );
RETURN l_cnt;
WHEN utl_file.invalid_path
THEN
dbms_output.put_line ( 'UTL_FILE.INVALID_PATH' );
utl_file.fclose ( l_output );
RETURN l_cnt;
WHEN utl_file.read_error
THEN
dbms_output.put_line ( 'UTL_FILE.READ_ERROR' );
utl_file.fclose ( l_output );
RETURN l_cnt;
WHEN utl_file.write_error
THEN
dbms_output.put_line ( 'UTL_FILE.WRITE_ERROR' );
utl_file.fclose ( l_output );
RETURN l_cnt;
WHEN utl_file.invalid_mode
THEN
dbms_output.put_line ( 'UTL_FILE.INVALID_MODE' );
utl_file.fclose ( l_output );
RETURN l_cnt;
WHEN utl_file.invalid_filehandle
THEN
dbms_output.put_line ( 'UTL_FILE.INVALID_FILEHANDLE' );
utl_file.fclose ( l_output );
RETURN l_cnt;
WHEN utl_file.invalid_operation
THEN
dbms_output.put_line ( 'UTL_FILE.INVALID_OPERATION' );
utl_file.fclose ( l_output );
RETURN l_cnt;
WHEN utl_file.internal_error
THEN
dbms_output.put_line ( 'UTL_FILE.INTERNAL_ERROR' );
utl_file.fclose ( l_output );
RETURN l_cnt;
WHEN utl_file.invalid_maxlinesize
THEN
dbms_output.put_line ( 'UTL_FILE.INVALID_MAXLINESIZE' );
utl_file.fclose ( l_output );
RETURN l_cnt;
WHEN VALUE_ERROR
THEN
dbms_output.put_line ( 'UTL_FILE.VALUE_ERROR' );
utl_file.fclose ( l_output );
RETURN l_cnt;
WHEN OTHERS
THEN
hum_do.default_exception ( 'ERROR in dump_csv : ' );
utl_file.fclose ( l_output );
RETURN l_cnt;
END dump_flatfile;
-- Return the next email address in the list of email addresses, separated
-- by either a "," or a ";". The format of mailbox may be in one of these:
-- someone@some-domain
-- "Someone at some domain" <someone@some-domain>
-- Someone at some domain <someone@some-domain>
FUNCTION get_mail_address (
addr_list IN OUT VARCHAR2 )
RETURN VARCHAR2
IS
addr VARCHAR2 ( 256 );
i PLS_INTEGER;
FUNCTION lookup_unquoted_char (
str IN VARCHAR2
, chrs IN VARCHAR2 )
RETURN PLS_INTEGER
AS
c VARCHAR2 ( 5 );
i PLS_INTEGER;
len PLS_INTEGER;
inside_quote BOOLEAN;
BEGIN
inside_quote := FALSE;
i := 1;
len := LENGTH ( str );
WHILE ( i <= len )
LOOP
c := SUBSTR ( str
, i
, 1 );
IF ( inside_quote )
THEN
IF ( c = '"' )
THEN
inside_quote := FALSE;
ELSIF ( c = '\' )
THEN
i := i + 1;
-- Skip the quote character
END IF;
GOTO next_char;
END IF;
IF ( c = '"' )
THEN
inside_quote := TRUE;
GOTO next_char;
END IF;
IF ( INSTR ( chrs, c ) >= 1 )
THEN
RETURN i;
END IF;
<<next_char>>
i := i + 1;
END LOOP;
RETURN 0;
END;
BEGIN
addr_list := LTRIM ( addr_list );
i := lookup_unquoted_char ( addr_list, ',;' );
IF ( i >= 1 )
THEN
addr := SUBSTR ( addr_list
, 1
, i - 1 );
addr_list := SUBSTR ( addr_list, i + 1 );
ELSE
addr := addr_list;
addr_list := '';
END IF;
i := lookup_unquoted_char ( addr, '<' );
IF ( i >= 1 )
THEN
addr := SUBSTR ( addr, i + 1 );
i := INSTR ( addr, '>' );
IF ( i >= 1 )
THEN
addr := SUBSTR ( addr
, 1
, i - 1 );
END IF;
END IF;
RETURN addr;
END;
FUNCTION smtp_command (
command IN VARCHAR2
, ok IN VARCHAR2 DEFAULT '250'
, code OUT VARCHAR2
, DEBUG NUMBER DEFAULT 0 )
RETURN BOOLEAN
IS
response VARCHAR2 ( 3 );
p_output_message VARCHAR2 ( 255 );
len PLS_INTEGER;
PRAGMA AUTONOMOUS_TRANSACTION;
BEGIN
len := utl_tcp.write_line ( conn, command );
p_output_message := SUBSTR ( utl_tcp.get_line ( conn, TRUE )
, 1
, 255 );
response := SUBSTR ( p_output_message
, 1
, 3 );
p_output_message :=
SUBSTR ( command || ' - ' || p_output_message
, 1
, 255 );
IF DEBUG = 1
THEN -- No Output
NULL;
ELSE -- Then DBMS_OUTPUT messages
print_output ( p_output_message );
END IF;
IF ( response <> ok )
THEN
code := response;
RETURN FALSE;
ELSE
code := response;
RETURN TRUE;
END IF;
EXCEPTION
WHEN OTHERS
THEN
p_output_message := SQLCODE || ' - ' || SQLERRM;
code := p_output_message;
RETURN FALSE;
END smtp_command;
FUNCTION query_server (
smtp_server VARCHAR2
, smtp_server_port PLS_INTEGER DEFAULT 25
, DEBUG NUMBER DEFAULT 0 )
RETURN BOOLEAN
IS
p_output_message VARCHAR2 ( 255 );
PRAGMA AUTONOMOUS_TRANSACTION;
err_noop EXCEPTION; -- SMTP code 250 not received
err_server_reject EXCEPTION;
-- SMTP code 421 means rejected
BEGIN
v_smtp_server := smtp_server;
v_smtp_server_port := smtp_server_port;
-- Open the SMTP connection ...
conn :=
utl_tcp.open_connection ( remote_host => v_smtp_server
, remote_port => v_smtp_server_port
, tx_timeout => tx_timeout );
----- OPEN SMTP PORT CONNECTION
rc := utl_tcp.write_line ( conn, 'HELO ' || v_smtp_server );
-- This will return a 250 OK response if your connection is valid
-- Initial handshaking ...
----- PERFORMS HANDSHAKING WITH SMTP SERVER
p_output_message := utl_tcp.get_line ( conn, TRUE );
IF DEBUG = 1
THEN -- No Output
NULL;
ELSE -- Then DBMS_OUTPUT messages
print_output ( p_output_message );
END IF;
IF SUBSTR ( p_output_message
, 1
, 3 ) = '421'
THEN
RAISE err_server_reject;
END IF;
-- NOOP THE SERVER
rc := utl_tcp.write_line ( conn, 'NOOP' );
-- This will return a 250 OK response if your connection is valid
-- Initial handshaking ...
----- PERFORMS NOOP WITH SMTP SERVER
p_output_message := utl_tcp.get_line ( conn, TRUE );
IF DEBUG = 1
THEN -- No Output
NULL;
ELSE -- Then DBMS_OUTPUT messages
print_output ( p_output_message );
END IF;
IF SUBSTR ( p_output_message
, 1
, 3 ) <> '250'
THEN
RAISE err_noop;
END IF;
rc := utl_tcp.write_line ( conn, 'QUIT' );
----- ENDS EMAIL TRANSACTION
BEGIN
FOR i_idx IN 1 .. 100
LOOP
p_output_message := utl_tcp.get_line ( conn, TRUE );
IF DEBUG = 1
THEN -- No Output
NULL;
ELSE -- Then DBMS_OUTPUT messages
print_output ( p_output_message );
END IF;
END LOOP;
EXCEPTION
WHEN OTHERS
THEN
IF DEBUG = 1
THEN -- No Output
NULL;
ELSE -- Then DBMS_OUTPUT messages
print_output ( p_output_message );
END IF;
END;
utl_tcp.close_connection ( conn ); ----- CLOSE SMTP PORT CONNECTION
RETURN TRUE;
EXCEPTION
WHEN err_server_reject
THEN
print_output ( 'ERROR -'
|| ' Server Rejected Connection ::'
|| ' SERVER_MSG := '
|| p_output_message );
RETURN FALSE;
WHEN err_noop
THEN
print_output ( 'ERROR -'
|| ' NOOP Check Failed ::'
|| ' SERVER_MSG := '
|| p_output_message );
utl_tcp.close_connection ( conn ); ----- CLOSE SMTP PORT CONNECTION
RETURN FALSE;
END query_server;
FUNCTION get_local_binary_data (
p_dir IN VARCHAR2
, p_file IN VARCHAR2 )
RETURN BLOB
IS
l_bfile BFILE;
l_data BLOB;
l_dbdir VARCHAR2 ( 100 ) := p_dir;
BEGIN
dbms_lob.createtemporary ( lob_loc => l_data
, CACHE => TRUE
, dur => dbms_lob.CALL );
l_bfile := BFILENAME ( l_dbdir, p_file );
dbms_lob.fileopen ( l_bfile, dbms_lob.file_readonly );
dbms_lob.loadfromfile ( l_data
, l_bfile
, dbms_lob.getlength ( l_bfile ));
dbms_lob.fileclose ( l_bfile );
RETURN l_data;
EXCEPTION
WHEN OTHERS
THEN
print_output ( 'Error during GET_LOCAL_BINARY_DATA :: '
|| SQLCODE
|| ' - '
|| SQLERRM );
dbms_lob.fileclose ( l_bfile );
RAISE;
END get_local_binary_data;
PROCEDURE attach_base64 (
conn IN OUT NOCOPY utl_tcp.connection
, DATA IN BLOB )
IS
i PLS_INTEGER;
len PLS_INTEGER;
l_result PLS_INTEGER;
l_buffer RAW ( 32767 );
l_pos INTEGER := 1;
l_blob_len INTEGER;
l_amount BINARY_INTEGER := 32767;
req utl_http.req;
resp utl_http.resp;
pdata RAW ( 200 );
BEGIN
-- Split the Base64-encoded attachment into multiple lines
-- In writing Base-64 encoded text following the MIME format below,
-- the MIME format requires that a long piece of data must be splitted
-- into multiple lines and each line of encoded data cannot exceed
-- 80 characters, including the new-line characters. Also, when
-- splitting the original data into pieces, the length of each chunk
-- of data before encoding must be a multiple of 3, except for the
-- last chunk. The constant MAX_BASE64_LINE_WIDTH
-- (76 / 4 * 3 = 57) is the maximum length (in bytes) of each chunk
-- of data before encoding.
l_blob_len := dbms_lob.getlength ( DATA );
WHILE l_pos < l_blob_len
LOOP
l_amount := max_base64_line_width;
dbms_lob.READ ( DATA
, l_amount
, l_pos
, l_buffer );
rc := utl_tcp.write_raw ( conn, utl_encode.base64_encode ( l_buffer ));
utl_tcp.FLUSH ( conn );
l_pos := l_pos + max_base64_line_width;
rc := utl_tcp.write_line ( conn, crlf );
END LOOP;
END attach_base64;
PROCEDURE sendmail (
smtp_server VARCHAR2
, smtp_server_port PLS_INTEGER DEFAULT 25
, from_name VARCHAR2
, to_name VARCHAR2
, cc_name VARCHAR2 DEFAULT NULL
, bcc_name VARCHAR2 DEFAULT NULL
, subject VARCHAR2
, MESSAGE CLOB
, priority PLS_INTEGER DEFAULT NULL
, filename VARCHAR2 DEFAULT NULL
, binaryfile BLOB DEFAULT EMPTY_BLOB ( )
, DEBUG NUMBER DEFAULT 0 )
IS
pos PLS_INTEGER := 1;
bytes_o_data CONSTANT PLS_INTEGER := 32767;
offset PLS_INTEGER := bytes_o_data;
msg_length CONSTANT PLS_INTEGER
:= dbms_lob.getlength ( MESSAGE );
v_line VARCHAR2 ( 32767 );
i BINARY_INTEGER;
v_slash_pos NUMBER;
my_recipients VARCHAR2 ( 32767 );
p_recipient_count PLS_INTEGER := 0;
p_output_message VARCHAR2 ( 2000 );
PRAGMA AUTONOMOUS_TRANSACTION;
err_server_reject EXCEPTION;
-- SMTP code 421 means rejected
err_message_send EXCEPTION; -- SMTP code must be 250
err_end_of_input EXCEPTION;
-- Used to signify last line of input retrieved
l_result PLS_INTEGER;
l_buffer_b RAW ( 32767 );
l_amount BINARY_INTEGER := 32767;
l_pos INTEGER := 1;
l_blob_len INTEGER;
l_blob BLOB;
g_debug BOOLEAN := TRUE;
i_base64 PLS_INTEGER;
len_base64 PLS_INTEGER;
BEGIN
v_smtp_server := smtp_server;
v_smtp_server_port := smtp_server_port;
l_blob := binaryfile;
-- Open the SMTP connection ...
conn :=
utl_tcp.open_connection ( remote_host => v_smtp_server
, remote_port => v_smtp_server_port
, tx_timeout => tx_timeout );
----- OPEN SMTP PORT CONNECTION
rc := utl_tcp.write_line ( conn, 'HELO ' || v_smtp_server );
-- Initial handshaking ...
----- PERFORMS HANDSHAKING WITH SMTP SERVER
p_output_message := utl_tcp.get_line ( conn, TRUE );
IF DEBUG = 1
THEN -- No Output
NULL;
ELSE -- Then DBMS_OUTPUT messages
print_output ( p_output_message );
END IF;
IF SUBSTR ( p_output_message
, 1
, 3 ) = '421'
THEN
RAISE err_server_reject;
ELSE
-- DBMS_OUTPUT.put_line (UTL_TCP.get_line (conn, TRUE));
rc := utl_tcp.write_line ( conn, 'MAIL FROM: ' || from_name );
----- MBOX SENDING THE EMAIL
p_output_message := utl_tcp.get_line ( conn, TRUE );
IF DEBUG = 1
THEN -- No Output
NULL;
ELSE -- Then DBMS_OUTPUT messages
print_output ( p_output_message );
END IF;
-- DBMS_OUTPUT.put_line (UTL_TCP.get_line (conn, TRUE));
-- rc := UTL_TCP.write_line (conn, 'RCPT TO: ' || to_name);
-- Specify recipient(s) of the email.
my_recipients := to_name;
WHILE ( my_recipients IS NOT NULL )
LOOP
BEGIN
rc :=
utl_tcp.write_line ( conn
, 'RCPT TO: '
|| get_mail_address ( my_recipients ));
p_recipient_count := p_recipient_count + 1;
END;
END LOOP;
-- DBMS_OUTPUT.put_line ('RCPT TO: COUNT ' || p_recipient_count);
----- MBOX RECV THE EMAIL
p_output_message := utl_tcp.get_line ( conn, TRUE );
IF DEBUG = 1
THEN -- No Output
NULL;
ELSE -- Then DBMS_OUTPUT messages
print_output ( p_output_message );
END IF;
-- DBMS_OUTPUT.put_line (UTL_TCP.get_line (conn, TRUE));
-- rc := UTL_TCP.write_line (conn, 'RCPT TO: ' || cc_name);
-- Specify cc recipient(s) of the email.
my_recipients := cc_name;
WHILE ( my_recipients IS NOT NULL )
LOOP
BEGIN
rc :=
utl_tcp.write_line ( conn
, 'RCPT TO: '
|| get_mail_address ( my_recipients ));
p_recipient_count := p_recipient_count + 1;
END;
END LOOP;
-- DBMS_OUTPUT.put_line ('RCPT TO: COUNT ' || p_recipient_count);
----- MBOX RECV THE EMAIL
p_output_message := utl_tcp.get_line ( conn, TRUE );
IF DEBUG = 1
THEN -- No Output
NULL;
ELSE -- Then DBMS_OUTPUT messages
print_output ( p_output_message );
END IF;
-- DBMS_OUTPUT.put_line (UTL_TCP.get_line (conn, TRUE));
-- rc := UTL_TCP.write_line (conn, 'RCPT TO: ' || bcc_name);
-- Specify bcc recipient(s) of the email.
my_recipients := bcc_name;
WHILE ( my_recipients IS NOT NULL )
LOOP
BEGIN
rc :=
utl_tcp.write_line ( conn
, 'RCPT TO: '
|| get_mail_address ( my_recipients ));
p_recipient_count := p_recipient_count + 1;
END;
END LOOP;
-- DBMS_OUTPUT.put_line ('RCPT TO: COUNT ' || p_recipient_count);
----- MBOX RECV THE EMAIL
p_output_message := utl_tcp.get_line ( conn, TRUE );
IF DEBUG = 1
THEN -- No Output
NULL;
ELSE -- Then DBMS_OUTPUT messages
print_output ( p_output_message );
END IF;
-- DBMS_OUTPUT.put_line (UTL_TCP.get_line (conn, TRUE));
rc := utl_tcp.write_line ( conn, 'DATA' );
----- EMAIL MSG BODY START
p_output_message := utl_tcp.get_line ( conn, TRUE );
IF DEBUG = 1
THEN -- No Output
NULL;
ELSE -- Then DBMS_OUTPUT messages
print_output ( p_output_message );
END IF;
-- DBMS_OUTPUT.put_line (UTL_TCP.get_line (conn, TRUE));
-- build the start of the mail message ...
rc := utl_tcp.write_line ( conn, p_datestring );
rc := utl_tcp.write_line ( conn, 'From: ' || from_name );
rc := utl_tcp.write_line ( conn, 'Subject: ' || subject );
rc := utl_tcp.write_line ( conn, 'To: ' || to_name );
IF cc_name IS NOT NULL
THEN
rc := utl_tcp.write_line ( conn, 'Cc: ' || cc_name );
END IF;
IF bcc_name IS NOT NULL
THEN
rc := utl_tcp.write_line ( conn, 'Bcc: ' || bcc_name );
END IF;
rc := utl_tcp.write_line ( conn, 'Mime-Version: 1.0' );
-- Set priority:
-- High Normal Low
-- 1 2 3 4 5
IF ( priority IS NOT NULL )
THEN
rc := utl_tcp.write_line ( conn, 'X-Priority: ' || priority );
END IF;
rc := utl_tcp.write_line ( conn, 'X-Mailer: ' || mailer_id );
rc :=
utl_tcp.write_line
( conn
, 'Content-Type: multipart/mixed; boundary="=_mixed 0052287A85256E75_="' );
rc := utl_tcp.write_line ( conn, '' );
rc :=
utl_tcp.write_line
( conn
, 'This is a Mime message, which your current mail reader may not' );
rc :=
utl_tcp.write_line
( conn
, 'understand. Parts of the message will appear as text. If the remainder' );
rc :=
utl_tcp.write_line
( conn
, 'appears as random characters in the message body, instead of as' );
rc :=
utl_tcp.write_line
( conn
, 'attachments, then you''ll have to extract these parts and decode them' );
rc := utl_tcp.write_line ( conn, 'manually.' );
rc := utl_tcp.write_line ( conn, '' );
rc := utl_tcp.write_line ( conn, '--=_mixed 0052287A85256E75_=' );
rc :=
utl_tcp.write_line ( conn
, 'Content-Type: text/html; charset=8859-1' );
rc := utl_tcp.write_line ( conn, '' );
rc := utl_tcp.write_line ( conn, '<html>' );
rc := utl_tcp.write_line ( conn, '<head>' );
rc :=
utl_tcp.write_line
( conn
, '<meta http-equiv="Content-Type" content="text/html;charset=8859-1">' );
rc := utl_tcp.write_line ( conn, '<title>' );
rc := utl_tcp.write_line ( conn, subject );
rc := utl_tcp.write_line ( conn, '</title>' );
rc := utl_tcp.write_line ( conn, '</head>' );
rc := utl_tcp.write_line ( conn, '<body>' );
WHILE pos < msg_length
LOOP
rc :=
utl_tcp.write_line ( conn
, dbms_lob.SUBSTR ( MESSAGE
, offset
, pos ));
pos := pos + offset;
offset := LEAST ( bytes_o_data, msg_length - offset );
END LOOP;
rc := utl_tcp.write_line ( conn, '<BR><BR>' );
rc := utl_tcp.write_line ( conn, '</body></html>' );
rc := utl_tcp.write_line ( conn, '' );
rc := utl_tcp.write_line ( conn, crlf );
-- Append the file BLOB ...
-- If the filename has been supplied ... it will fail if the BLOB is empty
IF filename IS NOT NULL
THEN
BEGIN
-- generate the MIME boundary line ...
rc :=
utl_tcp.write_line ( conn, '--=_mixed 0052287A85256E75_=' );
rc :=
utl_tcp.write_line
( conn
, 'Content-Type: application/octet-stream; name="'
|| filename
|| '"' );
rc :=
utl_tcp.write_line
( conn
, 'Content-Disposition: attachment; filename="'
|| filename
|| '"' );
rc :=
utl_tcp.write_line ( conn
, 'Content-Transfer-Encoding: base64' );
rc := utl_tcp.write_line ( conn, '' );
rc := utl_tcp.write_line ( conn, '' );
-- and append the file contents to the end of the message ...
-- Go get the file and the loop through blob and attach data
-- and append the file contents to the end of the message ...
attach_base64 ( conn => conn
, DATA => l_blob );
EXCEPTION
WHEN OTHERS
THEN
p_output_message :=
'Error in attaching file '
|| filename
|| ' :: '
|| SQLCODE
|| ' - '
|| SQLERRM;
IF DEBUG = 1
THEN -- No Output
NULL;
ELSE -- Then DBMS_OUTPUT messages
print_output ( p_output_message );
END IF;
RAISE err_message_send;
END;
END IF;
rc := utl_tcp.write_line ( conn, '' );
-- append the final boundary line ...
rc := utl_tcp.write_line ( conn, '' );
rc := utl_tcp.write_line ( conn, '--=_mixed 0052287A85256E75_=--' );
rc := utl_tcp.write_line ( conn, '' );
-- and close the SMTP connection ...
rc := utl_tcp.write_line ( conn, '.' );
----- EMAIL MESSAGE BODY END
p_output_message := utl_tcp.get_line ( conn, TRUE );
IF DEBUG = 1
THEN -- No Output
NULL;
ELSE -- Then DBMS_OUTPUT messages
print_output ( p_output_message );
END IF;
-- DBMS_OUTPUT.put_line (UTL_TCP.get_line (conn, TRUE));
rc := utl_tcp.write_line ( conn, 'QUIT' );
----- ENDS EMAIL TRANSACTION
p_output_message := utl_tcp.get_line ( conn, TRUE );
-- Capture '.' Message sent dialog
IF DEBUG = 1
THEN -- No Output
NULL;
ELSE -- Then DBMS_OUTPUT messages
print_output ( p_output_message );
END IF;
BEGIN
FOR i_idx IN 1 .. 100
LOOP
p_output_message := utl_tcp.get_line ( conn, TRUE );
IF DEBUG = 1
THEN -- No Output
NULL;
ELSE -- Then DBMS_OUTPUT messages
print_output ( p_output_message );
END IF;
END LOOP;
EXCEPTION
WHEN OTHERS
THEN
IF DEBUG = 1
THEN -- No Output
NULL;
ELSE -- Then DBMS_OUTPUT messages
print_output ( p_output_message );
END IF;
END;
END IF; -- err_server_reject
utl_tcp.close_connection ( conn ); ----- CLOSE SMTP PORT CONNECTION
EXCEPTION
WHEN err_message_send
THEN
print_output ( CHR ( 10 )
|| CHR ( 10 )
|| 'ERROR -'
|| ' Message was not submitted for delivery' );
print_output ( ' [FROM_NAME := ' || from_name || '] ' );
print_output ( ' [TO_NAME := ' || to_name || '] ' );
print_output ( ' [CC_NAME := ' || cc_name || '] ' );
print_output ( ' [BCC_NAME := ' || bcc_name || '] ' );
print_output ( ' [SUBJECT := ' || subject || '] ' );
print_output ( ' SERVER_MSG := ' || p_output_message );
utl_tcp.close_connection ( conn ); ----- CLOSE SMTP PORT CONNECTION
WHEN err_server_reject
THEN
print_output ( CHR ( 10 )
|| CHR ( 10 )
|| 'ERROR -'
|| ' Server Rejected Email' );
print_output ( ' [FROM_NAME := ' || from_name || '] ' );
print_output ( ' [TO_NAME := ' || to_name || '] ' );
print_output ( ' [CC_NAME := ' || cc_name || '] ' );
print_output ( ' [BCC_NAME := ' || bcc_name || '] ' );
print_output ( ' [SUBJECT := ' || subject || '] ' );
print_output ( ' SERVER_MSG := ' || p_output_message );
WHEN OTHERS
THEN
print_output ( CHR ( 10 )
|| CHR ( 10 )
|| 'ERROR :: '
|| SQLCODE
|| ' - '
|| SQLERRM );
print_output ( ' [FROM_NAME := ' || from_name || '] ' );
print_output ( ' [TO_NAME := ' || to_name || '] ' );
print_output ( ' [CC_NAME := ' || cc_name || '] ' );
print_output ( ' [BCC_NAME := ' || bcc_name || '] ' );
print_output ( ' [SUBJECT := ' || subject || '] ' );
print_output ( ' SERVER_MSG := ' || p_output_message );
END sendmail;
END;
/Perhaps your new SMTP server requires a more secure form of authentication than AUTH LOGIN. If you telnet to this new SMTP server on port 25 you should be issue the HELO or EHLO command to find out what AUTH mechanisms the server supports. You could then alter your code to use one of the supported authentication mechanisms.
-
Wireless card BCM4313 no connection at boot
Hi,
I have an HP Pavilion dv6 with a Broadcom BCM4313 wireless card. I use NETCFG and before the last kernel upgrade I was able to connect to my home wireless connection at boot without troubles. Now I have to do it manually and I need to try 2 or 3 times to see my connection active.
lspci -vnn
02:00.0 Network controller [0280]: Broadcom Corporation BCM4313 802.11b/g/n Wireless LAN Controller [14e4:4727] (rev 01)
Subsystem: Hewlett-Packard Company Device [103c:1483]
Flags: bus master, fast devsel, latency 0, IRQ 16
Memory at c3400000 (64-bit, non-prefetchable) [size=16K]
Capabilities: <access denied>
Kernel driver in use: brcmsmac
Kernel modules: bcma, wl, brcmsmac
lsmod
Module Size Used by
cpufreq_stats 3890 0
radeon 992718 0
ttm 54360 1 radeon
ipv6 290407 22
cpufreq_ondemand 6132 4
uvcvideo 64931 0
videodev 78006 1 uvcvideo
media 10437 2 uvcvideo,videodev
usbhid 35256 0
hid 81635 1 usbhid
v4l2_compat_ioctl32 8292 1 videodev
snd_hda_codec_hdmi 22092 1
joydev 9895 0
snd_hda_codec_idt 55175 1
i915 707307 7
snd_hda_intel 22122 0
snd_hda_codec 77927 3 snd_hda_codec_hdmi,snd_hda_codec_idt,snd_hda_intel
drm_kms_helper 25409 2 radeon,i915
lib80211_crypt_tkip 8506 0
drm 183380 5 radeon,ttm,i915,drm_kms_helper
snd_hwdep 6325 1 snd_hda_codec
snd_pcm 73856 3 snd_hda_codec_hdmi,snd_hda_intel,snd_hda_codec
snd_timer 19416 1 snd_pcm
r8169 42643 0
lib80211 4158 1 lib80211_crypt_tkip
snd 57786 7 snd_hda_codec_hdmi,snd_hda_codec_idt,snd_hda_intel,snd_hda_codec,snd_hwdep,snd_pcm,snd_timer
sg 25557 0
hp_accel 13864 0
lis3lv02d 10508 1 hp_accel
i2c_i801 8187 0
serio_raw 4294 0
iTCO_wdt 12717 0
hp_wmi 7738 0
intel_agp 10904 1 i915
arc4 1410 2
btusb 11577 0
evdev 9530 9
bluetooth 138465 1 btusb
soundcore 6146 1 snd
bcma 13762 0
i2c_algo_bit 5199 2 radeon,i915
sparse_keymap 3088 1 hp_wmi
mei 31249 0
i2c_core 20133 7 radeon,videodev,i915,drm_kms_helper,drm,i2c_i801,i2c_algo_bit
iTCO_vendor_support 1929 1 iTCO_wdt
pcspkr 1819 0
snd_page_alloc 7121 2 snd_hda_intel,snd_pcm
intel_ips 11213 0
psmouse 55224 0
intel_gtt 14423 3 i915,intel_agp
mii 3995 1 r8169
input_polldev 2882 1 lis3lv02d
battery 10905 0
wmi 8411 1 hp_wmi
ac 3265 0
button 4470 1 i915
brcmsmac 594624 0
thermal 7863 0
video 11228 1 i915
brcmutil 6563 1 brcmsmac
mac80211 215605 1 brcmsmac
cfg80211 160516 2 brcmsmac,mac80211
rfkill 15402 3 hp_wmi,bluetooth,cfg80211
crc_ccitt 1331 1 brcmsmac
acpi_cpufreq 5877 1
freq_table 2451 3 cpufreq_stats,cpufreq_ondemand,acpi_cpufreq
processor 24256 1 acpi_cpufreq
mperf 1275 1 acpi_cpufreq
ext4 369556 2
mbcache 5817 1 ext4
jbd2 71074 1 ext4
crc16 1297 2 bluetooth,ext4
sr_mod 14951 0
sd_mod 28307 4
cdrom 36329 1 sr_mod
ahci 20865 3
libahci 18885 1 ahci
libata 173297 2 ahci,libahci
ehci_hcd 39511 0
scsi_mod 131482 4 sg,sr_mod,sd_mod,libata
usbcore 142544 5 uvcvideo,usbhid,btusb,ehci_hcd
dmesg | grep wlan0
[ 11.715805] ADDRCONF(NETDEV_UP): wlan0: link is not ready
[ 13.791409] ADDRCONF(NETDEV_UP): wlan0: link is not ready
[ 16.885059] wlan0: authenticate with 50:67:f0:ab:4f:d4 (try 1)
[ 16.886567] wlan0: authenticated
[ 16.890100] wlan0: associate with 50:67:f0:ab:4f:d4 (try 1)
[ 16.892793] wlan0: RX AssocResp from 50:67:f0:ab:4f:d4 (capab=0x471 status=0 aid=1)
[ 16.892798] wlan0: associated
[ 16.894146] ADDRCONF(NETDEV_CHANGE): wlan0: link becomes ready
[ 26.697130] wlan0: deauthenticating from 50:67:f0:ab:4f:d4 by local choice (reason=3)
[ 87.612906] ADDRCONF(NETDEV_UP): wlan0: link is not ready
[ 89.754106] ADDRCONF(NETDEV_UP): wlan0: link is not ready
[ 92.849882] wlan0: authenticate with 50:67:f0:ab:4f:d4 (try 1)
[ 92.851661] wlan0: authenticated
[ 92.851823] wlan0: associate with 50:67:f0:ab:4f:d4 (try 1)
[ 92.854142] wlan0: RX AssocResp from 50:67:f0:ab:4f:d4 (capab=0x471 status=0 aid=1)
[ 92.854150] wlan0: associated
[ 92.855920] ADDRCONF(NETDEV_CHANGE): wlan0: link becomes ready
[ 103.719958] wlan0: no IPv6 routers present
[ 105.980215] wlan0: deauthenticating from 50:67:f0:ab:4f:d4 by local choice (reason=3)
[ 120.237260] ADDRCONF(NETDEV_UP): wlan0: link is not ready
[ 122.316759] ADDRCONF(NETDEV_UP): wlan0: link is not ready
[ 125.422195] wlan0: authenticate with 50:67:f0:ab:4f:d4 (try 1)
[ 125.423760] wlan0: authenticated
[ 125.423960] wlan0: associate with 50:67:f0:ab:4f:d4 (try 1)
[ 125.426083] wlan0: RX AssocResp from 50:67:f0:ab:4f:d4 (capab=0x471 status=0 aid=1)
[ 125.426090] wlan0: associated
[ 125.428085] ADDRCONF(NETDEV_CHANGE): wlan0: link becomes ready
[ 136.398877] wlan0: no IPv6 routers present
You could see that first I get the connection and then I lost it... for 2 or 3 times, then I could connect without problems.
ifconfig
lo Link encap:Local Loopback
inet addr:127.0.0.1 Mask:255.0.0.0
inet6 addr: ::1/128 Scope:Host
UP LOOPBACK RUNNING MTU:16436 Metric:1
RX packets:338 errors:0 dropped:0 overruns:0 frame:0
TX packets:338 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:0
RX bytes:27772 (27.1 Kb) TX bytes:27772 (27.1 Kb)
wlan0 Link encap:Ethernet HWaddr E0:2A:82:A2:B5:88
inet addr:192.168.1.33 Bcast:192.168.1.255 Mask:255.255.255.0
inet6 addr: fe80::e22a:82ff:fea2:b588/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:12484 errors:0 dropped:0 overruns:0 frame:0
TX packets:9606 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:13841736 (13.2 Mb) TX bytes:1241490 (1.1 Mb)
iwconfig
wlan0 IEEE 802.11bgn ESSID:"WLAN_A9"
Mode:Managed Frequency:2.452 GHz Access Point: 50:67:F0:AB:4F:D4
Bit Rate=54 Mb/s Tx-Power=19 dBm
Retry long limit:7 RTS thr:off Fragment thr:off
Power Management:off
Link Quality=40/70 Signal level=-70 dBm
Rx invalid nwid:0 Rx invalid crypt:0 Rx invalid frag:0
Tx excessive retries:0 Invalid misc:82 Missed beacon:0
my wirelessCasa netcfg profile
CONNECTION='wireless'
DESCRIPTION='A simple WEP encrypted wireless connection'
INTERFACE='wlan0'
SECURITY='wep'
ESSID='WLAN_A9'
KEY='s:mykey'
IP='dhcp'
POST_UP="notify-send -u critical -i /usr/share/icons/Faenza/status/48/connect_established.png -t 15000 'Connected to WLAN_A9'"
POST_DOWN="notify-send -u critical -i /usr/share/icons/Faenza/status/48/gnome-netstatus-disconn.png -t 15000 'Connection lost'"
# Uncomment this if your ssid is hidden
#HIDDEN=yes
rc.conf
NETWORKS=(wirelessCasa)
DAEMONS=(syslog-ng dbus net-profiles net-auto-wired !network !netfs crond laptop-mode alsa slim @acpid @cups)
When I execute netcfg for the first time (after boot) I see:
#NETCFG_DEBUG=yes netcfg wirelessCasa
DEBUG: Loading profile wirelessCasa
DEBUG: Configuring interface wlan0
:: wirelessCasa up [BUSY] DEBUG: status reported to profile_up as:
DEBUG: Loading profile wirelessCasa
DEBUG: Configuring interface wlan0
DEBUG: wireless_up stop_wpa wlan0
DEBUG: wireless_up start_wpa wlan0 /run/network//wpa.wlan0/wpa.conf nl80211,wext
DEBUG: wireless_up stop_wpa wlan0
DEBUG: wireless_up Configuration generated at /run/network//wpa.wlan0/wpa.conf
DEBUG: wireless_up ifup
DEBUG: wireless_up start_wpa wlan0 /run/network//wpa.wlan0/wpa.conf nl80211,wext
DEBUG: wireless_up wpa_check
DEBUG: wpa_cli -p /run/wpa_supplicant -i wlan0 status
DEBUG: Loading profile wirelessCasa
DEBUG: Configuring interface wlan0
DEBUG: ethernet_iproute_up ifup
DEBUG: ethernet_up dhcpcd -qL -t 10 wlan0
DEBUG:
> DHCP IP lease attempt failed.
DEBUG: Loading profile wirelessCasa
DEBUG: Configuring interface wlan0
DEBUG: Loading profile wirelessCasa
DEBUG: Configuring interface wlan0
DEBUG: ethernet_down if_down
DEBUG: wireless_down stop_wpa wlan0
DEBUG: profile_up connect failed
[FAIL]
And the second one:
#NETCFG_DEBUG=yes netcfg wirelessCasa
DEBUG: Loading profile wirelessCasa
DEBUG: Configuring interface wlan0
:: wirelessCasa up [BUSY] DEBUG: status reported to profile_up as:
DEBUG: Loading profile wirelessCasa
DEBUG: Configuring interface wlan0
DEBUG: wireless_up stop_wpa wlan0
DEBUG: wireless_up start_wpa wlan0 /run/network//wpa.wlan0/wpa.conf nl80211,wext
DEBUG: wireless_up stop_wpa wlan0
DEBUG: wireless_up Configuration generated at /run/network//wpa.wlan0/wpa.conf
DEBUG: wireless_up ifup
DEBUG: wireless_up start_wpa wlan0 /run/network//wpa.wlan0/wpa.conf nl80211,wext
DEBUG: wireless_up wpa_check
DEBUG: wpa_cli -p /run/wpa_supplicant -i wlan0 status
DEBUG: Loading profile wirelessCasa
DEBUG: Configuring interface wlan0
DEBUG: ethernet_iproute_up ifup
DEBUG: ethernet_up dhcpcd -qL -t 10 wlan0
DEBUG:
DEBUG: ethernet_iproute_up hostname archlap
[DONE]
I've tried to use the wl driver but it doesn't seems to work properly.
Could anyone help me please?
Thank you,
enricolitemotiv wrote:
Hmm it seems your card now takes longer to connect, the 'deauthenticating by local choice' often means that the default timeout is reached and netcfg disconnects. You can try adding a specific timeout parameter to your netcfg profile:
TIMEOUT=60
That doesn't explain why it takes longer to connect than before, but at least you should be able to connect in 1 try again.
Hi,
thank you for your time!
I'v tried adding the timeout line to my profile but it doesn't change nothing
I could connect at 3rd try.
Any other idea? -
Save report as pdf in the database
Hi all,
is it possible to save the generated pdf from reports10g in the database?
RegardsHere is what I was looking for:
re:How to get cookie information or http headers values inside Oracle reports
pr_example in the above forum was written under 8i. In 9i, they added the timeout which is set to a default of 60 seconds. Look at the UTL_HTTP package spec on more information on setting this timeout.
Plus, printing the BLOB is easier too. You can just use wpg_docload.download_file instead of using the while loop.
Anyway, that example shows you how to call a report from a stored procedure, store it in a blob, and even it print it back to the browser. -
Dear Sir/Madam,
Appreciate that you could advise me on the following error occur when connect power meter E4419B to computer via E5810A LAN/GPIB Gateway(remote interface) & run with Labview:
-1073807339
VISA Write in E4419_read_power.vi
I have added 5s timeout to Labview program but the result as previous.
There no error occurs when the power meter to computer via USB/GPIB interface(82357B).
Is it related to E5810A driver or the program I wrote?
How to resolve it?
Attachments:
E4419_read_power.vi 16 KBHi.
I'm experiencing the same problem when connecting a laser controller (New Focus Vortex TLB-6000) via the Agilent E5810A to a PC.
There are no problems when connected through a regular serial port, but timeouts arise every few seconds through the E5810A. I have another controller (SRS LDC501) which works very well with a second Agilent console.
Have you managed to find a solution to this problem?
Thanks,
Orel. -
Hi everybody:
This is not the typical question about this error, because the problem here is not about how to quit (CLEAR EVENTS then QUIT). The really and weird problem is that our application do no execute the error trapping routines (Try/Catch and ON ERROR) and tries
to directly Quit.
I have never seen something like this before, error trapping routines not executed.
I try to explain the problem better:
- The user click on the Citrix icon of our App
- Citrix shows the executed processes (establishing connection, applying user config, loading profile, etc)
- The Application (VFP 9 SP2) is started and in any moment, while loading, occurs an error that is not handled by error handlers, and it executes a "kind" of a Quit command, that we detect because have a ON SHUTDOWN to catch it, then the App shut
down and the user must click the Citrix icon and start all over again, up to 7 times, when the App really load and work.
- I think that it is useful to make clear that no QUIT command is really causing this, just the behaviour of the QUIT when an error occurs, but just while loading. If the App get completely loeaded, then everything works as expected
Infraestructure:
- Windows Terminal Server 2008 + Citrix XenApp 5 + VMWare vCenter 5.1
- There are up to 50 concurrent users max in every virtualized server
- More than 10 GB of free disk space / Up to 4 GB ram
- RAM Memory is never used to the max
- CPU (Intel Xeon) is never used to the max (up to 90% in some cases)
- Data (DBFs for temporal work) ar on local drive, not over network (to avoid network known problems with smb2-3)
- There are connection to a Oracle 11 database for permanently storing the data
About the errors:
- They are not always the same or in the same place. In example, in one execution could fail the query of SET("Printer",2), in other execution could fail a SET PROCEDURE TO xxx ADDITIVE (sometimes already loaded), in other could fail a "DO
WHILE .T." in a init event.... completely crazy, and in all cases the errors are not thrown, not a single error code, the App just try to quit, as if ALT+F4 where pressed.
- All this does not happen allways to everyone, but happens many times in the day to many many users as to be worried
- The same user can have this error many times a day, but not allways
- Some of the problems started when migrating to Windows Terminal Server 2008, but didn't notice nothing special in the beginning, but a year later (last 2014) problems tend to go worse
Tried solutions:
- For the "SET PROCEDURE TO xxx ADDITIVE" error, a "IF xxx $ SET('PROCEDURE')" check was added
- The "SET('Printer',2)" check was moved out of initialization code, so it executes when user want to print the first time. In this case was neccesary to talk with IT guys to map a default printer after the App runs, and not in background, as it
was.
- Other checks and modifications was made to minimize posibility of errors
- Adding a timeout of 5 secs in the start of the program, to force a wait
- Restart of virtual servers (not the phisical) every 3 weeks
What I suspect:
- Some Microsoft optimization (memory?, process execution?) in WTS-2008 may interfere?
- Some VMWare memory management may interfere with WTS-2008?
- Some Citrix management may interfere with both?
- Server degradation because of day to day use
Results until now:
- Apparently, adding the timeout to force 5 secs delay and the restart of the server have made a notable enhancement in App start and running
with far fewer
errors
Has
this happened to anyone?
Thanks! o_O
Fernando D. Bozzo / Madrid (Spain)I never had this type of problems, but somewhat similar start up problems. I'd say it indicates resource problems. Low RAM can cause many unpredictable things. In my case loading much data at the begin of an application caused out of memory errors, which
were reported and logged normally, though.
I made a small tool using Windows API functions GetPerformanceInfo and GetProcessMemoryInfo, you'll find declaration and usage like usual at the News2News site. It's a bit lengthy and cluttered, but pretty much what you find there anyway, so I'll not post
my utility code.
I could quite clearly see how many users degraded available memory per session and at some time no further instance of the application was possible on the server. In my case RDP was used to start the app, Citrix will be quite the same, in the end the application
runs on some server and users see the remote running application.
Bye, Olaf.
Olaf Doschke - TMN Systemberatung GmbH
http://www.tmn-systemberatung.de -
Re: Using ScopeCache custom tag
Hi, I am quite new to ColdFusion and I have a calendar that
is quite slow due to the cfloops it uses to build the calendar. As
the page does not change very often I wanted to use Raymond
Camden's ScopeCache custom tag. However, for some reason the custom
tag was not getting picked up from the custom tag folder on the
server. I have successfully used components so have tried to
convert the custom tag to a component but get the following error
message:
Routines cannot be declared more than once.
The routine scope_Cache has been declared twice in the same
file.
This is the component:
<!---
Name : scopeCache
Author : Raymond Camden ([email protected])
Created : December 12, 2002
Last Updated : November 6, 2003
History : Allow for clearAll (rkc 11/6/03)
: Added dependancies, timeout, other misc changes (rkc
1/8/04)
Purpose : Allows you to cache content in various scopes.
Documentation:
This tag allows you to cache content and data in various RAM
based scopes.
The tag takes the following attributes:
name/cachename: The name of the data. (required)
scope: The scope where cached data will reside. Must be
either session,
application, or server. (required)
timeout: When the cache will timeout. By default, the year
3999 (i.e., never).
Value must be either a date/time stamp or a number
representing the
number of seconds until the timeout is reached. (optional)
dependancies: This allows you to mark other cache items as
dependant on this item.
When this item is cleared or timesout, any child will also
be cleared.
Also, any children of those children will also be cleared.
(optional)
clear: If passed and if true, will clear out the cached
item. Note that
this option will NOT recreate the cache. In other words, the
rest of
the tag isn't run (well, mostly, but don't worry).
clearAll: Removes all data from this scope. Exits the tag
immidiately.
disabled: Allows for a quick exit out of the tag. How would
this be used? You can
imagine using disabled="#request.disabled#" to allow for a
quick way to
turn on/off caching for the entire site. Of course, all
calls to the tag
would have to use the same value.
License : Use this as you will. If you enjoy it and it helps
your application,
consider sending me something from my Amazon wish list:
http://www.amazon.com/o/registry/2TCL1D08EZEYE
--->
<cfcomponent>
<cffunction name="scope_Cache" access="public"
returntype="string">
<cfargument name="cachename" type="string"
required="yes">
<cfargument name="scope" type="string" required="yes">
<cfargument name="timeout" type="string"
required="yes">
<cfprocessingdirective pageencoding="utf-8">
<!--- allow for quick exit
<cfif isDefined("arguments.disabled") and
arguments.disabled>
<cfexit method="exitTemplate">
</cfif>
<!--- Allow for cachename in case we use cfmodule --->
<cfif isDefined("arguments.cachename")>
<cfset arguments.name = arguments.cachename>
</cfif>--->
<!--- Attribute validation --->
<cfif (not isDefined("arguments.name") or not
isSimpleValue(arguments.name)) and not
isDefined("arguments.clearall")>
<cfthrow message="scopeCache: The name attribute must be
passed as a string.">
</cfif>
<cfif not isDefined("arguments.scope") or not
isSimpleValue(arguments.scope) or not
listFindNoCase("application,session,server",arguments.scope)>
<cfthrow message="scopeCache: The scope attribute must be
passed as one of: application, session, or server.">
</cfif>
<!--- The default timeout is no timeout, so we use the
year 3999. --->
<cfparam name="arguments.timeout"
default="#createDate(3999,1,1)#">
<!--- Default dependancy list --->
<cfparam name="arguments.dependancies" default=""
type="string">
<cfif not isDate(arguments.timeout) and (not
isNumeric(arguments.timeout) or arguments.timeout lte 0)>
<cfthrow message="scopeCache: The timeout attribute must
be either a date/time or a number greather zero.">
<cfelseif isNumeric(arguments.timeout)>
<!--- convert seconds to a time --->
<cfset arguments.timeout =
dateAdd("s",arguments.timeout,now())>
</cfif>
<!--- create pointer to scope --->
<cfset ptr = structGet(arguments.scope)>
<!--- init cache root --->
<cfif not structKeyExists(ptr,"scopeCache")>
<cfset ptr["scopeCache"] = structNew()>
</cfif>
<cfif isDefined("arguments.clearAll")>
<cfset structClear(ptr["scopeCache"])>
<cfexit method="exitTag">
</cfif>
<!--- This variable will store all the guys we need to
update --->
<cfset cleanup = "">
<!--- This variable determines if we run the caching.
This is used when we clear a cache --->
<cfset dontRun = false>
<cfif isDefined("arguments.clear") and arguments.clear
and structKeyExists(ptr.scopeCache,arguments.name) and
thisTag.executionMode is "start">
<cfif
structKeyExists(ptr.scopeCache[arguments.name],"dependancies")>
<cfset cleanup =
ptr.scopeCache[arguments.name].dependancies>
</cfif>
<cfset structDelete(ptr.scopeCache,arguments.name)>
<cfset dontRun = true>
</cfif>
<cfif not dontRun>
<cfif thisTag.executionMode is "start">
<!--- determine if we have the info in cache already
--->
<cfif structKeyExists(ptr.scopeCache,arguments.name)>
<cfif
dateCompare(now(),ptr.scopeCache[arguments.name].timeout) is -1>
<cfif not isDefined("arguments.r_Data")>
<cfoutput>#ptr.scopeCache[arguments.name].value#</cfoutput>
<cfelse>
<cfset caller[arguments.r_Data] =
ptr.scopeCache[arguments.name].value>
</cfif>
<cfexit>
</cfif>
</cfif>
<cfelse>
<!--- It is possible I'm here because I'm refreshing. If
so, check my dependancies --->
<cfif structKeyExists(ptr.scopeCache,arguments.name) and
structKeyExists(ptr.scopeCache[arguments.name],"dependancies")>
<cfif
structKeyExists(ptr.scopeCache[arguments.name],"dependancies")>
<cfset cleanup = listAppend(cleanup,
ptr.scopeCache[arguments.name].dependancies)>
</cfif>
</cfif>
<cfset ptr.scopeCache[arguments.name] = structNew()>
<cfif not isDefined("arguments.data")>
<cfset ptr.scopeCache[arguments.name].value =
thistag.generatedcontent>
<cfelse>
<cfset ptr.scopeCache[arguments.name].value =
arguments.data>
</cfif>
<cfset ptr.scopeCache[arguments.name].timeout =
arguments.timeout>
<cfset ptr.scopeCache[arguments.name].dependancies =
arguments.dependancies>
<cfif isDefined("arguments.r_Data")>
<cfset caller[arguments.r_Data] =
ptr.scopeCache[arguments.name].value>
</cfif>
</cfif>
</cfif>
<!--- Do I need to clean up? --->
<cfset z = 1>
<cfloop condition="listLen(cleanup)">
<cfset z = z+1><cfif z gt 100><cfthrow
message="ack"></cfif>
<cfset toKill = listFirst(cleanup)>
<cfset cleanUp = listRest(cleanup)>
<cfif structKeyExists(ptr.scopeCache, toKill)>
<cfloop index="item"
list="#ptr.scopeCache[toKill].dependancies#">
<cfif not listFindNoCase(cleanup, item)>
<cfset cleanup = listAppend(cleanup, item)>
</cfif>
</cfloop>
<cfset structDelete(ptr.scopeCache,toKill)>
</cfif>
</cfloop>
<cfreturn scope_Cache>
</cffunction>
</cfcomponent>Hi, thanks to both of you for your help. I reverted back the
custom tag and it was picked up this time - I don't know what
happened before. The functionality works as expected but I have hit
another problem and I am hoping I can tap your combined ColdFusion
wisdom to solve!!
The calendar returns leave records for staff and filters the
records using a querystring variable appended when the user clicks
on a particular month. However, what members of staff the user sees
depends on the data held in the users' session variables based on
their authority. The reason I wanted to use caching is because the
page takes a good ten seconds to run because of the use of cfloops
for the members of staff and the days of the week to dynamically
build the page. Using the custom tag would have worked if all
members of staff saw the same calendar data and could only see one
month. Can you see anyway I can speed up the page and do you think
caching is the way forward here? -
Procedure in dynamic page shows only sometimes data
Is anybody recognizing this problem:
A stored procedure is called in a dynamic page. The procedure builds up a html form. When calling the dynamic page, sometimes the form appears, sometimes it does not appear. In the last case, even a errormessage is not shown. The portlet area in the page is just empty.
Anybody an idea?
JohanProblem solved. I changed the timeout period of the provider ('Edit a Provider Registration') and I added a timeout message.
Maybe you are looking for
-
Why is BT incompetent and unable to resolve a simp...
This has been an on-going issue with BT for a number of months in which BT has made multiple failing and I am now beginning to lose patience. The issue began when I moved house and took my BT services with me. During the house move I requested that t
-
CRMD_ORDER Item Details TAB one of line item setting date as 12/31/1899
Hi Experts, We have 3 line item for order, we call it as main line, return line and replacement line item. When we select Return line item and go to Dates Tab it shows all the dates related to that. Here Depot send the date via XML File and it is ge
-
Calling to Mobiles without internet and other quer...
Hi Team, I am new to this community, dont know if i am posting at correct place and if the questions are too lame Currrent Location - Amsterdam, Netherlands Queries - 1) If i choose a plan of 8Eur(800 mins) Internalional India calling subscription, c
-
Media playback error..
IN flash 8 when i link the media playback to a mp3 file it plays the music slowly like old man or fast like child voice and speed what is the reason plz help me
-
I just purchased and installed an X-Fi Platinum and wow, does it ever sound good!? Unfortunately, I let the setup install Auto Update and it barely gave me time to enjoy it before it found a driver update, and after it was installed and I restarted m