Invite a Co-worker
Send a co-worker an invite to the Exchange portal.Just enter their email address and we’ll connect them to register. After joining, they will belong to the same company.
Send Invite Cancel
80570members
346455posts

Where to create the ewsItemManager

Solved
SteveGregory
Commander Commander
Commander
0 Likes
4
383

Where to create the ewsItemManager

Hi, I am using the ewsItemManager out of the Utilities library and wondering where is the best place to instantiate this in a long running processor. Currently i have it in my DoUpdates loop where it is being created each time the processor goes through the incoming data and updates the changed values on the EWS server, but I am seeing some degradation of performance over time and wondering if that could be the cause?

Tags (1)

Accepted Solutions
ardak
Commander Commander
Commander
0 Likes
3
369

Re: Where to create the ewsItemManager

Hello,

 

It depends a bit on how you're using it and what kind of performance degradation you but most things in Smartconnector are designed around short lived processors.

 

You could try 

 

ewsItemManager.DataAdapter.CreateDatabaseContext();

 

to refresh the datacontext of the DataAdapter where it's applicable in your loop.

 

BR

Armend

See Answer In Context

Tags (1)
4 Replies 4
ardak
Commander Commander
Commander
0 Likes
3
370

Re: Where to create the ewsItemManager

Hello,

 

It depends a bit on how you're using it and what kind of performance degradation you but most things in Smartconnector are designed around short lived processors.

 

You could try 

 

ewsItemManager.DataAdapter.CreateDatabaseContext();

 

to refresh the datacontext of the DataAdapter where it's applicable in your loop.

 

BR

Armend

Tags (1)
SteveGregory
Commander Commander
Commander
0 Likes
2
360

Re: Where to create the ewsItemManager

Hi Armend,

 

I am creating an instance of the ewsItemManager in the DoUpdates() method which is periodically called by the long running processor. I am using it to read current ews values and write to them if they need to be updated.

When started, the processor takes about 6 seconds to do all the updates. The DoUpdates() method repeats 10 seonds after if finishes, until the cancellation token is called.

After about 4 hours, the time to update the values goes from 6 seconds to about a minute, and keeps getting longer. As soon as you restart the processor, it goes back to 6 seconds.

If i replace all the instances of ewsItemManager with DataAdaptor, the update time is less than 2 seconds and doesn't increase. I understand the ewsItemManager may have some additional overhead, but I don't understand why it would get slower over time. The only thing i can put it down to is that i am creating a new instance of it, each time i DoUpdates() and something is not getting cleaned up. I tried to do ewsItemManager.Dispose() at the end of each update, but it actually disposes of the dbContext and stops the processor. My SmartConnector is working fine now using the DataAdaptor directly, but curious to know what is happening here, or if i am doing something wrong. 

Tags (1)
ardak
Commander Commander
Commander
0 Likes
1
356

Re: Where to create the ewsItemManager

Without seeing your code it's impossible to say for sure, but probably your datacontext(entity framework) is getting huge when using the EwsItemManager. When using the DataAdapter you're probably (knowingly or inadvertently) refreshing the context. There should not be any overhead when using the EwsItemManger.

 

I suggest you try adding the line I suggested above, or preferably refactoring your processor to run when needed. If you are using a long running processor because you have state in the processor you can use the Cache to save state between runs.

 

BR

Armend

Tags (1)
SteveGregory
Commander Commander
Commander
0 Likes
0
159

Re: Where to create the ewsItemManager

Hi Armend,

 

This seemed to work:

 

ewsItemManager.DataAdapter.CreateDatabaseContext();

 

Thanks for your help.

 

Steve 

Tags (1)