use of com.tremolosecurity.provisioning.jms.JMSSessionHolder in project OpenUnison by TremoloSecurity.
the class SendMessageThread method lazyInit.
public void lazyInit(ConfigManager cfgMgr) throws ProvisioningException {
try {
smtpQueue = "TremoloUnisonSMTPQueue";
if (cfgMgr.getCfg().getProvisioning() != null && cfgMgr.getCfg().getProvisioning().getQueueConfig() != null) {
smtpQueue = cfgMgr.getCfg().getProvisioning().getQueueConfig().getSmtpQueueName();
}
this.smtpSendSession = JMSConnectionFactory.getConnectionFactory().getSession(smtpQueue);
JMSSessionHolder smtpReceieve = JMSConnectionFactory.getConnectionFactory().getSession(smtpQueue);
smtpReceieve.setMessageListener(this);
} catch (JMSException e) {
throw new ProvisioningException("Could not initialize JMS", e);
}
}
use of com.tremolosecurity.provisioning.jms.JMSSessionHolder in project OpenUnison by TremoloSecurity.
the class SendMessageThread method initLocalBroker.
private void initLocalBroker() throws ProvisioningException {
if (this.isInternalQueue()) {
this.broker = BrokerHolder.getInstance(cfgMgr, "local", this);
this.mpPools = new ArrayList<JMSSessionHolder>();
String taskQueueName = "unison-tasks";
if (this.cfgMgr.getCfg().getProvisioning() != null && this.cfgMgr.getCfg().getProvisioning().getQueueConfig() != null) {
taskQueueName = this.cfgMgr.getCfg().getProvisioning().getQueueConfig().getTaskQueueName();
}
try {
JMSSessionHolder sessionHolder = JMSConnectionFactory.getConnectionFactory().getSession(taskQueueName);
this.mpPools.add(sessionHolder);
} catch (Throwable t) {
logger.warn("Could not create internal queue " + taskQueueName);
}
} else {
this.mpPools = new ArrayList<JMSSessionHolder>();
if (this.cfgMgr.getCfg().getProvisioning().getQueueConfig().isMultiTaskQueues()) {
for (int j = 1; j <= this.cfgMgr.getCfg().getProvisioning().getQueueConfig().getNumQueues(); j++) {
String name = this.cfgMgr.getCfg().getProvisioning().getQueueConfig().getTaskQueueName().replace("{x}", Integer.toString(j));
JMSSessionHolder sessionHolder = JMSConnectionFactory.getConnectionFactory().getSession(name);
this.mpPools.add(sessionHolder);
}
} else {
this.mpPools = new ArrayList<JMSSessionHolder>();
JMSSessionHolder sessionHolder = JMSConnectionFactory.getConnectionFactory().getSession(this.cfgMgr.getCfg().getProvisioning().getQueueConfig().getTaskQueueName());
this.mpPools.add(sessionHolder);
}
}
}
use of com.tremolosecurity.provisioning.jms.JMSSessionHolder in project OpenUnison by TremoloSecurity.
the class SendMessageThread method addMessageListener.
@Override
public void addMessageListener(MessageListenerType mlt) throws InstantiationException, IllegalAccessException, ClassNotFoundException, ProvisioningException, JMSException {
UnisonMessageListener uml = (UnisonMessageListener) Class.forName(mlt.getClassName()).newInstance();
HashMap<String, Attribute> attrs = new HashMap<String, Attribute>();
for (ParamType pt : mlt.getParams()) {
Attribute attr = attrs.get(pt.getName());
if (attr == null) {
attr = new Attribute(pt.getName());
attrs.put(pt.getName(), attr);
}
attr.getValues().add(pt.getValue());
}
uml.init(this.cfgMgr, attrs);
JMSSessionHolder session = JMSConnectionFactory.getConnectionFactory().getSession(mlt.getQueueName());
session.setMessageListener(uml);
this.listenerSessions.put(mlt.getQueueName(), session);
}
use of com.tremolosecurity.provisioning.jms.JMSSessionHolder in project OpenUnison by TremoloSecurity.
the class SendMessageThread method initMessageConsumers.
@Override
public void initMessageConsumers() throws ProvisioningException {
try {
if (cfgMgr.getCfg().getProvisioning() == null) {
return;
}
String taskQueueName = "TremoloUnisonTaskQueue";
if (this.cfgMgr.getCfg().getProvisioning() != null && this.cfgMgr.getCfg().getProvisioning().getQueueConfig() != null) {
taskQueueName = this.cfgMgr.getCfg().getProvisioning().getQueueConfig().getTaskQueueName();
}
if (this.isInternalQueue()) {
TaskConsumer taskConsumer = new TaskConsumer(this, this.cfgMgr);
JMSSessionHolder sessionHolder = JMSConnectionFactory.getConnectionFactory().getSession(taskQueueName);
sessionHolder.setMessageListener(taskConsumer);
} else {
if (this.cfgMgr.getCfg().getProvisioning().getQueueConfig().isMultiTaskQueues()) {
for (int j = 1; j <= this.cfgMgr.getCfg().getProvisioning().getQueueConfig().getNumQueues(); j++) {
String name = this.cfgMgr.getCfg().getProvisioning().getQueueConfig().getTaskQueueName().replace("{x}", Integer.toString(j));
for (int i = 0; i < this.cfgMgr.getCfg().getProvisioning().getQueueConfig().getMaxConsumers(); i++) {
TaskConsumer taskConsumer = new TaskConsumer(this, this.cfgMgr);
JMSSessionHolder sessionHolder = JMSConnectionFactory.getConnectionFactory().getSession(name);
sessionHolder.setMessageListener(taskConsumer);
}
}
} else {
for (int i = 0; i < this.cfgMgr.getCfg().getProvisioning().getQueueConfig().getMaxConsumers(); i++) {
TaskConsumer taskConsumer = new TaskConsumer(this, this.cfgMgr);
JMSSessionHolder sessionHolder = JMSConnectionFactory.getConnectionFactory().getSession(taskQueueName);
sessionHolder.setMessageListener(taskConsumer);
}
}
}
} catch (JMSException e) {
throw new ProvisioningException("Could not initialize task message system", e);
}
}
use of com.tremolosecurity.provisioning.jms.JMSSessionHolder in project OpenUnison by TremoloSecurity.
the class SendMessageThread method enqueue.
public void enqueue(WorkflowHolder wfHolder) throws ProvisioningException {
TextMessage bm;
try {
JMSSessionHolder session;
String originalQueue;
session = this.getTaskMessageProducer();
bm = session.getSession().createTextMessage();
originalQueue = session.getQueueName();
synchronized (session) {
bm.setStringProperty("OriginalQueue", originalQueue);
bm.setStringProperty("WorkflowName", wfHolder.getWorkflow().getName());
bm.setStringProperty("WorkflowSubject", wfHolder.getUser().getUserID());
bm.setStringProperty("JMSXGroupID", "unison");
bm.setStringProperty("nonce", UUID.randomUUID().toString());
TaskHolder holder = wfHolder.getWfStack().peek();
WorkflowTask task = holder.getParent().get(holder.getPosition());
bm.setStringProperty("WorkflowCurrentTask", task.getLabel());
EncryptedMessage encMsg = this.encryptObject(wfHolder);
String json = JsonWriter.objectToJson(encMsg);
bm.setText(json);
session.getMessageProduceer().send(bm);
}
} catch (Exception e) {
throw new ProvisioningException("Could not enqueue message", e);
}
}
Aggregations