com.atomikos.icatch.msg
Interface Transport

All Superinterfaces:
RecoverableResource
All Known Implementing Classes:
AbstractTransport, AtomikosHttpTransport, HttpTransport, WsatHttpTransport

public interface Transport
extends RecoverableResource

A generic transport interface. A Transport creates, sends and receives messages and has callback mechanisms for message listeners. It is used by the MessageParticipant. Message delivery is NOT reliable: messages can be lost and are discarded if nobody is listening for them or waiting in a receive. Note that a transport is also a recoverable resource, since MessageParticipants ask the transport whether they can be recovered or not. Only the transport knows if it can handle the protocol and wire protocol of a given MessageParticipant.


Field Summary
static int FTP
          Constant indicating FTP transport protocol.
static int HTTP
          Constant indicating a HTTP transport protocol.
static int JMS
          Constant indicating a JMS transport protocol.
static int SMTP
          Constant indicating SMTP transport protocol.
static int UNKNOWN_PROTOCOL
          Constant indicating an unknown transport protocol.
 
Method Summary
 CommitMessage createCommitMessage(boolean onephase, String senderURI, String targetURI, Object targetAddress)
          Create a new commit message.
 ErrorMessage createErrorMessage(int code, String senderURI, String targetURI, Object targetAddress)
          Create a new error message.
 ForgetMessage createForgetMessage(String senderURI, String targetURI, Object targetAddress)
          Create a new forget message.
 PreparedMessage createPreparedMessage(boolean readonly, String senderURI, String targetURI, Object targetAddress)
          Create a new prepared message.
 PrepareMessage createPrepareMessage(int globalSiblingCount, CascadeInfo[] cascadeInfo, String senderURI, String targetURI, Object targetAddress)
          Create a new prepare message.
 PrepareMessage createPrepareMessage(String senderURI, String targetURI, Object targetAddress)
          Create a new prepare message.
 RegisteredMessage createRegisteredMessage(String senderURI, String targetURI, Object targetAddress)
          Create a new registration confirmation message.
 RegisterMessage createRegisterMessage(String senderURI, String targetURI, Object targetAddress, boolean for2PC)
          Create a new registration message.
 ReplayMessage createReplayMessage(String senderURI, String targetURI, Object targetAddress)
          Create a new replay message.
 RollbackMessage createRollbackMessage(String senderURI, String targetURI, Object targetAddress)
          Create a new rollback message.
 StateMessage createStateMessage(Boolean committed, String senderURI, String targetURI, Object targetAddress)
          Create a new state message.
 int getCommitProtocol()
          The protocol that this transport understands.
 String getCoordinatorAddress()
          Get the address on which this transport is listening for incoming coordinator messages.
 long getDefaultTimeout()
          Get a realistic default timeout for the given transport.
 int getFormat()
          Get the message format that this transport understands.
 String getParticipantAddress()
          Get the address on which this transport is listening for incoming participant messages.
 int getTransportProtocol()
          Get the transport protocol that this transport understands.
 void registerMessageListener(MessageListener listener)
          Register a message listener for unexpected receivals.
 void registerMessageListener(MessageListener listener, int messageType)
          Register a message listener for incoming messages of the given type.
 void removeMessageListener(MessageListener listener)
          Remove a previously registered listener.
 void send(TransactionMessage msg)
          Send a message.
 TransactionMessage sendAndReceive(TransactionMessage msg, long timeout, int[] expected)
          Send and receive a message for the given target.
 
Methods inherited from interface com.atomikos.datasource.RecoverableResource
close, endRecovery, getName, isClosed, isSameRM, recover, setRecoveryService
 

Field Detail

UNKNOWN_PROTOCOL

static final int UNKNOWN_PROTOCOL
Constant indicating an unknown transport protocol.

See Also:
Constant Field Values

HTTP

static final int HTTP
Constant indicating a HTTP transport protocol.

See Also:
Constant Field Values

SMTP

static final int SMTP
Constant indicating SMTP transport protocol.

See Also:
Constant Field Values

JMS

static final int JMS
Constant indicating a JMS transport protocol.

See Also:
Constant Field Values

FTP

static final int FTP
Constant indicating FTP transport protocol.

See Also:
Constant Field Values
Method Detail

getCommitProtocol

int getCommitProtocol()
The protocol that this transport understands.

Returns:
int The protocol, as defined in CommitProtocol.

