<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Statefulness of IdentityService in Alfresco Archive</title>
    <link>https://connect.hyland.com/t5/alfresco-archive/statefulness-of-identityservice/m-p/156935#M111148</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;It seems like the services provided by the ProcessEngine are all stateless, except the IdentityService…&amp;nbsp; ie. in most cases, you use a service to retrieve some bean and then work with that bean.&amp;nbsp; Based on the way that it's defined in the Spring configuration, it looks like the IdentityService (and the others) are singletons.&amp;nbsp; However, to start a process as a particular user you do:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp; identityService.setAuthenticatedUserId("userx");&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;…and then call to the RuntimeService to start the process (without the user, just implicitly set by calling that method on the IndentityService.&amp;nbsp; Is this thread-safe?&amp;nbsp; In other words, if I have a lot of threads in my application simultaneously kicking off processes, is the identity and invocation of the runtime service local to my individual thread?&amp;nbsp; I'm wondering about this design decision and why the identity isn't just passed into the call to the runtime service instead of being split between the two calls.&amp;nbsp; I'm working through the engine source to understand its design and this approach jumped out at me.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Thanks! - Bill&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Wed, 06 Nov 2013 19:39:47 GMT</pubDate>
    <dc:creator>bmarkmann</dc:creator>
    <dc:date>2013-11-06T19:39:47Z</dc:date>
    <item>
      <title>Statefulness of IdentityService</title>
      <link>https://connect.hyland.com/t5/alfresco-archive/statefulness-of-identityservice/m-p/156935#M111148</link>
      <description>It seems like the services provided by the ProcessEngine are all stateless, except the IdentityService…&amp;nbsp; ie. in most cases, you use a service to retrieve some bean and then work with that bean.&amp;nbsp; Based on the way that it's defined in the Spring configuration, it looks like the IdentityService (and th</description>
      <pubDate>Wed, 06 Nov 2013 19:39:47 GMT</pubDate>
      <guid>https://connect.hyland.com/t5/alfresco-archive/statefulness-of-identityservice/m-p/156935#M111148</guid>
      <dc:creator>bmarkmann</dc:creator>
      <dc:date>2013-11-06T19:39:47Z</dc:date>
    </item>
    <item>
      <title>Re: Statefulness of IdentityService</title>
      <link>https://connect.hyland.com/t5/alfresco-archive/statefulness-of-identityservice/m-p/156936#M111149</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;So, for anyone wondering…&amp;nbsp; I built a little test app that spun off 20 threads, and each created a process instance.&amp;nbsp; In between setting the authenticated user and kicking off the process instance, I put a randomized timer so that there was overlap between the threads setting different users and kicking off process instances.&amp;nbsp; Turned out each thread started the its process as the correct user, even with the overlapping calls.&amp;nbsp; After some more digging through the source, I found the reason – the identity set by the call to the identity service and used by the runtime service is stored in a thread-local string:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;A href="https://github.com/Activiti/Activiti/blob/master/modules/activiti-engine/src/main/java/org/activiti/engine/impl/identity/Authentication.java" rel="nofollow noopener noreferrer"&gt;https://github.com/Activiti/Activiti/blob/master/modules/activiti-engine/src/main/java/org/activiti/engine/impl/identity/Authentication.java&lt;/A&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Anyway, this was just a random question I had that wasn't entirely clear from the user guide… after building this little test I then stumbled across this in the JavaDocs: "void setAuthenticatedUserId(String authenticatedUserId): Passes the authenticated user id for this particular thread. All service method (from any service) invocations done by the same thread will have access to this authenticatedUserId."&amp;nbsp; Mystery solved. &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 17 Nov 2013 01:59:19 GMT</pubDate>
      <guid>https://connect.hyland.com/t5/alfresco-archive/statefulness-of-identityservice/m-p/156936#M111149</guid>
      <dc:creator>bmarkmann</dc:creator>
      <dc:date>2013-11-17T01:59:19Z</dc:date>
    </item>
    <item>
      <title>Re: Statefulness of IdentityService</title>
      <link>https://connect.hyland.com/t5/alfresco-archive/statefulness-of-identityservice/m-p/156937#M111150</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Thanks for coming back on this. Indeed, authentication mechanism uses thread-local storage of the current authenticated used, and is cleaned up afterwards as well, to make sure thread-pools (which reuse threads) don't get authentication mixed up…&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 05 Dec 2013 08:31:20 GMT</pubDate>
      <guid>https://connect.hyland.com/t5/alfresco-archive/statefulness-of-identityservice/m-p/156937#M111150</guid>
      <dc:creator>frederikherema1</dc:creator>
      <dc:date>2013-12-05T08:31:20Z</dc:date>
    </item>
  </channel>
</rss>

