Yeah, you are right, the two users will have their own connection of P8. We use
Factory.Connection.getConnection(ceURI);//CPE API
for each user logon.
Original Message:
Sent: Fri June 30, 2023 05:52 AM
From: Marcel Kostal
Subject: Synchronized block in ICN PluginService
Hi Calvin
Are you saying that callbacks.getP8Connection returns different connection for different user session? So if there are two users logged in and both executes pluginService at the same time each thread (user) will receive his own connection to p8? ..... because the API documentation just says: "Returns a connection to the IBM FileNet P8 domain for the given repository." (so I'm missing there: .... and for user session)
But if it works as you wrote than it's good (not an architecture bottleneck)... but I would suggest to update it in documentation ;-)
Thanks.
------------------------------
Marcel Kostal
Original Message:
Sent: Fri June 30, 2023 01:09 AM
From: JIE ZHANG
Subject: Synchronized block in ICN PluginService
Hi Marcel,
The callbacks.getP8ObjectStore or callbacks.getP8Connection return always the same and only ObjectStore/Connection (for specified repositoryId) for one user session. So it is not like the database connection pool mechanism. And P8 needs the push subject and pop subject in the correct sequence, or there may be unauthenticated error returned by CPE server. Actually I'd think that may be more key to have the synchronized block for P8 actions.
------------------------------
JIE ZHANG
Original Message:
Sent: Thu June 29, 2023 10:43 AM
From: Marcel Kostal
Subject: Synchronized block in ICN PluginService
Hello Calvin
I understand the reason why the p8 connection should be used only by one thread, but I will try to rephrase the original question:
will callbacks.getP8ObjectStore or callbacks.getP8Connection return always the same and only ObjectStore/Connection (for specified repositoryId)? Or is there any connection pooling? If yes, where can it be configured (e.g. size of the pool)?
Because if there's no connection pooling, it has very limited throughput. All requests from users that are served by multiple threads (configured in WAS) will wait for one p8 connection. And the only 2 options to scale the system up are:
a) install another ICN instance/server - so it is limiting horizontal scaling a lot (it creates lot of overhead).
b) define multiple repositories in ICN for the same p8 objectstore and implement own connection/repository pooling (e.g. for each usecase/feature use different repository). Most of the features has option to not include other repositories - so user will not get confused, but Home feature includes all repositories for the desktop and it can be confusing for the end user - why he have more repositories there and which one to select). - so here I would suggest either to have option to define "hidden" repository for desktop or allow hiding repository for Home feature.
...but ideally if callback.getP8* operation provides pooled connection and the pool can be configured.
------------------------------
Marcel Kostal
Original Message:
Sent: Wed June 28, 2023 01:05 AM
From: JIE ZHANG
Subject: Synchronized block in ICN PluginService
Actually, it is because those APIs return objects of the repositories API, or a wrap of them. Followed processing code will be repositories API callings. It belongs to the repositories API programming area in a multi-thread environment, like FileNet P8 CPE API. When you get a connection or an object store object, which should have a connection inside, or it cannot do the real actions against CPE server, if in a multi-thread environment, and you don't want the object be touched by other threads, synchronized block should be used.
------------------------------
JIE ZHANG
Original Message:
Sent: Mon June 26, 2023 07:37 PM
From: David Alfredson
Subject: Synchronized block in ICN PluginService
Hi,
The documentation is fairly vague. Even the use of it in the examples is fairly obtuse. Without a complete definition it means everyone does this over and over with trial and error, wasting development time and generating solutions that can cause issues as the documentation isn't clear, complete and concise.
It doesn't indicate WHY you need to use a synchronised block, WHAT happens if you do and WHAT happens if you don't. The original question asked for that level of information which isn't in any response I've seen so far and isn't in the documentation either. Is it possible to get those three things in this thread, and perhaps backfilled into the documentation?
------------------------------
David Alfredson
Original Message:
Sent: Fri June 23, 2023 12:50 PM
From: Nanda Pilaka
Subject: Synchronized block in ICN PluginService
As per the documentation here, some of these methods would need to used with a synchronized block -> https://www.ibm.com/docs/en/content-navigator/3.0.12?topic=comibmecmextension-pluginservicecallbacks. Please review and let us know your comments. We will provide additional comments.
------------------------------
Nanda Pilaka
IBM Content Navigator Support
Original Message:
Sent: Thu June 22, 2023 05:06 AM
From: Gabriela Maráková
Subject: Synchronized block in ICN PluginService
Hi everyone,I would like to ask you about best practices for using getSynchObject in custom PluginService.I read "Customizing and Extending IBM Content Navigator" redbook and filenet api for class PluginServiceCallbacks, but I still have several questions:- Do I need to use synchronized block everytime I read data from objectStore?- Do I need to use synchronized block everytime I write data to objectStore?- It is needed to use synchronized block only if I am using one of these methods?
getCMDatastore
getODServer
getP8Connection
getCMISSession
retrieveDocumentContent
retrieveJSONAnnotations
getCMDocumentDDO
getODDocument
addODNote
getCMAnnotationsXDO
getCMBookmarksXDO
getODNotes- Do I need to use synchronized block in case I get objectstore object the way below?
public void execute(PluginServiceCallbacks callbacks, HttpServletRequest request, HttpServletResponse response) throws Exception { String repositoryId = request.getParameter("repositoryId"); ObjectStore objectStore = callbacks.getP8ObjectStore(repositoryId); }
- Why do you need to use synchronized block in chapter 5.3.1 "Sample code of custom repository search service" for p8 calls?
Thank you.
------------------------------
Gabriela Maráková
------------------------------