getHeaders – a new attribute in the cfexchangemail tag

With ColdFusion 11 Update 3, we have introduced a new parameter called “getHeaders”, in the “cfExchangeMail” tag. It accepts a boolean value. When set to true, cfExchangeMail returns a query with an additional “InternetHeader” column. This column contains a struct containing key-value pairs of the email-headers associated with each message.

Email message headers provide technical details about the message, such as who sent it, the software used to compose it, the version of the MIME protocol used by the sender etc. 

On Exchange 2010, the fields that are returned are: CC, Content-Transfer-Encoding, Content-Type, Date, From, MIME-Version, Message-ID, Received, Return-Path, Subject, To, X-MS-Exchange-Organization-AuthAs, X-MS-Exchange-Organization-AuthSource, X-Mailer.

You may reference this weblink for the detailed list of the fields and their description.

You can put this new feature to any good use that suites your purpose. I will dwell on one such use case below.

In MS Exchange 2010 and later, the “ToId” column in the retrieved messages query contains the primary email address of the sender. A primary email address can have multiple aliases. If you need to retrieve the email-alias the message was sent to, you can make use of this new attribute.

Here’s an example that demonstrates the usage the tag in the context of the use case discussed above:

<cfmail from=”#frm_usr_email#” to=”#to_usr_alias#” cc=”#cc_usr_alias#” subject=”#msg_sub#”  server= “#exchangeServerIP#” port = “25”>

———– testing mail to an alias address ————

</cfmail>

<cfset sleep(5000)>

<cfexchangeConnection action=”open” username =”#to_usr#” password=”#password#” server=”#exchangeServerIP#” serverversion=”#version#” protocol=”#protocol#” connection=”excon”>

<cfexchangemail action=”get” name=”usr_msgs” connection=”excon” getheaders=true folder=”Inbox”>

<cfexchangefilter name=”fromID” value=’#frm_usr#’>

<cfexchangefilter name=”subject” value=”#msg_sub#”>

</cfexchangemail>

<cfif usr_msgs.recordcount GTE 1>

info from cfexchangemail fields:<br>

<cfloop query=”usr_msgs”>

<cfoutput>

#usr_msgs.subject#<br> 

#usr_msgs.CC#<br> 

#usr_msgs.fromId#<br>

</cfoutput>

</cfloop>

info from cfexchangemail.internetHeaders fields:<br>

<cfloop query=”usr_msgs”>

<cfoutput>

#ReplaceList(usr_msgs.internetHeaders[“from”][1], “>,<“, “,”, “,”, “,”)#<br>

#ReplaceList(usr_msgs.internetHeaders[“to”][1], “>,<“, “,”, “,”, “,”)#<br>

#ReplaceList(usr_msgs.internetHeaders[“cc”][1], “>,<“, “,”, “,”, “,”)#<br>

</cfoutput>

</cfloop>

</cfif>

 

You can reference the bugbase, for the enhancement request originally logged for this feature.

Taking Thread Dumps from ColdFusion Server Programmatically

Many times you would want to tweak the performance of the ColdFusion server or want to debug the bottlenecks that make the server unresponsive.

To analyze this, ideally you would want to have Thead dumps and Server memory snapshot(Heap Space, Eden Space, Survivor Space, Old Gen, Perm Gen).

While you can use JDK tools like jstack to get the dumps, it is tedious to install it and schedule the thread dumps.

So, programmatically thread dumps and memory snapshots are are triggered and can be configured as a scheduler task and can be triggered on-demand as well.

Download the following zip file and move it to the server where you want to take thread dumps.

 

threaddump.zip

This zip file contains two files. One is threaddump.jar file.

Place this file under: C:ColdFusion11cfusionwwwrootWEB-INFlib and restart the server for it to load.

And the other file is the cfm file takethreaddump.cfm where the call to ThreadDump class is made and the path where the dump content should be written.

By default it is dumped to the file #GetTempDirectory()#/threaddump<Day>-<Month>-<Year>.log

(Depending on the server location it translates similar to C:ColdFusion11cfusionruntimeworkCatalinalocalhosttmpthreaddump12-8-2015.log)

You can change this to any other convenient path in the cfm file.

You can call this cfm on-demand at point of time or configure a new scheduled task to schedule it at some interval.

More number of Thread dumps are more helpful for problem analysis. So, it is better to take at some interval.

