API
Version 7.x > API > Integration Bus and Session State View modes: 
User avatar
Kentico Legend
Kentico Legend
Brenden Kehren - 5/21/2013 8:26:42 AM
   
Integration Bus and Session State
I'm working on a connector that sends updates to web services upon a User being updated. I have a session variable that is stored and updated regularally but is read as a null value when the ProcessInternalTaskAsync method is called. I can see the value is set prior to the ProcessInternalTaskAsync method call. Is there any reason the session variable would be blank or null aside from not being set? The control that sets it has already been loaded.

User avatar
Certified Developer 13
Certified Developer 13
kentico_josefd - 5/27/2013 4:34:32 AM
   
RE:Integration Bus and Session State
Hello,

Unfortunately, it is not possible to access the context properties, like session and session variables, because the tasks are processed asynchronously.

Regards,
Josef Dvorak

User avatar
Kentico Legend
Kentico Legend
Brenden Kehren - 5/27/2013 3:00:59 PM
   
RE:Integration Bus and Session State
That's what I thought the problem was Josef. How do you recommend I go about correcting this then? Is there a way I can pass this value in as a variable to that method per each object updated?

User avatar
Member
Member
Swainy - 5/30/2013 9:01:42 AM
   
RE:Integration Bus and Session State
Hi Frogg,

What is the session variable that needs to be updated regularly but also needs to be accessed from the integration bus? This seems an odd scenario?

If you need to get a value from inside the integration bus code you will need to store this value in custom settings within kentico. Then where you update the session variable with your new value also update the custom setting value at the same time.

If you need any further help let me know,

Thanks,

Matt

User avatar
Kentico Legend
Kentico Legend
Brenden Kehren - 5/30/2013 9:13:48 AM
   
RE:Integration Bus and Session State
Thanks Matt.

My scenario is a single user can be logged in and have access to multiple credit card accounts (custom table linking users and accounts and account type). The user has a list of accounts they are linked to and when they change the selected account the session value (account number) is set.

I'm syncing the users email and 1 custom user setting to a web service. Whenever the user object is updated I need to get the currently selected account number for the user and perform an update via the web service.

Now that I go through this, I'm wondering if it wouldn't be better to create a global event for the users and insert the data I need into a custom table and perform the integration bus actions on that custom table which would have the user info, selected account and other fields I need to sync.

Thanks for making me think outside of the box.

Brenden

User avatar
Member
Member
Swainy - 5/30/2013 10:29:45 AM
   
RE:Integration Bus and Session State
Hi Brenden,

No problem :)

Sounds like a global event handler may be a better option to me. The integration bus definately shouldn't be session dependant, especially if it's user data as it does run asynchronously so you can never be sure at what point it may run.

One of the main benefits of the bus is that it queue's the tasks so that if your external web service is unavailable it stores the requests and then runs them later when the web service is avialable (this could be hours later and your session/user data wouldn't be availabe), so I would certainly agree in your situation it sounds like it's best to update the custom table and then synch it using the bus from the custom table to the web service.

Thanks,

Matt

User avatar
Kentico Legend
Kentico Legend
Brenden Kehren - 5/30/2013 10:35:52 AM
   
RE:Integration Bus and Session State
The queue is what I was looking for in the event the web service is unavailable or something like that. I wanted to have a more robust solution than a scheduled task or simple global event handler. Thanks again!