use of nl.nn.adapterframework.jms.JmsException in project iaf by ibissource.
the class TibcoMessagingSource method lookupDestination.
public Destination lookupDestination(String destinationName) throws JmsException {
Session session = null;
try {
session = createSession(false, Session.AUTO_ACKNOWLEDGE);
log.debug("Session class [" + session.getClass().getName() + "]");
Destination destination;
/* create the destination */
if (session instanceof TopicSession) {
destination = ((TopicSession) session).createTopic(destinationName);
} else {
destination = ((QueueSession) session).createQueue(destinationName);
}
return destination;
} catch (Exception e) {
throw new JmsException("cannot create destination", e);
} finally {
releaseSession(session);
}
}
use of nl.nn.adapterframework.jms.JmsException in project iaf by ibissource.
the class EsbUtils method getEsbConnectionFactoryInfo.
private static EsbConnectionFactoryInfo getEsbConnectionFactoryInfo(EsbJmsListener esbJmsListener) {
String cfUrl = null;
String cfUserName = null;
String cfPassword = null;
Object managedConnectionFactory = null;
try {
managedConnectionFactory = esbJmsListener.getManagedConnectionFactory();
} catch (JmsException e) {
log.warn("error occured during getting managed connection factory: " + e.getMessage());
}
if (managedConnectionFactory == null) {
log.warn("could not get managed connection factory");
} else {
String contextFactoryClassname = getContextFactoryClassname(managedConnectionFactory);
if (contextFactoryClassname == null) {
log.warn("could not get context factory");
} else {
cfUrl = getProviderURL(managedConnectionFactory);
String authDataAlias = getAuthDataAlias(managedConnectionFactory);
if (authDataAlias != null) {
CredentialFactory cf = new CredentialFactory(authDataAlias, null, null);
cfUserName = cf.getUsername();
cfPassword = cf.getPassword();
}
if (!contextFactoryClassname.equals("com.tibco.tibjms.naming.TibjmsInitialContextFactory")) {
log.warn("did not expect context factory of type [" + contextFactoryClassname + "]");
} else {
return new EsbConnectionFactoryInfo(managedConnectionFactory, contextFactoryClassname, cfUrl, cfUserName, cfPassword);
}
}
}
return null;
}
use of nl.nn.adapterframework.jms.JmsException in project iaf by ibissource.
the class EsbUtils method receiveMessageAndMoveToErrorStorage.
public static String receiveMessageAndMoveToErrorStorage(EsbJmsListener esbJmsListener, JdbcTransactionalStorage errorStorage) {
String result = null;
PoolingConnectionFactory jmsConnectionFactory = null;
PoolingDataSource jdbcDataSource = null;
BitronixTransactionManager btm = null;
javax.jms.Connection jmsConnection = null;
try {
jmsConnectionFactory = getPoolingConnectionFactory(esbJmsListener);
if (jmsConnectionFactory != null) {
jdbcDataSource = getPoolingDataSource(errorStorage);
if (jdbcDataSource != null) {
String instanceNameLc = AppConstants.getInstance().getString("instance.name.lc", null);
String logDir = AppConstants.getInstance().getString("log.dir", null);
TransactionManagerServices.getConfiguration().setServerId(instanceNameLc + ".tm");
TransactionManagerServices.getConfiguration().setLogPart1Filename(logDir + File.separator + instanceNameLc + "-btm1.tlog");
TransactionManagerServices.getConfiguration().setLogPart2Filename(logDir + File.separator + instanceNameLc + "-btm2.tlog");
btm = TransactionManagerServices.getTransactionManager();
jmsConnection = jmsConnectionFactory.createConnection();
Session jmsSession = null;
MessageConsumer jmsConsumer = null;
java.sql.Connection jdbcConnection = null;
btm.begin();
log.debug("started transaction [" + btm.getCurrentTransaction().getGtrid() + "]");
try {
jmsSession = jmsConnection.createSession(true, Session.AUTO_ACKNOWLEDGE);
String queueName = esbJmsListener.getPhysicalDestinationShortName();
Queue queue = jmsSession.createQueue(queueName);
jmsConsumer = jmsSession.createConsumer(queue);
jmsConnection.start();
long timeout = 30000;
log.debug("looking for message on queue [" + queueName + "] with timeout of [" + timeout + "] msec");
Message rawMessage = jmsConsumer.receive(timeout);
if (rawMessage == null) {
log.debug("no message found on queue [" + queueName + "]");
} else {
String id = rawMessage.getJMSMessageID();
log.debug("found message on queue [" + queueName + "] with messageID [" + id + "]");
Serializable sobj = null;
if (rawMessage != null) {
if (rawMessage instanceof Serializable) {
sobj = (Serializable) rawMessage;
} else {
try {
sobj = new MessageWrapper(rawMessage, esbJmsListener);
} catch (ListenerException e) {
log.error("could not wrap non serializable message for messageId [" + id + "]", e);
if (rawMessage instanceof TextMessage) {
TextMessage textMessage = (TextMessage) rawMessage;
sobj = textMessage.getText();
} else {
sobj = rawMessage.toString();
}
}
}
}
jdbcConnection = jdbcDataSource.getConnection();
result = errorStorage.storeMessage(jdbcConnection, id, id, new Date(System.currentTimeMillis()), "moved message", null, sobj);
}
log.debug("committing transaction [" + btm.getCurrentTransaction().getGtrid() + "]");
btm.commit();
} catch (Exception e) {
if (btm.getCurrentTransaction() != null) {
log.debug("rolling back transaction [" + btm.getCurrentTransaction().getGtrid() + "]");
btm.rollback();
}
log.error("exception on receiving message and moving to errorStorage", e);
} finally {
if (jdbcConnection != null) {
jdbcConnection.close();
}
if (jmsConnection != null) {
jmsConnection.stop();
}
if (jmsConsumer != null) {
jmsConsumer.close();
}
if (jmsSession != null) {
jmsSession.close();
}
}
}
}
} catch (Exception e) {
log.error("exception on receiving message and moving to errorStorage", e);
} finally {
if (jmsConnection != null) {
try {
jmsConnection.close();
} catch (JMSException e) {
log.warn("exception on closing connection", e);
}
}
if (jmsConnectionFactory != null) {
jmsConnectionFactory.close();
}
if (jdbcDataSource != null) {
jdbcDataSource.close();
}
if (btm != null) {
btm.shutdown();
}
}
return result;
}
use of nl.nn.adapterframework.jms.JmsException in project iaf by ibissource.
the class PipeLine method configure.
/**
* Configures the pipes of this Pipeline and does some basic checks. It also
* registers the <code>PipeLineSession</code> object at the pipes.
* @see IPipe
*/
public void configure() throws ConfigurationException {
INamedObject owner = getOwner();
IAdapter adapter = null;
if (owner instanceof IAdapter) {
adapter = (IAdapter) owner;
}
if (cache != null) {
cache.configure(owner.getName() + "-Pipeline");
}
for (int i = 0; i < pipes.size(); i++) {
IPipe pipe = getPipe(i);
log.debug("Pipeline of [" + owner.getName() + "] configuring Pipe [" + pipe.getName() + "]");
// forward is defined, it is not overwritten by the globals
for (String gfName : globalForwards.keySet()) {
PipeForward pipeForward = globalForwards.get(gfName);
pipe.registerForward(pipeForward);
}
if (pipe instanceof FixedForwardPipe) {
FixedForwardPipe ffpipe = (FixedForwardPipe) pipe;
if (ffpipe.findForward("success") == null) {
int i2 = i + 1;
if (i2 < pipes.size()) {
String nextPipeName = getPipe(i2).getName();
PipeForward pf = new PipeForward();
pf.setName("success");
pf.setPath(nextPipeName);
pipe.registerForward(pf);
} else {
PipeLineExit plexit = findExitByState("success");
if (plexit != null) {
PipeForward pf = new PipeForward();
pf.setName("success");
pf.setPath(plexit.getPath());
pipe.registerForward(pf);
}
}
}
}
configure(pipe);
}
if (pipeLineExits.size() < 1) {
throw new ConfigurationException("no PipeLine Exits specified");
}
if (this.firstPipe == null) {
throw new ConfigurationException("no firstPipe defined");
}
if (getPipe(firstPipe) == null) {
throw new ConfigurationException("no pipe found for firstPipe [" + firstPipe + "]");
}
IPipe inputValidator = getInputValidator();
IPipe outputValidator = getOutputValidator();
if (inputValidator != null && outputValidator == null && inputValidator instanceof IDualModeValidator) {
outputValidator = ((IDualModeValidator) inputValidator).getResponseValidator();
setOutputValidator(outputValidator);
}
if (inputValidator != null) {
log.debug("Pipeline of [" + owner.getName() + "] configuring InputValidator");
PipeForward pf = new PipeForward();
pf.setName("success");
inputValidator.registerForward(pf);
inputValidator.setName(INPUT_VALIDATOR_NAME);
configure(inputValidator);
}
if (outputValidator != null) {
log.debug("Pipeline of [" + owner.getName() + "] configuring OutputValidator");
PipeForward pf = new PipeForward();
pf.setName("success");
outputValidator.registerForward(pf);
outputValidator.setName(OUTPUT_VALIDATOR_NAME);
configure(outputValidator);
}
if (getInputWrapper() != null) {
log.debug("Pipeline of [" + owner.getName() + "] configuring InputWrapper");
PipeForward pf = new PipeForward();
pf.setName("success");
getInputWrapper().registerForward(pf);
getInputWrapper().setName(INPUT_WRAPPER_NAME);
configure(getInputWrapper());
}
if (getOutputWrapper() != null) {
log.debug("Pipeline of [" + owner.getName() + "] configuring OutputWrapper");
PipeForward pf = new PipeForward();
pf.setName("success");
if (getOutputWrapper() instanceof AbstractPipe && adapter instanceof Adapter) {
((AbstractPipe) getOutputWrapper()).setRecoverAdapter(((Adapter) adapter).isRecover());
}
getOutputWrapper().registerForward(pf);
getOutputWrapper().setName(OUTPUT_WRAPPER_NAME);
if (getOutputWrapper() instanceof EsbSoapWrapperPipe) {
EsbSoapWrapperPipe eswPipe = (EsbSoapWrapperPipe) getOutputWrapper();
boolean stop = false;
Iterator<IReceiver> recIt = adapter.getReceiverIterator();
if (recIt.hasNext()) {
while (recIt.hasNext() && !stop) {
IReceiver receiver = recIt.next();
if (receiver instanceof ReceiverBase) {
ReceiverBase rb = (ReceiverBase) receiver;
IListener listener = rb.getListener();
try {
if (eswPipe.retrievePhysicalDestinationFromListener(listener)) {
stop = true;
}
} catch (JmsException e) {
throw new ConfigurationException(e);
}
}
}
}
}
configure(getOutputWrapper());
}
requestSizeStats = new SizeStatisticsKeeper("- pipeline in");
if (isTransacted() && getTransactionTimeout() > 0) {
String systemTransactionTimeout = Misc.getSystemTransactionTimeout();
if (systemTransactionTimeout != null && StringUtils.isNumeric(systemTransactionTimeout)) {
int stt = Integer.parseInt(systemTransactionTimeout);
if (getTransactionTimeout() > stt) {
ConfigurationWarnings configWarnings = ConfigurationWarnings.getInstance();
String msg = "Pipeline of [" + owner.getName() + "] has a transaction timeout [" + getTransactionTimeout() + "] which exceeds the system transaction timeout [" + stt + "]";
configWarnings.add(log, msg);
}
}
}
int txOption = this.getTransactionAttributeNum();
if (log.isDebugEnabled())
log.debug("creating TransactionDefinition for transactionAttribute [" + getTransactionAttribute() + "], timeout [" + getTransactionTimeout() + "]");
txDef = SpringTxManagerProxy.getTransactionDefinition(txOption, getTransactionTimeout());
log.debug("Pipeline of [" + owner.getName() + "] successfully configured");
}
use of nl.nn.adapterframework.jms.JmsException in project iaf by ibissource.
the class ShowSecurityItems method addJmsRealms.
private ArrayList<Object> addJmsRealms() {
List<String> jmsRealms = JmsRealmFactory.getInstance().getRegisteredRealmNamesAsList();
ArrayList<Object> jmsRealmList = new ArrayList<Object>();
String confResString;
try {
confResString = Misc.getConfigurationResources();
if (confResString != null) {
confResString = XmlUtils.removeNamespaces(confResString);
}
} catch (IOException e) {
log.warn("error getting configuration resources [" + e + "]");
confResString = null;
}
for (int j = 0; j < jmsRealms.size(); j++) {
Map<String, Object> realm = new HashMap<String, Object>();
String jmsRealm = (String) jmsRealms.get(j);
String dsName = null;
String qcfName = null;
String tcfName = null;
String dsInfo = null;
String qcfInfo = null;
DirectQuerySender qs = (DirectQuerySender) ibisManager.getIbisContext().createBeanAutowireByName(DirectQuerySender.class);
qs.setJmsRealm(jmsRealm);
try {
dsName = qs.getDataSourceNameToUse();
dsInfo = qs.getDatasourceInfo();
} catch (JdbcException jdbce) {
// no datasource
}
if (StringUtils.isNotEmpty(dsName)) {
realm.put("name", jmsRealm);
realm.put("datasourceName", dsName);
realm.put("info", dsInfo);
if (confResString != null) {
String connectionPoolProperties = Misc.getConnectionPoolProperties(confResString, "JDBC", dsName);
if (StringUtils.isNotEmpty(connectionPoolProperties)) {
realm.put("connectionPoolProperties", connectionPoolProperties);
}
}
}
JmsSender js = new JmsSender();
js.setJmsRealm(jmsRealm);
try {
qcfName = js.getConnectionFactoryName();
qcfInfo = js.getConnectionFactoryInfo();
} catch (JmsException jmse) {
// no connectionFactory
}
if (StringUtils.isNotEmpty(qcfName)) {
realm.put("name", jmsRealm);
realm.put("queueConnectionFactoryName", qcfName);
realm.put("info", qcfInfo);
if (confResString != null) {
String connectionPoolProperties = Misc.getConnectionPoolProperties(confResString, "JMS", qcfName);
if (StringUtils.isNotEmpty(connectionPoolProperties)) {
realm.put("connectionPoolProperties", connectionPoolProperties);
}
}
}
tcfName = js.getTopicConnectionFactoryName();
if (StringUtils.isNotEmpty(tcfName)) {
realm.put("name", jmsRealm);
realm.put("topicConnectionFactoryName", tcfName);
}
jmsRealmList.add(realm);
}
return jmsRealmList;
}
Aggregations