On every new day, dump is rotated automatically to a new file name.

 

Some of the factors that help in deciding the memory that application needs

Would like to explain the some of the factors that
decide how much maximum memory that an application needs.

Here are two examples. One is with cffile upload action
and the other is with cfpdf thumbnail action.


Sometimes, while uploading large files using cffile
with upload action (<CFFILE ACTION= “UPLOAD”) you would have run
into the following error

“500 – Internal server error.

There is a problem with the resource you are looking
for, and it cannot be displayed.”

 

File upload is dependent on “Maximum size of post data”
value that you can set in ColdFusion Administrator.

However, it can’t exceed the total available free
memory.

Say, if 512 MB is the Xmx memory value (jvm.config) and
350 MB is already occupied by the application, even if “Maximum size of post
data” value is set to 200 MB, it can upload files of up to ~150 MB (512 MB- 350
MB).

It can’t upload files of size 200 MB.

To fix it, Xmx should be increased which is again
subjected to the available memory in that machine.

 

Here is other example:-

Say, you are using CFPDF’s Thumbnail Action and the
thumbnails background is not generated properly.
Here the issue would be insufficient memory.

        Just to hold the decoded image data,
java application needs large memory (say 1.2 GB depending on the image pixels).

It is because of the format and high pixel nature of
the image that is being converted. Number objects created are equal to the
total number of pixels in that image.

So, high pixel imge would consume more memory.

To fix this, Xmx value in jvm.config should be at least
-> Applications memory Size + 1.2 GB (from the above example) i.e.
a minimum of 1.5 GB and can be more depending on your application.

Changing the value and restarting the server would
fix this.

Normal
0

false
false
false

EN-US
X-NONE
X-NONE

/* Style Definitions */
table.MsoNormalTable
{mso-style-name:”Table Normal”;
mso-tstyle-rowband-size:0;
mso-tstyle-colband-size:0;
mso-style-noshow:yes;
mso-style-priority:99;
mso-style-parent:””;
mso-padding-alt:0in 5.4pt 0in 5.4pt;
mso-para-margin-top:0in;
mso-para-margin-right:0in;
mso-para-margin-bottom:8.0pt;
mso-para-margin-left:0in;
line-height:107%;
mso-pagination:widow-orphan;
font-size:11.0pt;
font-family:”Calibri”,sans-serif;
mso-ascii-font-family:Calibri;
mso-ascii-theme-font:minor-latin;
mso-hansi-font-family:Calibri;
mso-hansi-theme-font:minor-latin;}

How to enable/disable Tomcat Access logs (logging of each ColdFusion request)

Sometimes, depending on your need, you may want to enable or disable the tomcat access logs, which track every request to ColdFusion. In CF10, these logs were enabled by default. In CF11, they are disabled by default. This post shows how to enable or disable them.

This can be simply done changing a setting a in <ColdFusion_Home>cfusionruntimeconfserver.xml file.

At the end of this xml file you may find the following commented tag.

<!–

<Valve className="org.apache.catalina.valves.AccessLogValve" directory="logs" 

               prefix="localhost_access_log." suffix=".txt"

               pattern="%h %l %u %t &quot;%r&quot; %s %b" resolveHosts="false"/>

–>

To enable the logging, uncomment this tag as follows, and restart the server for the changes to be effective.

<Valve className="org.apache.catalina.valves.AccessLogValve" directory="logs" 

               prefix="localhost_access_log." suffix=".txt"

               pattern="%h %l %u %t &quot;%r&quot; %s %b" resolveHosts="false"/>

If access logging is enabled, the logs are stored in {ColdFusion Root}cfusionruntimelogs.

Note that you can modify the attributes, such as the log filename (via the prefix attribute) and what is logged, via the pattern attribute. For more information on these and other attributes, and on Tomcat access logging in general, see https://tomcat.apache.org/tomcat-7.0-doc/config/valve.html#Access_Logging

Be aware that this feature logs EVERY request made to ColdFusion, and so these logs can grow quite large.

To disable the Tomcat access logs, sinply comment out the tag above (using 2 dashes for XML, rather than  CFML), and restart CF for that change to take effect.

Configuring JNDI Data sources in ColdFusion

For configuring JNDI data sources, it should firstly be supported by the
application server.

Tomcat server, which is built-into ColdFusion server, has the support for
this by default.

