Websphere MQ Everyplace

com.ibm.mqe.adapters
Class MQeTcpipAdapter

java.lang.Object
  |
  +--com.ibm.mqe.adapters.MQeCommunicationsAdapter
        |
        +--com.ibm.mqe.adapters.MQeTcpipAdapter
Direct Known Subclasses:
MQeTcpipHttpAdapter, MQeTcpipLengthAdapter, MQeWESAuthenticationAdapter

public abstract class MQeTcpipAdapter
extends MQeCommunicationsAdapter

The MQeTcpipAdapter is an adapter that provides support for reading and writing data over TCP/IP streams.

This adapter cannot be used to connect two WebSphere MQ Everyplace applications, as it does not provide a protocol for the exchange of data. Various adapters that inherit from this class provide some possible protocols.

An instance of this class can be used to either listen for incoming TCP/IP connections, or connect to an existing listener. It is not possible for a single MQeTcpipAdapter object to do both.

See Also:
MQeTcpipLengthAdapter, MQeTcpipHttpAdapter, MQeTcpipHistoryAdapter

Field Summary
 
Fields inherited from class com.ibm.mqe.adapters.MQeCommunicationsAdapter
COMMS_ADAPTER_ADDRESS, COMMS_ADAPTER_CLASS, COMMS_ADAPTER_GROUP_SIZE, COMMS_ADAPTER_HTTP_VERSION, COMMS_ADAPTER_LISTEN, COMMS_ADAPTER_NONBLOCKING_TIMEOUT, COMMS_ADAPTER_NOPERSIST, COMMS_ADAPTER_PERSIST, COMMS_ADAPTER_PKTSIZE, COMMS_ADAPTER_PORT, COMMS_ADAPTER_RETRIES, COMMS_ADAPTER_SERVLET, COMMS_ADAPTER_TIMEOUT, COMMS_ADAPTER_VARIANCE, listeningAdapter, persistentAdapter, responderAdapter
 
Constructor Summary
MQeTcpipAdapter()
           
 
Method Summary
 void activate(MQePropertyProvider info)
          Initialises a new MQeTcpipAdapter object.
 void close()
          Closes the current MQeTcpipAdapter object.
 void open()
          Opens a socket for use.
 byte[] readLength(int recordSize)
          Reads bytes from the underlying TCP/IP stream.
 java.lang.String readln()
          Reads a line of data from the underlying TCP/IP stream.
 void temporaryClose()
          If the adapter is not persistent calls the close method
 MQeCommunicationsAdapter waitForContact(MQePropertyProvider info)
          Only valid for a listening adapter, the adapter waits on a named socket for an incoming connection request.
 
Methods inherited from class com.ibm.mqe.adapters.MQeCommunicationsAdapter
createNewAdapter, isStopDemanded, isStopRequested, read, writeData, writeResponse
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

MQeTcpipAdapter

public MQeTcpipAdapter()
Method Detail

activate

public void activate(MQePropertyProvider info)
              throws java.lang.Exception

Initialises a new MQeTcpipAdapter object.

While the MQeTcpipAdapter is not intended for use by MQe, this method should be called inside the activate method of all the adapters that extend this class.

Specified by:
activate in class MQeCommunicationsAdapter
Returns:
void
Throws:
java.lang.Exception -
 DefaultTimeOut                    = 5000
 DefaultPacketSize                 = 4096
 DefaultRetry                      = 3
 

These properties should be changed with care, only if you understand the ramifications of altering the time out or packet size should they be altered.

These properties may be set by the command line parameter to the JVM using the -D option, for instance -Dcom.ibm.mqe.adapters.MQeCommunicationsAdapter.Timeout=500 or within a program using the System.setProperties() method, for instance System.setProperties("com.ibm.mqe.adapters.MQeCommunicationsAdapter.Timeout", "500").

Usage Example :

super.activate(MQePropertyProvider);
See Also:
MQeCommunicationsAdapter.COMMS_ADAPTER_ADDRESS, MQeCommunicationsAdapter.COMMS_ADAPTER_PORT, MQeCommunicationsAdapter.COMMS_ADAPTER_LISTEN, MQeCommunicationsAdapter.COMMS_ADAPTER_TIMEOUT, MQeCommunicationsAdapter.COMMS_ADAPTER_PKTSIZE, MQeCommunicationsAdapter.COMMS_ADAPTER_RETRIES, com.ibm.mqe.adapters.MQeCommunicationsAdapter#COMMS_ADAPTER_THREAD_STOP_CHECK

close

public void close()
           throws java.lang.Exception

Closes the current MQeTcpipAdapter object.

Closes the current adapter so that it can no longer be read from or written to.

Specified by:
close in class MQeCommunicationsAdapter
Returns:
void
Throws:
java.lang.Exception

open

public void open()
          throws java.lang.Exception

Opens a socket for use.

If this is a listening adapter then a new server socket is created. Otherwise a new socket is created.

Specified by:
open in class MQeCommunicationsAdapter
Returns:
void
Throws:
java.lang.Exception -

Usage Example :

super.open();

readLength

public byte[] readLength(int recordSize)
                  throws java.lang.Exception

Reads bytes from the underlying TCP/IP stream.

Parameters:
recordSize - An integer that specifies the maximum buffer size to read in one go. If this parameter is less than or equal to zero, then the variable adapterPacketSize is used. *
Returns:
byte[] The data in a byte array of up to adapterPacketSize bytes. The last "block" may be an array of less than adapterPacketSize bytes.
Throws:
java.io.EOFException - If no more data is available.
java.lang.Exception -

Usage Example :

byte []results =super.read(4096);

readln

public java.lang.String readln()
                        throws java.lang.Exception

Reads a line of data from the underlying TCP/IP stream.

Returns:
A String that contains the line read from the input stream.
Throws:
java.io.EOFException - If no more data is available.
java.lang.Exception -

Usage Example :

String results =super.readln(null);

temporaryClose

public void temporaryClose()
                    throws java.lang.Exception

If the adapter is not persistent calls the close method

Specified by:
temporaryClose in class MQeCommunicationsAdapter
Returns:
void
Throws:
java.lang.Exception -

Usage Example :

super.close();

waitForContact

public MQeCommunicationsAdapter waitForContact(MQePropertyProvider info)
                                        throws java.lang.Exception

Only valid for a listening adapter, the adapter waits on a named socket for an incoming connection request.

Specified by:
waitForContact in class MQeCommunicationsAdapter
Parameters:
info - contains the property information that is used to create a new adapter. This will need to contain the following fields, as well as the fields required to start the adapter.
Returns:
MQeCommunicationsAdapter a communications adapter
Throws:
MQeException - If the parameter object was not correct for the given option.
java.lang.Exception -

Usage Example :

See Also:
MQeCommunicationsAdapter.COMMS_ADAPTER_CLASS, MQeCommunicationsAdapter.COMMS_ADAPTER_LISTEN, * @return MQeCommunicationsAdapter, this is the adapter that was created as a result of a connection request

Websphere MQ Everyplace