Package com.ibm.di.connector
Class JMSConnector
- java.lang.Object
-
- com.ibm.di.connector.Connector
-
- com.ibm.di.connector.JMSConnector
-
- All Implemented Interfaces:
ConnectorInterface,VersionInfoInterface,javax.jms.MessageListener
- Direct Known Subclasses:
DISBConnector,IBMMQConnector
public class JMSConnector extends Connector implements javax.jms.MessageListener, ConnectorInterface
The JMS Connector uses underlying implementations to access JMS based systems. Since the constructor is not defined in the JMS specification we actually need a java class for each JMS system.
-
-
Field Summary
Fields Modifier and Type Field Description static java.lang.StringJMS_BROKERThe URL to the external brokerstatic java.lang.StringJMS_MESSAGE_PROPERTYThe name under which the JMS Property is stored in the Entrystatic java.lang.StringJMS_PASSWORDThe password to use for establishing connection with the queue/topic.static java.lang.StringJMS_Q_MANAGERThe name of the queue manager parameterstatic java.lang.StringJMS_SERVER_CHANNELWebsphere MQ server channelstatic java.lang.StringJMS_SSL_CIPHERThe name of the cipher the IBMMQ driver to use.static java.lang.StringJMS_SSL_SERVER_CHANNELWebsphere MQ encrypted server channelstatic java.lang.StringJMS_SSL_USE_FLAGTells whether a SSL should be usedstatic java.lang.StringJMS_USERNAMEThe username to use for establishing connection with the queue/topic.static java.lang.StringMESSAGE_ATTRIBUTEThe attribute name used for plain text messages-
Fields inherited from class com.ibm.di.connector.Connector
ALL_MODES, myLog, PROPERTY_MESSAGE, PROPERTY_READER, PROPERTY_WRITER
-
-
Constructor Summary
Constructors Constructor Description JMSConnector()Constructor for the JMSConnector object
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description java.lang.Stringacknowledge()Acknowledge all messages received in this topicSession.voidcommit()Commits all messages done in this transaction.javax.jms.Messageentry2message(Entry entry)Convert an entry to a JMS message.EntryfindEntry(SearchCriteria search)Query the queue for specific messages.java.lang.StringgetIBMCharset(javax.jms.BytesMessage bytesmessage)Gets the name of the charset set as a property to aBytesMessageEntrygetNextEntry()Gets the nextEntry attribute of the JMSConnector objectjavax.jms.QueuegetQueue()Gets the sendQueue member of the JMSConnector objectjavax.jms.QueuegetReadQueue()Gets the readQueue member of the JMSConnector objectjavax.jms.QueuegetSendQueue()Gets the sendQueue member of the JMSConnector objectjavax.jms.SessiongetSession()Gets the Session member of the JMSConnector object If topicSession non equals to null then return topicSession else return queueSessionjavax.jms.TopicgetTopic()Gets the topic member of the JMSConnector objectjava.lang.StringgetVersion()Return version informationvoidinitialize(java.lang.Object o)Initialize the ConnectorEntrymessage2entry(javax.jms.Message m)Convert a JMS message to an entry.voidonMessage(javax.jms.Message message)Handles the arrived messagevoidputEntry(Entry entry)Send an entry to the JMS server.EntryqueryReply(Entry entry)This method uses temporary queues/topics to implement the queryReply method.voidreconnect()Reconnect to the underlying data source.voidrollback()Rolls back any messages done in this transaction.voidselectEntries()We only start the queue/topic listener thread if we are iteratingvoidsetFactory(javax.jms.ConnectionFactory factory)Sets topicFactory or queueFactory members of the JMSConnector object If the parameter is instance of TopicConnectionFactory set topicFactory If the parameter is instance of QueueConnectionFactory set queueFactoryvoidsetReadQueue(javax.jms.Queue queue)Sets the readQueue member of the JMSConnector objectvoidsetSendQueue(javax.jms.Queue queue)Sets the sendQueue member of the JMSConnector objectvoidsetTopic(javax.jms.Topic topic)Sets the topic member of the JMSConnector objectvoidterminate()Close the connection-
Methods inherited from class com.ibm.di.connector.Connector
addFindEntry, allModes, clearFindEntries, debug, debugMode, deleteEntry, extractExceptionInformation, findEntry, getBoolean, getClassInstance, getConfiguration, getContext, getFindEntryCount, getFirstFindEntry, getLog, getMaxDuplicateEntries, getModes, getModes, getName, getNextClient, getNextFindEntry, getParam, getParser, getProperty, getPushbackEntry, getRawConnectorConfiguration, getRSInterface, getUI, hasConfigValue, hasParser, initParser, isDeltaSupported, isExceptionFatal, isIOException, logError, logmsg, modEntry, modEntry, pushback, queryOperations, querySchema, queryTables, reconnect, registerScriptBeans, replyEntry, setConfiguration, setContext, setCurrent, setDebugMode, setLog, setMaxDuplicateEntries, setModes, setModes, setName, setParam, setParser, setProperty, setRSInterface, terminateServer
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface com.ibm.di.connector.ConnectorInterface
deleteEntry, getConfiguration, getContext, getFindEntryCount, getFirstFindEntry, getMaxDuplicateEntries, getName, getNextClient, getNextFindEntry, getParam, getPushbackEntry, getRawConnectorConfiguration, isDeltaSupported, isExceptionFatal, isIOException, modEntry, modEntry, pushback, queryOperations, querySchema, reconnect, registerScriptBeans, replyEntry, setConfiguration, setContext, setCurrent, setLog, setMaxDuplicateEntries, setName, setParam, setRSInterface, terminateServer
-
-
-
-
Field Detail
-
MESSAGE_ATTRIBUTE
public static final java.lang.String MESSAGE_ATTRIBUTE
The attribute name used for plain text messages- See Also:
- Constant Field Values
-
JMS_MESSAGE_PROPERTY
public static final java.lang.String JMS_MESSAGE_PROPERTY
The name under which the JMS Property is stored in the Entry- See Also:
- Constant Field Values
-
JMS_BROKER
public static final java.lang.String JMS_BROKER
The URL to the external broker- See Also:
- Constant Field Values
-
JMS_SERVER_CHANNEL
public static final java.lang.String JMS_SERVER_CHANNEL
Websphere MQ server channel- See Also:
- Constant Field Values
-
JMS_SSL_SERVER_CHANNEL
public static final java.lang.String JMS_SSL_SERVER_CHANNEL
Websphere MQ encrypted server channel- See Also:
- Constant Field Values
-
JMS_Q_MANAGER
public static final java.lang.String JMS_Q_MANAGER
The name of the queue manager parameter- See Also:
- Constant Field Values
-
JMS_SSL_USE_FLAG
public static final java.lang.String JMS_SSL_USE_FLAG
Tells whether a SSL should be used- See Also:
- Constant Field Values
-
JMS_SSL_CIPHER
public static final java.lang.String JMS_SSL_CIPHER
The name of the cipher the IBMMQ driver to use.
Possibilities:
SSL_RSA_WITH_DES_CBC_SHA
SSL_RSA_WITH_NULL_MD5
SSL_RSA_WITH_NULL_SHA
SSL_RSA_EXPORT_WITH_RC2_CBC_40_MD5
SSL_RSA_WITH_RC4_128_MD5
SSL_RSA_EXPORT_WITH_RC4_40_MD5
SSL_RSA_WITH_RC4_128_SHA
SSL_RSA_WITH_3DES_EDE_CBC_SHA
SSL_RSA_EXPORT1024_WITH_RC4_56_SHA
SSL_RSA_EXPORT1024_WITH_DES_CBC_SHA
SSL_RSA_WITH_AES_128_CBC_SHA
SSL_RSA_WITH_AES_256_CBC_SHA
SSL_RSA_FIPS_WITH_DES_CBC_SHA
SSL_RSA_FIPS_WITH_3DES_EDE_CBC_SHA- See Also:
- Constant Field Values
-
JMS_USERNAME
public static final java.lang.String JMS_USERNAME
The username to use for establishing connection with the queue/topic.- See Also:
- Constant Field Values
-
JMS_PASSWORD
public static final java.lang.String JMS_PASSWORD
The password to use for establishing connection with the queue/topic.- See Also:
- Constant Field Values
-
-
Method Detail
-
getTopic
public javax.jms.Topic getTopic()
Gets the topic member of the JMSConnector object- Returns:
- The topic value
-
setTopic
public void setTopic(javax.jms.Topic topic)
Sets the topic member of the JMSConnector object- Parameters:
topic- The topic value
-
getQueue
public javax.jms.Queue getQueue()
Gets the sendQueue member of the JMSConnector object- Returns:
- The sendQueue value
-
getSendQueue
public javax.jms.Queue getSendQueue()
Gets the sendQueue member of the JMSConnector object- Returns:
- The sendQueue value
-
getReadQueue
public javax.jms.Queue getReadQueue()
Gets the readQueue member of the JMSConnector object- Returns:
- The readQueue value
-
setSendQueue
public void setSendQueue(javax.jms.Queue queue)
Sets the sendQueue member of the JMSConnector object- Parameters:
queue- The sendQueue value
-
setReadQueue
public void setReadQueue(javax.jms.Queue queue)
Sets the readQueue member of the JMSConnector object- Parameters:
queue- The readQueue value
-
getSession
public javax.jms.Session getSession()
Gets the Session member of the JMSConnector object If topicSession non equals to null then return topicSession else return queueSession- Returns:
- The topicSession value
-
setFactory
public void setFactory(javax.jms.ConnectionFactory factory)
Sets topicFactory or queueFactory members of the JMSConnector object If the parameter is instance of TopicConnectionFactory set topicFactory If the parameter is instance of QueueConnectionFactory set queueFactory- Parameters:
factory- The TopicConnectionFactory or QueueConnectionFactory object
-
getNextEntry
public Entry getNextEntry() throws java.lang.Exception
Gets the nextEntry attribute of the JMSConnector object- Specified by:
getNextEntryin interfaceConnectorInterface- Overrides:
getNextEntryin classConnector- Returns:
- The nextEntry value
- Throws:
java.lang.Exception- if the operation does not succeed- See Also:
ConnectorInterface.selectEntries()
-
acknowledge
public java.lang.String acknowledge()
Acknowledge all messages received in this topicSession.- Returns:
- - null if OK, a string containing the error message if failure
-
terminate
public void terminate()
Close the connection- Specified by:
terminatein interfaceConnectorInterface- Overrides:
terminatein classConnector
-
initialize
public void initialize(java.lang.Object o) throws java.lang.ExceptionInitialize the Connector- Specified by:
initializein interfaceConnectorInterface- Overrides:
initializein classConnector- Parameters:
o- The mode of the Connector- Throws:
java.lang.Exception- if the initialization fails
-
selectEntries
public void selectEntries() throws java.lang.ExceptionWe only start the queue/topic listener thread if we are iterating- Specified by:
selectEntriesin interfaceConnectorInterface- Overrides:
selectEntriesin classConnector- Throws:
java.lang.Exception- if an exception occurs while listening for messages
-
findEntry
public Entry findEntry(SearchCriteria search) throws java.lang.Exception
Query the queue for specific messages. If jms.lookupConsumesMessage is true then we use the JMS QueueReceiver otherwise the QueueBrowser is used.- Specified by:
findEntryin interfaceConnectorInterface- Overrides:
findEntryin classConnector- Parameters:
search- The search criteria for message selection- Returns:
- Returns the first entry found or null if no entries were found
- Throws:
java.lang.Exception- Any JMS error
-
putEntry
public void putEntry(Entry entry) throws java.lang.Exception
Send an entry to the JMS server.- Specified by:
putEntryin interfaceConnectorInterface- Overrides:
putEntryin classConnector- Parameters:
entry- The entry to send- Throws:
java.lang.Exception- If the sending of a message fails
-
queryReply
public Entry queryReply(Entry entry) throws java.lang.Exception
This method uses temporary queues/topics to implement the queryReply method. The receiver of the message must heed the replyTo property of the message.- Specified by:
queryReplyin interfaceConnectorInterface- Overrides:
queryReplyin classConnector- Parameters:
entry- the entry to send.- Returns:
- the response as entry
- Throws:
java.lang.Exception- if a JMS exception occurs
-
onMessage
public void onMessage(javax.jms.Message message)
Handles the arrived message- Specified by:
onMessagein interfacejavax.jms.MessageListener- Parameters:
message- The received message
-
entry2message
public javax.jms.Message entry2message(Entry entry) throws java.lang.Exception
Convert an entry to a JMS message. Use the configuration to determine how the generated JMS message should be like.- Parameters:
entry- The entry to convert- Returns:
- The JMS message
- Throws:
java.lang.Exception- if an error occurs
-
getIBMCharset
public java.lang.String getIBMCharset(javax.jms.BytesMessage bytesmessage) throws javax.jms.JMSExceptionGets the name of the charset set as a property to aBytesMessage- Parameters:
bytesmessage- the byte message.- Returns:
- the name of the charset
- Throws:
javax.jms.JMSException- if an error occurs while retrieving the specific property.
-
message2entry
public Entry message2entry(javax.jms.Message m) throws java.lang.Exception
Convert a JMS message to an entry.- Parameters:
m- The JMS message to convert- Returns:
- An entry object
- Throws:
java.lang.Exception- if an error occurs
-
getVersion
public java.lang.String getVersion()
Return version information- Specified by:
getVersionin interfaceVersionInfoInterface- Returns:
- The version value
-
reconnect
public void reconnect() throws java.lang.ExceptionReconnect to the underlying data source.The following code could be placed in the 'On Connection lost' hook to change the connector's
ldapUrlto another server in case the connection is lost.Example:
thisConnector.setParam("ldapURL", "ldap://backupserver.acme.com:389"); // reconnect to backup server thisConnector.reconnect();- Overrides:
reconnectin classConnector- Throws:
java.lang.Exception- if an error occurs.- See Also:
Connector.initialize(Object)
-
commit
public void commit() throws javax.jms.JMSExceptionCommits all messages done in this transaction. This method can only be used with a transacted session.- Throws:
javax.jms.JMSException- Since:
- 7.2.0.1
-
rollback
public void rollback() throws javax.jms.JMSExceptionRolls back any messages done in this transaction. This method can only be used with a transacted session.- Throws:
javax.jms.JMSException- Since:
- 7.2.0.1
-
-