While there is a blog Here on this how to configure, I want to explain few mistakes
that are tend to be done while configuring. 

  One common mistake generally done is:-
  When the data source is configured from the ColdFusion administrator by
providing irrelevant    username/password.
  You may tend to provide Database’s username/password. This is NOT
Database’s username/password.
  It is the application server’s username and password on which data
source is configured.
  It should be left blank when the credentials are not required by the
server.

Prepending java:comp/env/ is required for the actual JNDI name that is
registered in xml while registering the name in administrator.

It is not mandatory that you register the JNDI data source in ColdFusion administrator.

As long as the app server supports JNDI, you can invoke the data
source that is configured in the application server in cfm source code directly
either in case of standalone installation or EAR/WAR deployment.
But for consistency and preferred names that can used in ColdFusion should be
registered in ColdFusion.

This is applicable to both ColdFusion 10 and ColdFusion 11.

 

Normal
0

false
false
false

EN-US
X-NONE
X-NONE

/* Style Definitions */
table.MsoNormalTable
{mso-style-name:”Table Normal”;
mso-tstyle-rowband-size:0;
mso-tstyle-colband-size:0;
mso-style-noshow:yes;
mso-style-priority:99;
mso-style-parent:””;
mso-padding-alt:0in 5.4pt 0in 5.4pt;
mso-para-margin-top:0in;
mso-para-margin-right:0in;
mso-para-margin-bottom:8.0pt;
mso-para-margin-left:0in;
line-height:107%;
mso-pagination:widow-orphan;
font-size:11.0pt;
font-family:”Calibri”,sans-serif;
mso-ascii-font-family:Calibri;
mso-ascii-theme-font:minor-latin;
mso-hansi-font-family:Calibri;
mso-hansi-theme-font:minor-latin;}

Why should we use WebSocket Proxy?

This is the first in a series of
posts on WebSocket proxy configuration.

ColdFusion uses dedicated port
(8575/8577) to start its internal WebSocket Server by default. Earlier, these
ports were required to be always accessible from outside. This setup works well
for intranet applications. But for public facing web applications, it is not
advisable to keep port open and let it be accessible from outside.

ColdFusion 11 has introduced
proxy support for WebSocket. There is a new proxy module that can be configured
with IIS and Apache Web Server which intercept ColdFusion WebSocket requests
and redirect the requests to the ColdFusion’s internal WebSocket Server.
Now, web applications communicate to WebSocket server over the same port on
which web application is running.

How to start WebSocket proxy
service?

