all groups > sql server notification services > june 2005 >
You're in the

sql server notification services

group:

Custom Formatter: Initialize and Close methods


Custom Formatter: Initialize and Close methods sidgam NO[at]SPAM hotmail-dot-com.no-spam.invalid
6/9/2005 1:02:15 AM
sql server notification services:
Hello folks

While debuggin my Custom Formatter I noticed that the Initialize an
Close methods are called for every email (comprised of man
notificaitons) instead just once for a batch of emails

This means that arguments from the ADF are loaded up every tim
instead of just once for a batch. As I understand it, a batch wil
only have emails that use the same protocol, so the arguements neede
would be the same for it, so it should just load it once

I want to use the Initialize and Close methods to load up and clea
text which is larger than the 4000 char limit for EMN fields. Th
idea is to load up the text once, preserve and use it for th
duration of the batch and then remove it from memory

Any suggestions on other mechanisms I can use to accomplish this

Thx
Re: Custom Formatter: Initialize and Close methods Shyam Pather [MSFT]
6/22/2005 11:48:00 AM
Hello,
Initialize and Close on content formatters are called once per notification
batch per delivery channel i.e. to distribute 1 notification batch over 3
delivery channels, there will be 3 pairs on Initialize/Close calls.

If you're seeing one Initialize()/Close() sequence per notification, it
might be that each notification is in a batch by itself. This could happen,
depending on how you've configured your application, but is probably not
what you want. If you post your ADF, I can try to take a look.

Your strategy for caching the large text field across many notifications is
sound - many applications I know of use a similar strategy.
-shyam

--
Learn more about SQL-NS:
http://www.amazon.com/exec/obidos/tg/detail/-/0672326647/
---------------------------------------------
This posting is provided "AS IS" with no warranties, and confers no rights.
Use of included script samples are subject to the terms specified at
http://www.microsoft.com/info/cpyright.htm.
---------------------------------------------
[quoted text, click to view]

re:Custom Formatter: Initialize and Close methods sidgam NO[at]SPAM hotmail-dot-com.no-spam.invalid
7/8/2005 1:00:17 AM
Hey Shyam

Thanks for the response. I do have 2 delivery channels and whenever
do my tests I set them up to send emails via both delivery channels.
I will do some tests using just 1 delivery channel to confirm tha
the Initialize/Close methods are only called once for the batch

I would like to present the scenario I am trying to use SQL-NS for.
want to set SQL-NS up to be able to send push emails ad-hoc. Th
recipient community that will receive these push emails is define
via rules. The method I have come up with is to create subscription
to a rule, provide delivery content (body of email) to that rule
schedule it for later or immediate delivery. What I want to be abl
to do is to delete the subscriptions when the delivery of th
notifications is complete. Since the rules are not reused, I woul
like to clean up the subscriptions once delivery is complete t
prevent my subscriptions table from getting too large

What is the best way to truncate the subscriptions table? Via code o
through a scheduled task in the db. I dont see a clean way to cal
the clean up code in the Custom Formatter or Protocol. If via a d
scheduled task, do I just need to call S
NSMain.Dbo.NSDeleteAllSubscriptions

Please let me know
Re: Custom Formatter: Initialize and Close methods Joe Webb
7/12/2005 7:46:11 AM

Here's some C# code that can be used to delete all subscriptions for a
particular subscriber. You could put this in a loop of all subscribers
to completely get rid of your subscriptions. (You'll also want to put
this is a try block with proper error handling).

public bool DeleteSubscriptions(string sId)
{
//Create an NSInstance and NSApplication object
NSInstance instance = getNSInstance();

//create a subscriber object
Subscriber subscriber = new Subscriber(instance);
subscriber.SubscriberId = sId;

//delete the subscriptions
subscriber.DeleteSubscriptions() ;

return true;

}

If you have multiple applications for the instance, you can specify in
which application the subscriptions should be deleted.

HTH...

--
Joe Webb
SQL Server MVP


~~~
Get up to speed quickly with SQLNS
http://www.amazon.com/exec/obidos/tg/detail/-/0972688811

I support PASS, the Professional Association for SQL Server.
(www.sqlpass.org)



On Fri, 08 Jul 2005 01:00:17 -0500,
[quoted text, click to view]
Re: Custom Formatter: Initialize and Close methods Joe Webb
7/12/2005 7:53:14 AM
Forgot to include the getNSInstance proc in the prior. Nothing
special, just wanted to be complete.


private NSInstance getNSInstance()
{
//Create an NSInstance object
string instanceName =
ConfigurationSettings.AppSettings["NSInstanceName"];
NSInstance instance;
instance = new NSInstance(instanceName);
return instance;
}


HTH...

Joe



--
Joe Webb
SQL Server MVP


~~~
Get up to speed quickly with SQLNS
http://www.amazon.com/exec/obidos/tg/detail/-/0972688811

I support PASS, the Professional Association for SQL Server.
(www.sqlpass.org)

On Tue, 12 Jul 2005 07:46:11 -0500, Joe Webb
[quoted text, click to view]
re:Using SQL-NS for one time, ad hoc push emails sidgam NO[at]SPAM hotmail-dot-com.no-spam.invalid
7/14/2005 1:00:09 AM
Thnx for your reponse Joe

The reason for asking if there is a way to delete subscription
directly through the sps is bec. of my unique scenario

The goal here is to use SQL-NS for ad-hoc, one time push emails.
can use the SQL-NS api to create the subscriptions. Once the email
are sent out, the subscriptions would not be used again and it woul
be prudent to clean them out. I would like to run a scheduled tas
to do this

I could write a windows service which leverages SQL-NS api, but i
this can be done through a db scheduled task, I would prefer tha
route
AddThis Social Bookmark Button