getFormat

int getFormat()
Get the message format that this transport understands.

Returns:
int The message format, as defined in TransactionMessage.

getTransportProtocol

int getTransportProtocol()
Get the transport protocol that this transport understands.

Returns:
int The transport protocol. One of the predefined constants.

getCoordinatorAddress

String getCoordinatorAddress()
Get the address on which this transport is listening for incoming coordinator messages.

Returns:
String The address.

getParticipantAddress

String getParticipantAddress()
Get the address on which this transport is listening for incoming participant messages.

Returns:
String The address.

getDefaultTimeout

long getDefaultTimeout()
Get a realistic default timeout for the given transport.

Returns:
long The timeout in milliseconds. After this time, a message may be considered lost in the system.

sendAndReceive

TransactionMessage sendAndReceive(TransactionMessage msg,
                                  long timeout,
                                  int[] expected)
                                  throws TransportException,
                                         IllegalMessageTypeException
Send and receive a message for the given target.

Parameters:
msg - The message to send.
expected - The types of messages expected. Other messages are ignored. The values should be of TransactionMessage's predefined types.
timeout - The timeout in milliseconds after which the method will return, received or not.
Returns:
TransactionMessage The message, or null if timedout.
Throws:
IllegalMessageTypeException - If the message sent is of the wrong type.
TransportException

send

void send(TransactionMessage msg)
          throws TransportException,
                 IllegalMessageTypeException
Send a message.

Parameters:
msg - The message to send.
Throws:
IllegalMessageTypeException - If the message sent is of the wrong type.
TransportException - On failure.

registerMessageListener

void registerMessageListener(MessageListener listener)
                             throws TransportException
Register a message listener for unexpected receivals. This method should work even before recover is called.

Parameters:
listener - The message listener.
Throws:
TransportException - On failure.

registerMessageListener

void registerMessageListener(MessageListener listener,
                             int messageType)
                             throws TransportException
Register a message listener for incoming messages of the given type. This method should work even before recover is called.

Parameters:
listener - The listener.
messageType - The type to listen for.
Throws:
TransportException - On failure.

removeMessageListener

void removeMessageListener(MessageListener listener)
                           throws TransportException
Remove a previously registered listener. This method should work even after close.

Parameters:
listener - The message listener.
Throws:
TransportException - On failure.

createCommitMessage

CommitMessage createCommitMessage(boolean onephase,
                                  String senderURI,
                                  String targetURI,
                                  Object targetAddress)
Create a new commit message.


createErrorMessage

ErrorMessage createErrorMessage(int code,
                                String senderURI,
                                String targetURI,
                                Object targetAddress)
Create a new error message.


createForgetMessage

ForgetMessage createForgetMessage(String senderURI,
                                  String targetURI,
                                  Object targetAddress)
Create a new forget message.


createPrepareMessage

PrepareMessage createPrepareMessage(String senderURI,
                                    String targetURI,
                                    Object targetAddress)
Create a new prepare message.


createPrepareMessage

PrepareMessage createPrepareMessage(int globalSiblingCount,
                                    CascadeInfo[] cascadeInfo,
                                    String senderURI,
                                    String targetURI,
                                    Object targetAddress)
Create a new prepare message.


createPreparedMessage

PreparedMessage createPreparedMessage(boolean readonly,
                                      String senderURI,
                                      String targetURI,
                                      Object targetAddress)
Create a new prepared message. The option default_rollback is not used by our software, so we do not allow setting it to other than the default value.


createReplayMessage

ReplayMessage createReplayMessage(String senderURI,
                                  String targetURI,
                                  Object targetAddress)
Create a new replay message.


createRollbackMessage

RollbackMessage createRollbackMessage(String senderURI,
                                      String targetURI,
                                      Object targetAddress)
Create a new rollback message.


createStateMessage

StateMessage createStateMessage(Boolean committed,
                                String senderURI,
                                String targetURI,
                                Object targetAddress)
Create a new state message.


createRegisterMessage

RegisterMessage createRegisterMessage(String senderURI,
                                      String targetURI,
                                      Object targetAddress,
                                      boolean for2PC)
Create a new registration message.


createRegisteredMessage

RegisteredMessage createRegisteredMessage(String senderURI,
                                          String targetURI,
                                          Object targetAddress)
Create a new registration confirmation message.



Copyright © 2012. All Rights Reserved.