In order to start WebSocket proxy
service follow steps mentioned below:

  • Login to ColdFusion Administrator.
  • Navigate to Server Settings > WebSocket.
  • Select “Use Proxy” option under Enable WebSocket Service.
  •  Submit Changes.
  • Restart ColdFusion Application service.
  •  

    How to configure WebSocket proxy
    with ColdFusion?

    We have shipped WebSocket Proxy
    Configuration tool along with ColdFusion 11 which can be used to configure WebSocket
    proxy with IIS and Apache Web Server on all supported platforms.

    WebSocket Proxy Configuration tool
    can be located at:

    •  <cf_install_root>/cfusion/bin/wsproxyconfig.exe(for
      windows platform
      )
    •  <cf_install_root>/cfusion/bin/wsproxyconfig.sh(for
      non-windows platform
      )

    Supported web servers with
    WebSocket proxy:

    • IIS
      8 or above
    • Apache
      Web Server 2.2.*

    Upcoming posts in this series:

    • How to configure WebSocket proxy
      with IIS
    • How to configure WebSocket proxy
      with Apache Web Server
    • Tuning ColdFusion 11 WebSocket
      proxy configuration with IIS 8 or above

     

    Tournament Scorecard Pro built with Adobe ColdFusion 11 Mobile

    We would like to make an announcement to highlight a great public application that was built with Adobe ColdFusion 11 Mobile Platform Tools by one of our well-known community members, Dave Ferguson.  We think the app is a great example of the types of mobile solutions that can be built utilizing the features available.

    Well done Dave!  Thanks for sharing.

     

    The application was built using these mobile features of ColdFusion 11: 

    Local data storage access using components.

    Remote app inspection using built-in weinre server.

    App debugging during development process.  

    Application building via phonegap build for deployment. 

     

    Bootstrap was used for UI controls and layout.  

    Dynamic tempting was achieved with Mustache.

    jQuery and other Javascript plugins for miscellaneous UI elements.

     

    Description:

    Tournament Scorecard Pro is an app for keeping score at a
    martial arts tournament.  These tournaments don’t have a scoreboard for
    spectators, so it is up to the spectators to keep score themselves.  This
    has historically been done with pen and paper. However, this method leads to
    lost scores or other issues. With the app, spectators can easily keep track of
    scores and always have them with them.  They can now easily look back at
    previous tournaments for reference.  The app also helps during the tournament
    when it comes to correcting scoring conflicts and figuring out ties.

     www.tournamentscorecard.com

     

     

    Have you built a mobile application using any of the ColdFusion 11 tools?  Tell us about it!

    Setting up ColdFusion in distributed envionment

    You might want to set up ColdFusion in a distributed environment where ColdFusion is running on one machine and Web server is running on a different machine.

    Following are the set of steps that have to be performed to achieve this (less error-prone):

    This applies to both ColdFusion 10 and ColdFusion 11.

    1) Have ColdFusion server installed in a machine.

    2) Next thing is to download and install VC Runtime.

                 – The version of VC Runtime that you have to install depends on the version of ColdFusion.

                    Say, ColdFusion 11 needs VC Runtime 2012

                     (32-bit VC Runtime for 32-bit Web server and 64-bit VC Runtime for 64-bit Web server.

                      If you are not sure, you can install both)

                     (https://www.microsoft.com/en-in/download/details.aspx?id=30679)

                    and ColdFusion 10 needs VC Runtime 2010

     

    3) Copy the following contents from the machine where ColdFusion is running to the machine where Web server is running at the same location.

     C:ColdFusion11jre

     C:ColdFusion11runtimelibwsconfig.jar

     C:ColdFusion11runtimeconfserver.xml

    C:ColdFusion11configinstances.xml

    C:ColdFusion11configcluster.xml

     

    4) Open a Command prompt and run wsconfig tool

       C:ColdFusion11>jrebinjava -jar cfusionruntimelibwsconfig.jar

        It will open a configuration window where you have to provide AppServer Host as the ColdFusion Server IP.

        Configure the connector.

    Distributed environment is ready for use. Send requests to the Web server's URL with cfm files under web server root and same files under ColdFusion's Web root.

    Web server would redirect these to ColdFusion, which is on some other machine.

     

     

    Scheduled Task Error: Unable to display the error’s location in a CFML template

    Recently this error popped up when one of our customers updated their system so we wanted to share how it can be resolved.

     

    The following error may occur under ColdFusion Administrator in the scheduled tasks tab:

    The error occurred in scheduletasks.cfm: line 188 -1 : Unable to
    display error’s location in a CFML template.

     

    This problem occurs if neo-cron.xml file becomes corrupt.

     

    Workaround:

    Place the following in ColdFusion11cfusionlibneo-cron.xml file and restart the Application Services

    <wddxPacket
    version=’1.0′><header/><data><array length=’4′><struct
    type=’coldfusion.server.ConfigMap’></struct><boolean
    value=’false’/><string></string><string>txt,log</string></array></data></wddxPacket>


    Alternatively, if you have a good backup of the same file you could replace that instead of the above step.

     

    We are unable to reproduce any particular events that cause this issue.  If you have run into the problem, feel free to indicate in the comments any potential steps that may have contributed to it.

    Adobe ColdFusion Government Seminar – Washington, D.C. May 7th

    Please join the ColdFusion team at a free event in Washington, D.C. on May 7th, 2015 at 8:00 AM ET

    Date: Thursday, May 7, 2015
    Registration: Begins at 8:00am
    Event Time: 8:30am – 11:30am

    Location: Washington Marriott
                      at Metro Center

                      775 12th Street NW
                      Junior Ballroom Salon I
                      Washington, DC 20005
    Cost: Free

    *Complimentary breakfast will be provided

    For more details and registration please use this link: http://pages.carahsoft.com/v/v0000OgY03MMU0zfM010000

    This is a half-day morning event where we will have interactive discussions on current and future web trends with an emphasis on government related focus areas such as security, data management, and latest technologies.  It’s an exciting opportunity to interact with executive leadership and product management to discuss strategy and hear about Adobe’s plans for ColdFusion’s continued success and future technology focus areas.  

    We encourage all of our ColdFusion customers in the D.C. area to attend.

    We’re looking forward to seeing you there!