Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » EGL Development Tools » IBM i persistent connections (Are persistent connections possible in EDT?)
IBM i persistent connections [message #941736] Fri, 12 October 2012 20:20 Go to next message
Jeffrey Gardner is currently offline Jeffrey GardnerFriend
Messages: 20
Registered: August 2012
Junior Member
Persistent connections was a feature of an early EGL incarnation. Is this feature part of EDT?

If so, can you point me to "How To" documentation?
If not, is it a coming attraction?
Re: IBM i persistent connections [message #944579 is a reply to message #941736] Mon, 15 October 2012 02:56 Go to previous messageGo to next message
Joseph Vincens is currently offline Joseph VincensFriend
Messages: 31
Registered: December 2011
Location: Prospect CT
Member
Hi,

Very good question.
Yes it can be supported, but it's very different than RBD.

The EDT implementation is more open allowing you to supply an IBMiConnection to the call statement with the 'using' expression. There is a 1 to 1 association between the connection and the host Job. So you can write your own code to create, store, and retrieve IBMiConnections.

I have created a sample library that manages IBMiConnection and an example project showing how to use the library: http://git.eclipse.org/gitroot/edt/org.eclipse.edt.git/ibmi/org.eclipse.edt.jtopen.samples and http://git.eclipse.org/gitroot/edt/org.eclipse.edt.git/ibmi/org.eclipse.edt.ibmi.examples respectively.

These samples rely on J2EE functionality so they are only available to applications deployed on a application server. You could use some of the same concepts with a program in a batch environment.

In the example project server.GETREC.getCustomers gets fake customer information using a program on IBM I. The first request returns the first 10 records, the second request returns the second 10, etc. You would use the same 3 steps in your application replacing the application specific information. Here's what you need to do and it's shown in the example:
  1. use SessionConnectionsLib.getSessionConnection passing the system, userid, and password to get the IBMiConnection.
  2. use the IBMiConnection in the 'using' expression of a call statement that targets an IBMi proxy function (a function that has the IBMiProgram annotation).
  3. after the call returns use SessionConnectionsLib.returnConnectionToPool passing the IBMiConnection to return the connection to the pool. This is critical so the connection is available for the next use.


I think it will be useful if you understand the code that handles the persistent connection. Here is an overview of what happens in the SessionConnectionsLib.getSessionConnection:
  1. create a key that represents the system and userid.
  2. get the sessionid
    1. get the HttpServletRequest context created when the service was invoked
    2. get the HttpSession from the HttpServletRequest context.
    3. Return the sessionId from the HttpSession
  3. get the connections available for the specific sessionId
    The connections for a session are stored in a Dictionary, which is stored on a Java class (org.eclipse.edt.jtopen.connection.persistent.SessionConnectionPool) using the sessionId. The Java class has a static method used for getting a static instance of the class thereby creating the storage so the connections are available from invocation to invocation.
  4. get the IBMiConnection
    • If the key does not exist in the pool create and return a new IBMiConnection using the system, userid, and password.
    • if the key exists there is a connection in the pool. That connection is returned and removed from the pool. This prevents it from another call trying to use the connection while it's already in use.


If the sample does not suite your needs you are free to use any part of it to implement your requirements.

I hope this helps.
regards,
Joe
Re: IBM i persistent connections [message #945561 is a reply to message #944579] Mon, 15 October 2012 12:56 Go to previous messageGo to next message
Jeffrey Gardner is currently offline Jeffrey GardnerFriend
Messages: 20
Registered: August 2012
Junior Member
I couldn't get to the examples. Both links gave me a "404 not found - The requested URL /gitroot/edt/org.eclipse.edt.git/ibmi/org.eclipse.edt.ibmi.examples was not found on this server."
Re: IBM i persistent connections [message #947328 is a reply to message #945561] Wed, 17 October 2012 02:18 Go to previous messageGo to next message
Joseph Vincens is currently offline Joseph VincensFriend
Messages: 31
Registered: December 2011
Location: Prospect CT
Member
Hi,

These projects are in the Eclipse EDT git repository and the URL is used from within git to access the repositry.

You need to use git to get the projects here is some information on git for eclipse. http://wiki.eclipse.org/Git

Use http://git.eclipse.org/gitroot/edt/org.eclipse.edt.git to clone the repository. Then import org.eclipse.edt.jtopen.samples and org.eclipse.edt.ibmi.examples from the ibmi folder in the cloned repository.

regards,
Joe
Re: IBM i persistent connections [message #948157 is a reply to message #947328] Wed, 17 October 2012 20:19 Go to previous messageGo to next message
Jeffrey Gardner is currently offline Jeffrey GardnerFriend
Messages: 20
Registered: August 2012
Junior Member
Thanks very much. I finally got EGit installed into my Eclipse. But, the org.eclipse.edt.ibmi.examples project gives me an error:

- The type javax.servlet.http.HttpServletRequest cannot be resolved. It is indirectly referenced from required .class files
- ServerInfo.java
- /org.eclipse.edt.ibmi.examples/generatedJava/server

From where do I import the javax. type?
Re: IBM i persistent connections [message #949596 is a reply to message #948157] Fri, 19 October 2012 05:30 Go to previous message
Joseph Vincens is currently offline Joseph VincensFriend
Messages: 31
Registered: December 2011
Location: Prospect CT
Member
Hi,

The class is part of the server runtime. When the the project is deployed to a server the server adds the class. If you debug you app the jetty server will add the class, if you deploy to Tomcat, it adds the class.

To get rid of the compile error, add the server runtime to the Java Build path.
  • Add a server to your workspace.
    Preferences > servers > runtime
  • Add the server runtime to the project's Java Build path
    • Project properties.
    • Select Java Build Path.
    • Go to the libraries tab
    • Click the Add a Library button, select Server runtime, select the server you added.


regards,
Joe
Previous Topic:HTML5 Audio Widget
Next Topic:Out of memory
Goto Forum:
  


Current Time: Tue Nov 25 23:33:40 GMT 2014

Powered by FUDForum. Page generated in 0.14071 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software