Gamini,
Since you are working with a webserver, there should be no problems
with multiple request coming in at once (they will fork or
thread out the connection) - you will have to get the input
stream with something like:
// Convert urlString into a BufferedReader
URL url = new URL(urlString);
URLConnection connection = url.openConnection();
InputStream is = connection.getInputStream();
InputStreamReader isr = new InputStreamReader(is);
BufferedReader br = new BufferedReader(isr);
Else if you were working directly with Sockets, then you will have to open
up a connection (which *should* be "forked" out on the server side, so
you don't have to contend for connection requests.), you can maintain
the connection for a period of time (Timeout) in an Stateless Session Bean
member variable. Then you send a request (of whatever prototocol you agree to) and
read
a response. You can handle these in two different threads (if you work outside
the J2EE container - actually I suppose you could share the connection between a writer
and reader SSB - but this would get tricky as the Container manages them).
Make sure you maintain/check your connections and account for passivation of your bean.
As Leonard mentioned in another email on this thread, you could work
with a JMS queue in a separate JVM and manage threads and messages
to/from SSB and sockets this way... (this is a good approach)
Check out: http://java.sun.com/docs/books/tutorial/networking/sockets/clientServer.html
for more information on sockets programming.
By the way all of this conversation depends heavily on how the card
processor is dealing with requests... and you should have an Architect
or team of them to make sure your design is a good one. Otherwise
you could be in for a lot of hit-and-miss suprises...etc.
-Joel
Gamini de Alwis wrote:
> Joel
> Thank you very much for your response. Do you mean that the container
> would allow the many SSB's to use the Port in parallel i.e. many
> requests would be dispatched while others are awaiting their matching
> responses?
> I would be grateful if you could share some of code fragments of your
> implementation.
> regards
>
> Gamini de Alwis
> mailto:[EMAIL PROTECTED]
> Software Developer
> Business Manager Software
> Tel (03) 9813 3022. Fax (03) 9882 5887
>
> -----Original Message-----
> From: Joel A. Thompson [mailto:[EMAIL PROTECTED]]
> Sent: Wednesday, January 24, 2001 4:47 AM
> To: [EMAIL PROTECTED]
> Subject: Re: Credit Card Authorization
>
> Why not use a stateless session bean, which has the handle
> to the Socket in a member variable. This way you can control
> the number of SSB's. Make sure to initialize the connection, then
> use the SSB by invoking a single method call... ie ssb.sendRequest(),
> that
> gives a response back. (Opposed to ssb.sendRequest() and
> ssb.getResponse())...
>
> re: "The problem is the single nominated port and the fact that threads
> are
> handled within the J2EE container."
> Usually requests on the port will be forked out by the Server as soon
> as the OPEN request comes in. This way you won't have to worry
> about bottlenecking on the port... As far as the threads within the
> J2ee
> container go... this is why you'd use the SSB, it will even "queue"
> requests if all SSB are currently in use.
>
> -Joel
> --
> --------------------------------------
> RHINO Systems Inc.
> RDBMS and Internet development
> Java/EJB/Oracle systems
> www.rhinosystemsinc.com
> EFAX#: (425)969-0745
> --------------------------------------
>
> Gamini de Alwis wrote:
>
> > Hello,
> > I am working on a typical shopping cart type application based on
> J2EE.
> > I am a bit stuck with the problem of Credit Card Authorization in
> > supplying credit card details to a clearing house and receiving a
> > response. I would like to do this from the server side. The Vendor
> > identified by us wants us to invoke an SSL socket on a given port and
> > send information via a standard POST request and will return a
> standard
> > response. Both the request and response can and will be stamped with a
> > unique reference.
> > The problem is the single nominated port and the fact that threads are
> > handled within the J2EE container.
> > Perhaps someone has been able to solve this problem and I would be
> > grateful for any suggestions or possible solutions to this problem.
> >
> > regards
> >
> > Gamini de Alwis
> > mailto:[EMAIL PROTECTED]
> > > Software Developer
> > > Business Manager Software
> > > Tel (03) 9813 3022. Fax (03) 9882 5887
> > >
> > >
> >
> >
> ========================================================================
> ===
> > To unsubscribe, send email to [EMAIL PROTECTED] and include in the
> body
> > of the message "signoff EJB-INTEREST". For general help, send email
> to
> > [EMAIL PROTECTED] and include in the body of the message "help".
>
> ========================================================================
> ===
> To unsubscribe, send email to [EMAIL PROTECTED] and include in the
> body
> of the message "signoff EJB-INTEREST". For general help, send email to
> [EMAIL PROTECTED] and include in the body of the message "help".
>
> ===========================================================================
> To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
> of the message "signoff EJB-INTEREST". For general help, send email to
> [EMAIL PROTECTED] and include in the body of the message "help".
--
--------------------------------------
RHINO Systems Inc.
RDBMS and Internet development
Java/EJB/Oracle systems
www.rhinosystemsinc.com
EFAX#: (425)969-0745
--------------------------------------
===========================================================================
To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
of the message "signoff EJB-INTEREST". For general help, send email to
[EMAIL PROTECTED] and include in the body of the message "help".