com.sap.aii.af.service.idmap

Class MessageIDMapper

java.lang.Object
  extended by com.sap.aii.af.service.idmap.MessageIDMapper

public class MessageIDMapper
extends Object

MessageIDMapper is a singleton that allows applications to create id mappings in a transactional manner. MessageIDMapper mapper = MessageIDMapper.getInstance(); mapper.createIDMap(mid1, mid2);


Method Summary
 void createIDMap(MessageKey mkey1, MessageKey mkey2, long archiveAfter, boolean callPMIAgent, boolean transactional)
          Creates a map between two message keys.
 void createIDMap(String mid1, String mid2, long archiveAfter)
           
 void createIDMap(String mid1, String mid2, long archiveAfter, boolean transactional)
          Creates a map between two message ids.
 void decrementDuplicateCount(String mid1, int duplicateThreshold)
          Decrements the duplicate count for message id MSG_ID1
 void decrementDuplicateCount(String mid1, int duplicateThreshold, boolean transactional)
          Decrements the duplicate count for message id MSG_ID1
 com.sap.aii.af.service.idmap.IDMap getIDMapExt(String mid)
          Get ID Map Extended.
static MessageIDMapper getInstance()
          Gets the singleton MessageIDMapper
 String getMappedId(String mid)
          Retrieves a message id from the mapped message ids.
 MessageKey getMappedKey(MessageKey mkey)
          Retrieves a message key from the mapped message keys.
 void incrementDuplicateCount(String mid1)
          Increments the duplicate count for message id MSG_ID1
 void incrementDuplicateCount(String mid1, boolean transactional)
          Increments the duplicate count for message id MSG_ID1
 LinkedList<String[]> readIDMapEntries()
          Reads all IDMap entries available in the DB and returns them as a LinkedList of IDMap objects.
 String remove(String mid)
           
 String remove(String mid, boolean transactional)
          Removes the message id map entry for this id.
 void removeExpiredIDMaps()
           
 void removeExpiredIDMaps(Timestamp timeStamp)
          Deletes all IDMapper entries, where the persist duration has already expired.
 void removeExpiredIDMaps(Timestamp timeStamp, int bulkLimit)
          Deletes all IDMapper entries, where the persist duration has already expired.
 void updateIDMap(String mid1, String new_mid2, long archiveAfter, boolean transactional)
          Updates the mapped message identifier for a given MSG_ID1.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

getInstance

public static MessageIDMapper getInstance()
Gets the singleton MessageIDMapper

Returns:
the MessageIDMapper singleton.

getMappedId

public String getMappedId(String mid)
Retrieves a message id from the mapped message ids.

Parameters:
mid - the message id.
Returns:
the mapped id for the given input, null if no id exists.

getIDMapExt

public com.sap.aii.af.service.idmap.IDMap getIDMapExt(String mid)
Get ID Map Extended. Retrieves MSG_ID2, PERSIST_UNTIL for a given MSG_ID1.

Parameters:
mid - the message id (MSG_ID1).
Returns:
the selected row as a IDMap object, null if no id exists.

getMappedKey

public MessageKey getMappedKey(MessageKey mkey)
Retrieves a message key from the mapped message keys. When using this method, the entry needs to be written with the createIDMap method with the message key parameters.

Parameters:
mkey - the message key.
Returns:
the mapped key for the given input, null if no key exists.

remove

public String remove(String mid,
                     boolean transactional)
Removes the message id map entry for this id.

Parameters:
mid - the message id for which to remove the map.
Returns:
Always returns null.

remove

public String remove(String mid)

createIDMap

public void createIDMap(String mid1,
                        String mid2,
                        long archiveAfter)
                 throws UtilException
Throws:
UtilException

createIDMap

public void createIDMap(String mid1,
                        String mid2,
                        long archiveAfter,
                        boolean transactional)
                 throws UtilException
Creates a map between two message ids. Both ids should be GUIDs so that it should be possible to retrieve ids in both directions based on either id without collisions.

Parameters:
mid1 - the first message id.
mid2 - the second message id.
archiveAfter - a point in time represented in milliseconds as per the java standard after which this message id mapping will no longer be required and can be archived.
transactional - specifies if the IDMap entry should be written in an existing transactional context
Throws:
MessagingException - if one of the ids already exists in the database.
UtilException

updateIDMap

public void updateIDMap(String mid1,
                        String new_mid2,
                        long archiveAfter,
                        boolean transactional)
                 throws UtilException
Updates the mapped message identifier for a given MSG_ID1. It is used for updating the progress of content conversion in file adapter, as current behaviour is to call remove and insert again.

Parameters:
mid1 - the unique message identifier, unique index on MSG_ID1 is introduced with note 1656793
new_mid2 -
Throws:
UtilException

createIDMap

public void createIDMap(MessageKey mkey1,
                        MessageKey mkey2,
                        long archiveAfter,
                        boolean callPMIAgent,
                        boolean transactional)
                 throws UtilException
Creates a map between two message keys. Both ids should be GUIDs so that it should be possible to retrieve ids in both directions based on either id without collisions. IDMap entries created with this method have to be checked using the getMappedKey method.

Parameters:
mkey1 - the first message key.
mkey2 - the second message key.
archiveAfter - a point in time represented in milliseconds as per the java standard after which this message id mapping will no longer be required and can be archived.
transactional - specifies if the IDMap entry should be created as part or a transactional context
callPMIAgent - specifies if the IDMapping PMI agent should be called
Throws:
MessagingException - if one of the ids already exists in the database.
UtilException

incrementDuplicateCount

public void incrementDuplicateCount(String mid1)
                             throws UtilException
Increments the duplicate count for message id MSG_ID1

Parameters:
mid1 - the first message id.
Throws:
UtilException

incrementDuplicateCount

public void incrementDuplicateCount(String mid1,
                                    boolean transactional)
                             throws UtilException
Increments the duplicate count for message id MSG_ID1

Parameters:
mid1 - the first message id.
transactional - specifies if the IDMap entry should be written in an existing transactional context
Throws:
UtilException - in case of any exception

decrementDuplicateCount

public void decrementDuplicateCount(String mid1,
                                    int duplicateThreshold)
                             throws UtilException
Decrements the duplicate count for message id MSG_ID1

Parameters:
mid1 - the first message id.
duplicateThreshold - limit for duplicate messages
Throws:
UtilException

decrementDuplicateCount

public void decrementDuplicateCount(String mid1,
                                    int duplicateThreshold,
                                    boolean transactional)
                             throws UtilException
Decrements the duplicate count for message id MSG_ID1

Parameters:
mid1 - the first message id.
duplicateThreshold - limit for duplicate messages
transactional - specifies if the IDMap entry should be written in an existing transactional context
Throws:
UtilException - in case of any exception

removeExpiredIDMaps

public void removeExpiredIDMaps(Timestamp timeStamp)
Deletes all IDMapper entries, where the persist duration has already expired.


removeExpiredIDMaps

public void removeExpiredIDMaps(Timestamp timeStamp,
                                int bulkLimit)
Deletes all IDMapper entries, where the persist duration has already expired. Mind the bulk limit property.


removeExpiredIDMaps

public void removeExpiredIDMaps()

readIDMapEntries

public LinkedList<String[]> readIDMapEntries()
Reads all IDMap entries available in the DB and returns them as a LinkedList of IDMap objects. This method is for testing only!.

Access Rights

This class can be accessed from:


SC DC Public Part ACH
[sap.com] SAP_XIAF [sap.com] com.sap.aii.af.svc.facade api BC-XI


Copyright 2014 SAP AG Complete Copyright Notice