use of com.sun.enterprise.connectors.jms.config.JmsService in project Payara by payara.
the class JmsProviderLifecycle method eagerStartupRequired.
private boolean eagerStartupRequired() {
JmsService jmsService = getJmsService();
if (jmsService == null)
return false;
List<JmsHost> jmsHostList = jmsService.getJmsHost();
if (jmsHostList == null)
return false;
String defaultJmsHostName = jmsService.getDefaultJmsHost();
JmsHost defaultJmsHost = null;
for (JmsHost host : jmsHostList) {
if (defaultJmsHostName != null && defaultJmsHostName.equals(host.getName())) {
defaultJmsHost = host;
break;
}
}
if (defaultJmsHost == null && jmsHostList.size() > 0) {
defaultJmsHost = jmsHostList.get(0);
}
boolean lazyInit = false;
if (defaultJmsHost != null)
lazyInit = Boolean.parseBoolean(defaultJmsHost.getLazyInit());
// we don't manage lifecycle of remote brokers
if (brokerType == BROKER_TYPE.REMOTE)
return false;
// Initialize on demand is currently enabled based on a system property
String jmsInitializeOnDemand = System.getProperty(JMS_INITIALIZE_ON_DEMAND);
// if the system property is true, don't do eager startup
if ("true".equals(jmsInitializeOnDemand))
return false;
if (brokerType == BROKER_TYPE.EMBEDDED && (!lazyInit))
return true;
// local broker has eager startup by default
if (brokerType == BROKER_TYPE.LOCAL)
return true;
return false;
}
use of com.sun.enterprise.connectors.jms.config.JmsService in project Payara by payara.
the class MQAddressList method getMasterBroker.
public String getMasterBroker(String clustername) {
String masterbrk = null;
// if (rep != null) {
try {
JmsHost mb = getMasterJmsHostInCluster(clustername);
JmsService js = getJmsServiceForMasterBroker(clustername);
MQUrl url = createUrl(mb, js);
masterbrk = url.toString();
if (logger.isLoggable(Level.FINE))
logger.log(Level.FINE, "Master broker obtained is " + masterbrk);
} catch (Exception e) {
LogHelper.log(logger, Level.SEVERE, JMSLoggerInfo.GET_MASTER_FAILED, e);
}
// }
return masterbrk;
}
use of com.sun.enterprise.connectors.jms.config.JmsService in project Payara by payara.
the class ListJMSHosts method execute.
/**
* Executes the command with the command parameters passed as Properties
* where the keys are the paramter names and the values the parameter values
*
* @param context information
*/
public void execute(AdminCommandContext context) {
final ActionReport report = context.getActionReport();
Config targetConfig = domain.getConfigNamed(target);
if (targetConfig != null)
config = targetConfig;
Server targetServer = domain.getServerNamed(target);
// String configRef = targetServer.getConfigRef();
if (targetServer != null) {
config = domain.getConfigNamed(targetServer.getConfigRef());
}
com.sun.enterprise.config.serverbeans.Cluster cluster = domain.getClusterNamed(target);
if (cluster != null) {
config = domain.getConfigNamed(cluster.getConfigRef());
}
JmsService jmsService = config.getExtensionByType(JmsService.class);
if (jmsService == null) {
report.setMessage(localStrings.getLocalString("list.jms.host.invalidTarget", "Invalid Target specified."));
report.setActionExitCode(ActionReport.ExitCode.FAILURE);
return;
}
try {
ArrayList<String> list = new ArrayList();
for (JmsHost r : jmsService.getJmsHost()) {
list.add(r.getName());
}
for (String jmsName : list) {
final ActionReport.MessagePart part = report.getTopMessagePart().addChild();
part.setMessage(jmsName);
}
} catch (Exception e) {
report.setMessage(localStrings.getLocalString("list.jms.host.fail", "Unable to list JMS Hosts") + " " + e.getLocalizedMessage());
report.setActionExitCode(ActionReport.ExitCode.FAILURE);
report.setFailureCause(e);
return;
}
report.setActionExitCode(ActionReport.ExitCode.SUCCESS);
}
use of com.sun.enterprise.connectors.jms.config.JmsService in project Payara by payara.
the class ActiveJmsResourceAdapter method loadRAConfiguration.
/**
* Loads RA configuration for MQ Resource adapter.
*
* @throws ConnectorRuntimeException in case of an exception.
*/
@Override
protected void loadRAConfiguration() throws ConnectorRuntimeException {
JmsService jmsService = getJmsService();
if (jmsService != null && jmsService.getType().equals("DISABLED")) {
throw new ConnectorRuntimeException("JMS Broker is Disabled");
}
if (connectorRuntime.isServer()) {
// Check whether MQ has started up or not.
try {
// if (!JmsProviderLifecycle.shouldUseMQRAForLifecycleControl()) {
// JmsProviderLifecycle.checkProviderStartup();
// } else {
setLifecycleProperties();
// }
} catch (Exception e) {
ConnectorRuntimeException cre = new ConnectorRuntimeException(e.getMessage());
throw (ConnectorRuntimeException) cre.initCause(e);
}
setMdbContainerProperties();
setJmsServiceProperties(null);
setClusterRABeanProperties();
setAvailabilityProperties();
} else {
setAppClientRABeanProperties();
}
super.loadRAConfiguration();
postRAConfiguration();
}
use of com.sun.enterprise.connectors.jms.config.JmsService in project Payara by payara.
the class ActiveJmsResourceAdapter method destroy.
@Override
public void destroy() {
try {
JmsService jmsService = getJmsService();
if (jmsService != null && jmsService.getType().equals("DISABLED")) {
return;
}
if (connectorRuntime.isServer() && grizzlyListenerInit && jmsService != null && EMBEDDED.equalsIgnoreCase(jmsService.getType())) {
GrizzlyService grizzlyService = null;
try {
grizzlyService = Globals.get(GrizzlyService.class);
} catch (MultiException rle) {
// if GrizzlyService was shut down already, skip removing the proxy.
}
if (grizzlyService != null) {
synchronized (grizzlyListeners) {
if (grizzlyListeners.size() > 0) {
String[] listeners = grizzlyListeners.toArray(new String[grizzlyListeners.size()]);
for (String listenerName : listeners) {
try {
grizzlyService.removeNetworkProxy(listenerName);
grizzlyListeners.remove(listenerName);
} catch (Exception e) {
LogHelper.log(_logger, Level.WARNING, JMSLoggerInfo.SHUTDOWN_FAIL_GRIZZLY, e, listenerName);
}
}
}
}
}
grizzlyListenerInit = false;
}
} catch (Throwable th) {
if (_logger.isLoggable(Level.WARNING)) {
_logger.log(Level.WARNING, JMSLoggerInfo.SHUTDOWN_FAIL_JMSRA, new Object[] { th.getMessage() });
}
throw new RuntimeException(th);
}
super.destroy();
}
Aggregations